Drupal Commerce auto calculate shipping in cart problem

by Bill Hanson   Last Updated December 03, 2017 16:07 PM

0 down vote

I have been using a rule to auto calculate and add shipping to the shopping cart. I have one problem which I can't seem to find a solution. My rule correctly calculates shipping for any products added to cart but it does not calculate correctly when there are multiple quantities of same SKU or if you change quantity in the cart. It does re-calculate correctly when you go to checkout review, though. If you click 'Update Cart' a second time it updates the shipping to the correct value, just not on the first update. I just can't get it to update with the correct shipping in the cart view. Is this a problem with my view, or the calculation? Here is my rule:

{ "rules_auto_add_shipping_service" : { "LABEL" : "Auto-add shipping service", "PLUGIN" : "reaction rule", "OWNER" : "rules", "REQUIRES" : [ "commerce_order", "rules", "commerce_shipping", "commerce_cart", "entity" ], "ON" : { "commerce_cart_product_add" : [], "commerce_cart_product_remove" : [], "commerce_line_item_update" : [], "commerce_order_insert" : [], "commerce_order_update" : [] }, "IF" : [ { "commerce_order_compare_total_product_quantity" : { "commerce_order" : [ "commerce_order" ], "operator" : "\u003E=", "value" : "1" } }, { "data_is" : { "data" : [ "commerce-order:status" ], "op" : "IN", "value" : { "value" : { "cart" : "cart", "checkout_checkout" : "checkout_checkout", "checkout_review" : "checkout_review" } } } }, { "data_is" : { "data" : [ "commerce-order:type" ], "value" : "commerce_order" } } ], "DO" : [ { "commerce_shipping_delete_shipping_line_items" : { "commerce_order" : [ "commerce_order" ] } }, { "commerce_shipping_method_collect_rates" : { "shipping_method_name" : "flat_rate", "commerce_order" : [ "commerce_order" ] } }, { "commerce_shipping_rate_apply" : { "commerce_order" : [ "commerce_order" ], "shipping_service_name" : [ "" ] } } ] } }

Thanks for any help with this, and let me know if you need any other info



Related Questions


Add multiple cart in drupal 7

Updated August 15, 2015 17:03 PM




How to create custom commerce order states?

Updated May 17, 2015 08:03 AM