Jump to content

Cannot update order from hook


Recommended Posts

I wish to update an order custom field from ActionValidateOrder hooks but the method $order->update() wont work.

public function hookActionValidateOrder($params) {
    $context = Context::getContext();
    $ps_order = $params['order'];
    $customer = $params['customer'];
    $cart = $params['cart'];
    $virtualAgeOrder = new VirtualAgeWsRequest();
    $rs = $virtualAgeOrder->exportOrder($cart, $ps_order, $customer);
    $erp_order_id = $rs->pedido['cd_pedido'];
    $order = new Order($ps_order->id, (int) $context->language->id);
    $order->virtualagews_order_id = $erp_order_id;
    $order->update() // wont work
}
while the script about works just fine.
include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');


$order = new Order(24, (int) $context->language->id);
$order->virtualagews_order_id = 15;
$order->update(); // works

PS version = 1.6.1.17

 

 

 

 

 
Edited by kelsencrist (see edit history)
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...