2

I want to auto add flat rate shipping cost to any order and display it in the shopping cart summary.

I am using Commerce Shipping and Commerce Flat Rate modules. I can't know how to implement it using rules.

I found this post but it didn't help me.

what I need is to automatically add $10 on every order for shipping, I will disable the Shipping Service Panel.

1

You can do this with Rules. Here is an example:

{
    "rules_auto_add_shipping_service" : {
      "LABEL" : "Auto-add shipping service",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "rules", "commerce_order", "commerce_shipping", "entity" ],
      "ON" : { "commerce_order_update" : [] },
      "IF" : [
        { "data_is" : { "data" : [ "commerce-order:type" ], "value" : "commerce_order" } },
        { "commerce_order_contains_product" : {
            "commerce_order" : [ "commerce_order" ],
            "product_id" : "YOUR-SKU-HERE",
            "operator" : "\u003E=",
            "value" : "1"
          }
        }
      ],
      "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" : [ "" ]
          }
        }
      ]
    }
}

Just change the SKU or the other conditions to suit your needs.

0

You should be able to do this out of the box with FLAT RATE.

Just add your new FLAT RATE for $10 (yoursite.com/admin/commerce/config/shipping then click ADD NEW FLAT RATE) and it will show up in the shipping pane already selected when checking out. It will also create a new line item on the cart summary for SHIPPING.

This will add a $10 flat rate shipping method to every order - if this is not what you are looking for please clarify, hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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