I followed this screencast to set free shipping over $30.00:

When having an order of $27.00 and shipping costs of $5.00, going to checkout, going to next page on checkout (review order), and using the back button, the shipping line item is not deleted. The total amount is $32.00 and (whats the point) the user is able to select free shipping method for his $27.00 order.

I setted up the ruleset like shown in the screencast. When i manually go to the url /checkout the shipping line item is deleted correctly. But using the back button the ruleset doenst seem to be executed.

I hope you have a hint for me to workaround this.

Greetings and thanks for the great module(s) and screencast(s).

Members fund testing for the Drupal project. Drupal Association Learn more


MickL’s picture

Issue summary: View changes

missed something

marktheshark’s picture

When you say 'back button', do you mean the browser Back button or the 'Go back' link?

jbova’s picture

I believe he means the "Go back" link next to the "Continue to next step" button. I also followed the instructions in the screencast, with the same result. During the initial calculation, shipping is correct. However, a customer can click the "Go back" button and then select "free shipping" if the order total with shipping is greater than the data comparison value.

How to duplicate:
Flat rate shipping condition: Order total less than 1000.
Flat rate shipping action: Add flat rate shipping of $9.99.
Free shipping condition: Order total greater than 9999.
Free shipping action: Add free shipping service

checkout process
Initial order total: $95.00
Shipping service presented to visitor: Flat rate $9.99
Click "Continue to next step"
Checkout payment screen totals: Subtotal: $95.00, Shipping: $9.99, Order Total: $104.99
Click on the "Go back" button
Shipping service presented to visitor is now: Free shipping $0.00
Click "Continue to next step"
Checkout payment screen totals: Subtotal: $95.00, Shipping: $0.00, Order Total: $95.00

The above order should not qualify for free shipping, but it does. This is despite the fact that a custom ruleset has been created to delete all shipping line items from an order prior to calculating shipping.

nodecode’s picture

I agree this is messed up. I tried "Delete all shipping line items from an order" before the loop but that throws an error each time and only after I reload the page does it work as it's supposed to.

Still looking for a working solution...

nodecode’s picture

Status: Active » Fixed
713 bytes

Here's the solution. I modified some code I got from #1892414: Clear Shipping line item on shipping stage (status). Just import the attached rule and as long as your shipping calculation is happening in the "Shipping" checkout pane and you have the "Review order" pane active, it should all just work now.

You can thank me later.

P.S. you may also find this comment helpful for adding some conditions to your shipping calculation rules to ensure they only apply to one shipping method at a time: https://drupal.org/node/1415638#comment-5520628

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

spelling mistakes

bpirkle’s picture

nodecode said to thank him later, and it is later now, so thank you. :-)

The solution from #4 works beautifully in the case described in the screencast, where the customer is presented with either a single flat rate option or a single free option.

Be aware that this technique has an issue if more shipping options are presented along with free shipping. Because the rule clears any shipping selection, whatever the customer may have chosen will be discarded.

In our case, we offer free shipping for certain orders, but also the option to pay for faster shipping. So the user is presented with several shipping radio buttons like Free, Priority, and Overnight.

If a customer selects Overnight and proceeds to Review, then backs up, the rule from #4 will have cleared their choice, and the Free method will again be selected. The customer may then get confused, thinking that the system isn't remembering the shipping choice (even though it'd be fine if they just submit the order). Or worse, they don't realize their choice of Overnight was lost, proceed with checkout, then call asking why their package didn't show up the next day.

I don't have a solution yet, but I'll post one if I come up with it.

bpirkle’s picture

Well, I have a solution but I'm not thrilled with it.

Instead of using the "Data Comparison" described in the screencast, I wrote a PHP function that determines if an order qualifies for free shipping and used that as my condition.

I put something like this in a custom module (I altered my actual code to make the module name generic and to use the $30.00 cutoff from the original issue.)

function mymodule_rules_condition_info() {
  return array(
    'mymodule_order_qualifies_for_free_shipping' => array(
      'group' => 'MyModule',
      'label' => t('MyModule order qualifies for free shipping'),
      'parameter' => array(
        'commerce_order' => array(
          'type' => 'commerce_order',
          'label' => t('Order'),
      'callbacks' => array(
        'execute' => 'mymodule_order_qualifies_for_free_shipping',

function mymodule_order_qualifies_for_free_shipping($order) {
  $qualifies = FALSE;

  $product_total_price = 0;
  foreach (entity_metadata_wrapper('commerce_order', $order)->commerce_line_items as $line_item_wrapper) {
    $type = $line_item_wrapper->type->value();
    if ($type == 'product') {
      $line_item_total = $line_item_wrapper->commerce_total->value();
      $product_total_price += $line_item_total['amount'];

  if ($product_total_price > 3000) {
    $qualifies = TRUE;

  return $qualifies;

I'd prefer a full pointy-clicky solution that didn't involve writing code, but I don't have one at the moment.

Be aware that my products have a machine name of "product". If your product machine name(s) differ, that comparison within the PHP would need adjustment.

(There's probably also a way to do this without a module via "Execute custom PHP code", but our development standards are to keep PHP out of the database. So I used a module.)

BD3’s picture

Category: Support request » Bug report
Issue summary: View changes
Status: Closed (fixed) » Active

I am going to reopen this as a bug so it is able to get the attention it needs. A user clicking the browser back button should not affect the pricing of shipping.

The rule in #4 works only one time, if the user clicks the back button then goes back to the review page and back again, free shipping is applied.

#7 is a good start, but I am not so sure that a module should have to be implemented for a customer using a browser function (although thank you for sharing for a quick fix).

abautu’s picture

I have this same problem now. Indeed #4 works for "Go back" button on checkout form (which updates the order status), but doesn't work for "Back" button in the browser (which doesn't update the order status). My fix for both cases was to include an "Execute PHP" condition at the top of the free payment method (before comparing price with the threshold for free shipping). In this "condition" I used the following code:

return true;
pushkspl’s picture

I have tried the comment #7 and it's working fine for me.