Jump to content

[Solved] This Simple Update Query Doesn't Work, What Am I Missing?


jotacee

Recommended Posts

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 by jotacee (see edit history)
Link to comment
Share on other sites

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 by safa (see edit history)
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...