If like me you need to clear the shipping line item when going back from review to shipping (or any other path back to shipping) you can use the rule below to do so.
This can be handy in various use cases like when needing to have shipping calculation based on order total.
The rule is

Event:
After updating an existing commerce order

Conditions:
Data comparison: commerce-order:status = Checkout: Shipping
Shipping line item exists

Action:
Delete all shipping line items from an order

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guy_schneerson’s picture

Attaching an export of the rule, hope other find it useful.

Horroshow’s picture

Issue summary: View changes

Useful! Thanks!

svouthi’s picture

I was excited to see this because I have rules which add fees based upon shipping cost/type and things get messy when a user backs out of Checkout Review and returns to Checkout or Shipping with all those line items staying present. However, this rule isn't working for me. Instead of removing the shipping line item if the user leaves the Checkout Review page, the shipping line item is removed between adding it on the Shipping page and arriving at Checkout Review (such that there is no shipping charge.)

I experimented with changing the data comparison to Checkout:Review instead of Checkout:Shipping, but the behavior is the same. When I change it to Checkout:Checkout, the shipping line item doesn't get cleared.

calebyoder’s picture

Yes, I struggled with this issue for hours as well. :( What finally seems to be working fairly good is when I added the following condition.

NOT Data comparison: commerce-order-unchanged:status = Checkout: Shipping

Thanks for sharing this, guy_schneerson!

-Caleb

barry6575’s picture

Confirmed #1 & #4 solved the issue for me. Thanks!

CaptChawrls’s picture

Confirmed #1 & #4 solved the issue for me, too. However, since my shipping choice option had been moved to step 1 of checkout (I was trying to limit the number of stages of checkout), I had to modify #4 to point to the correct step in the process (i.e. Checkout: Checkout instead of Checkout: Shipping).

Before I added this rule, when the user went to step 1 of checkout and then returned to the view cart page, there was a blank line item (i.e. no title, only claculated shipping price and a remove button) appearing that wouldn't go away. Additionally, it also caused the update button to generate a fatal error when clicked -- EntityMetadataWrapperException: Unknown data property commerce_product. in EntityStructureWrapper->getPropertyInfo() ...