Articles


Drupal Commerce: How to remove Shipping pane on the checkout page via Rules?

Drupal Commerce: How to remove Shipping pane on the checkout page via Rules?



Posted byUttam Kotekar,3rd Oct 2016

In this article we will try to remove shipping pane on the checkout page via rules when non-shippabe product is added to the cart. To do so, initially we need to install and enable commerce_rules_extra module and make sure you have also enabled commerce_physical module. You need to enable this module before importing below rule.

  1. Initially we will create an event name called "Remove shipping service pane when subscription added" and event will be "Process change to a checkout pane". This event you will only find it after you enable commerce_rules_extra module.
  2. This rule needs to be trigger only when only non-shippable produce is added to the cart. So first lets create an condition "The order contains shippable product" and also check Negate checkbox and save it.
  3. The condition "The order contains shippable product" you will only find it after you have enabled commerce_physical module. So finally lets create an actions: Add an action "Change pane properties" and pick "Shipping information" on "Id of pane to change" section. Keep "Page to move to" has "<do not change>" and select "Enabled: False." and save it.

Thats it. Check the functionality it work like charm.

{ "rules_remove_shipping_service_pane_when_subscription_added" : {
    "LABEL" : "Remove shipping service pane when subscription added",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "commerce_physical", "commerce_rules_extra" ],
    "ON" : { "commerce_rules_extra_process_checkout_pane" : [] },
    "IF" : [
      { "NOT commerce_physical_rules_order_is_shippable" : { "commerce_order" : [ "commerce_order" ] } }
    ],
    "DO" : [
      { "commerce_rules_extra_change_pane" : {
          "pane_id" : "customer_profile_shipping",
          "page_id" : "\u003Csame\u003E",
          "enabled" : "0"
        }
      }
    ]
  }
}

Categories