The submit handler for the commerce_shipping_pane removes and re-adds the shipping line item without the intent of saving the order which is specified by the $skip_save parameter for commerce_shipping_delete_shipping_line_items
and commerce_shipping_add_shipping_line_item
.
However commerce_shipping_delete_shipping_line_items
calls commerce_line_item_delete_multiple
which again calls commerce_line_item_delete_references
where eventually entity_save is used on the referenced order entity. In other words, commerce_shipping_delete_shipping_line_items
triggers an order update regardless of the $skip_save parameter.
This causes the hook_commerce_order_update to run only when the shipping line item is removed and I end up with the wrong calculation for order total.
/**
* Checkout pane callback: submit the shipping checkout pane.
*/
function commerce_shipping_pane_checkout_form_submit($form, &$form_state, $checkout_pane, $order) {
...
// Delete any existing shipping line items from the order.
commerce_shipping_delete_shipping_line_items($order, TRUE);
...
// Save and add the line item to the order.
commerce_shipping_add_shipping_line_item($line_item, $order, TRUE);
Comments