1

I am using this simple code:

$order = commerce_order_load($order_id);
$order->status='completed';
field_attach_update('commerce_order', $order);

To update the status of order to completed.

This code use to work but does not work anymore (the order status is not updated).

How to debug this ?

UPDATE:

Using :

entity_get_controller('commerce_order')->resetCache(array($order->order_id));

Does not work neither.

1

You can't debug what ain't a bug :)

status is a property, not a field, of the commerce_order entity type - so it isn't affected by running field_attach_update(), which just saves field data, and avoids saving the entity itself.

You'll need to use commerce_order_save(), entity_save(), or manipulate the commerce_order table directly, and then clear the cache using the entity controller.

| improve this answer | |
  • 1
    You beat me to it ;) – Neograph734 May 18 '16 at 14:52
  • @Clive how is that this worked previously ? – Michal Przybylowicz May 18 '16 at 15:00
  • I'm not really sure how to answer that - according to the code, it didn't. – Clive May 18 '16 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.