jotacee Posted February 18, 2016 Share Posted February 18, 2016 (edited) Hi guys, I tried with a lot of changes to this simple line, but I can't get it to work. I just want to update id_Shop value in an order when city has a specific value: if($delivery->city == "New York") { $sql = 'UPDATE `'._DB_PREFIX_.'orders` SET `id_shop` = 2 WHERE `id_order` = '.(int)$order->id; if (!Db::getInstance()->execute($sql)) die('error!'); } I also tried: // Db::getInstance()->update('orders', 'id_shop = 2', 'id_order = '.(int)$order->id, 1); // Db::getInstance()->update('orders', array('id_shop' => 2), 'reference = '.$order->reference, 1); Then a new order arrives with "New York" value... but mysql tablet ps_orders doesn't get the update in that value. I'm pretty sure it's something really stupid that I'm missing. How can I make this work? Thanks dudes, jc Edited February 22, 2016 by jotacee (see edit history) Link to comment Share on other sites More sharing options...
safa Posted February 18, 2016 Share Posted February 18, 2016 (edited) hi , which using this code in php file ? regards ?? id_shop can be setting payment modules valideorder() order fuction. sample for bankwire module. $this->module->validateOrder($cart->id, 2, $total, $this->module->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key); you can add extra paremeter like this $this->module->validateOrder($cart->id, 2, $total, $this->module->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key, $idshop); also you can set to all payments modules on classes/PaymentModule.php file public function validateOrder(); if id_shop not setting valideorder function prestashop getting current cart id shop value $this->context->shop = ($shop ? $shop : new Shop((int)$this->context->cart->id_shop)); you can chance to. regards... Edited February 18, 2016 by safa (see edit history) Link to comment Share on other sites More sharing options...
jotacee Posted February 18, 2016 Author Share Posted February 18, 2016 Thanks for your reply, safa. I have a cron job that checks all orders, looking for orders in that city and moving them from one shop (multishop) to another. I don't need to validate the order, as it's already validated and paid. I just need to move it from one shop to another inside same multishop. I was trying to execute that simple query but it doesn't affect any row. Link to comment Share on other sites More sharing options...
safa Posted February 19, 2016 Share Posted February 19, 2016 ps_orders_detail have a id_shop to , if you share your php file with us. i wil try help you. regards.. Link to comment Share on other sites More sharing options...
jotacee Posted February 22, 2016 Author Share Posted February 22, 2016 Thanks, Safa. It turns out that I can execute that query ok from an outside php controller. I don't know why it doesn't work inside a modification in maillalerts module. Now it's working. But the mystery is unsolved Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now