0

I manually update an order using the following code.

db_update('uc_orders') // Table name no longer needs {}
  ->fields(array(
    'order_status' => 'payment_received',
  ))
  ->condition('order_id', $order->order_id)
  ->execute();

Then I visit /admin/store/orders/view, but the value for the order still shows a Pending. If I clear the cache, the new status is Payment received, as it should be.

How do I clear the specific order cache so that it updates immediately?

The following code does what I want, but I would prefer clearing the cache for the specific order that is manually updated.

$orderEntity = Order::load($order_id);
$orderEntity->setStatusId('payment_received');
$orderEntity->save();

1 Answer 1

1
\Drupal::service('entity_type.manager')->getStorage('commerce_order')->resetCache([ORDER_ID]);

This service which used in OrderReassignTest.php will help you to Reload the order based on Order ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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