Conditional Shipping and Payments

Conditional Shipping and Payments gives you complete control over the payment gateways, shipping methods and shipping countries/states available to customers during checkout. It allows you to create multiple exclusion rules based on many conditions, which can be combined together to implement very complex restrictions.

This guide will introduce you to the basic concepts behind Conditional Shipping and Payments, demonstrate the process of setting it up and give you real-life examples that will help you get a clear idea of how it works.

The extension will not create any new payment gateways for you. However, it allows you to conditionally activate existing payment gateways based on conditions such as the selected shipping method, selected billing/shipping country and state, cart/order total, user role, user e-mail, and more.
The extension will not create any new shipping methods for you. However, it allows you to conditionally disable existing shipping methods — or shipping method instances attached to specific Shipping Zones, if you are using WooCommerce 2.6+. Exclusion rules can be combined with conditions, such as the selected billing/shipping country/state (better handled using Shipping Zones in WooCommerce 2.6+), package weight, cart contents, customer role, etc. For details, see Example 1. Note that if you need to create very complex shipping rules and rates, it is strongly recommended to use the Table Rate Shipping extension, which was made specifically for this purpose.

Installation ↑ Back to top

  1. Ensure you have the latest version of WooCommerce installed.
  2. Unzip and upload the plugin’s folder to your /wp-content/plugins/ directory.
  3. Activate the extension from the Plugins menu in WordPress.

How it Works ↑ Back to top

When a customer checks out items in their cart, they are normally presented with some country/state options, some shipping method options and, finally, some payment options, according to how you have set up WooCommerce.

You can find some general information about setting up WooCommerce here, while this reference is particularly useful if you want to learn more about shipping methods. Payment options included in WooCommerce are described here, and there is also a handy guide about Premium Payment Gateway options.

Conditional Shipping and Payments works by excluding some of these options, or by showing a helpful notice when a customer attempts to use an excluded option.

To achieve this, the extension introduces the Restrictions concept: A restriction is basically an exclusion rule applied to one ore more of these checkout options, which is evaluated based on a set of conditions specified in the rule.

Some examples or restriction rules:

  • Disable the Direct Bank Transfer payment option when the order total is below $1000.
  • Enable the Direct Bank Transfer payment option for specific customers or customer roles only.
  • Disable the PayU payment option if the selected billing country is not Poland.
  • Disable the Express Mail Europe add-on flat-rate shipping option if the selected shipping country is not a European country and the order total is lower than $50.
  • Disable the Continental US Express Mail add-on flat-rate shipping option when customers select a non-continental US State.
  • Prevent orders from being shipped abroad if they contain products from the Fresh Foods category.
  • Prevent products in the Batteries category from being shipped with the Royal Mail shipping option.

Getting Started ↑ Back to top

The extension includes two types of Restrictions that you can use to conditionally activate payment and shipping options:

  • Product-level Restrictions
  • Global Restrictions

The objective of this chapter is to give you a good understanding of what Restrictions do and how you can use them to control your payment and shipping options.

Product-level Restrictions ↑ Back to top

As their name suggests, product-level restrictions are exclusion rules associated with specific products. Product-level restrictions are evaluated only if the product associated with the restriction is present in the cart during checkout. As you might have guessed already, they are created and accessed from the Product Data section located in the edit-product screen:

Example of a Product-based Restriction
Example of a Product-based Restriction

In this example, we have created a single Shipping Countries & States restriction for a simple product – Rechargeable Lithium Battery. The restriction prevents customers from selecting the United States as a shipping destination for this product, unless the order total is higher than $100. In this example, this particular Europe-based shop was required to use special, expensive packaging for battery shipments to the US – a process which had a high administrative cost that was only justified above a minimum order value.

Note that you can create product-level restrictions for:

  • Shipping Countries & States,
  • Payment Gateways and
  • Shipping Methods.

Additionally, you can create multiple rules for the same restriction class — for example, it is possible to create multiple Payment Gateway restrictions for different payment gateways, or multiple restrictions (with different conditions) that target the same payment gateway.

Product-based restrictions can be created for all types of shipping and payment options.
Product-based restrictions can be created for all types of shipping and payment options.

Global Restrictions ↑ Back to top

Global restrictions are the most flexible, since they are not associated with specific products – they are always evaluated during checkout. Global restrictions are created and managed from a dedicated Restrictions tab found by navigating to WooCommerce > Settings > Restrictions:

Global restrictions accessed under Settings > Restrictions.
Global restrictions accessed under Settings > Restrictions.

There, you will find 3 sections dedicated to creating and modifying global restrictions for:

  • Shipping Countries & States,
  • Payment Gateways and
  • Shipping Methods.

Here’s an example of a very simple global restriction:

A simple Global Restriction.
A simple Global Restriction.

This Payment Gateway restriction disables the Direct Bank Transfer option for all orders with a value lower than $1000.

Note that, just like with product-level restrictions, you can create as many rules for the same restriction class as you want.

Conditions ↑ Back to top

As we have seen so far, every restriction rule is evaluated based on an assortment of conditions which decide if the targeted option(s) will be disabled or not.

Conditions are very straightforward when looked at individually – however, to use them successfully, you must remember that a restriction rule will be in effect only if all defined conditions match at the same time.

To outline this concept better, let’s look at an example similar to the Rechargeable Lithium Battery product-based restriction that we saw earlier – only a bit more complex:

This time, we’re creating a global restriction to exclude all available shipping methods when customers:

  • choose the United States as the shipping destination of their order,
  • the order contains any product from the Batteries category and
  • its total is under $100.
A restriction with multiple conditions.
A restriction with multiple conditions.

The restriction will work only when all 3 conditions match simultaneously: If any of them is not satisfied, all shipping methods will be available as usual.

Working with multiple conditions - checkout notice.
Working with multiple conditions – checkout notice.

Restrictions Reference ↑ Back to top

Payment Gateways ↑ Back to top

Payment Gateway restrictions allow you to conditionally disable/exclude payment gateways.

Creating Global Rules

You can create global restriction rules for payment gateways by navigating to WooCommerce > Settings > Restrictions > Payment Gateways.

To add a new rule, click on the Add Global Restriction button. Then go on to configure its parameters:

  1. Enter a Short Description to identify this rule. As you add more rules, short descriptions will make it easier for you to manage them effectively.
  2. Select one or more Payment Gateways that you want to conditionally disable with this new rule.
  3. Configure the Show Excluded setting. By default, excluded payment gateways are removed from the list of gateways available during checkout. Select this option if you prefer to show excluded gateways in the checkout options, and have a notice displayed when customers attempt to complete an order using an excluded payment option.
  4. Define exclusion conditions – the restriction will work if all defined conditions are satisfied simultaneously. If you don’t use any conditions, the gateways targeted by the rule will always be excluded/disabled.
Condition Description
Billing Countries In effect if the billing country selected during checkout is (or is not) included in this list.
Shipping Countries In effect if the shipping country selected during checkout is (or is not) included here. If any specific States/Regions are defined, the condition will be true if State/Region selected during checkout is (or is not) in the list.
Shipping States / Regions Part of the Shipping Countries condition – see above.
Order Total In effect if the checkout order total is lower (<) or higher (>=) than this value.
Shipping Methods In effect if the shipping method selected during checkout is (or is not) included here.
Product Categories In effect if the cart contains (or does not contain any) products from the categories included here.
Product Shipping Classes In effect if the cart contains (or does not contain any) products from the shipping classes included here.
Customer In effect if the current customer’s e-mail is (or is not) found in the e-mails included here.
Customer Role In effect if the current customer’s role is (or is not) found in the specified list of roles.

Creating Product-level Rules

Use product-level restriction rules for payment gateways if you want to exclude/disable one or more payment gateways when a specific product is in the cart. Product-level restrictions can be added from the Product Data > Restrictions tab located in every edit-product screen.

To add a new rule, select the Payment Gateways restriction and click on the Add Restriction button. Then go on to configure its parameters. The Short Description, Payment Gateways, and Show Excluded options are identical with their Global restriction equivalents. However, the available Conditions are slightly different:

  1. The Product Categories and Product Shipping Classses conditions are unavailable, since product-level rules are linked to a specific product.
  2. There is a new condition, Product Quantity:
Condition Description
Product Quantity In effect if the cart item quantity of the product involved is lower (<) or higher (>=) than this value.

Shipping Methods ↑ Back to top

Shipping Method restrictions allow you to conditionally disable/exclude shipping methods — or, shipping method instances added to specific Shipping Zones when using WooCommerce version 2.6+.

Creating Global Rules

You can create global restriction rules for shipping methods by navigating to WooCommerce > Settings > Restrictions > Shipping Methods.

To add a new rule, click on the Add Global Restriction button. Then go on to configure its parameters:

  1. Enter a Short Description to identify this rule. As you add more rules, short descriptions will make it easier for you to manage them effectively.
  2. Select one or more Shipping Methods that you want to conditionally exclude/disable with this new rule.
  3. Configure the Show Excluded setting. By default, excluded shipping methods are removed from the list of options available during checkout. Check this box if you prefer to show excluded payment methods in the checkout options, and have a notice displayed when customers attempt to complete an order using an excluded shipping method.
  4. Define exclusion conditions – the restriction will work if all defined conditions are satisfied simultaneously. If you don’t use any conditions, the shipping methods targeted by the rule will always be excluded/disabled. Remember that most shipping method conditions operate at package-level, for compatibility with extensions that create multiple shipment packages from a single cart.
Condition Description
Shipping Countries In effect if the shipping country selected during checkout is (or is not) included here. If any specific States/Regions are defined, the condition will be true if State/Region selected during checkout is (or is not) in the list.
Shipping States / Regions Part of the Shipping Countries condition – see above.
Billing Countries In effect if the billing country selected during checkout is (or is not) included in this list.
Cart Total In effect if the cart total (after discounts, including taxes) is lower (<) or higher (>=) than this value.
Product Categories In effect if the package contains (or does not contain any) products from the categories included here.
Product Shipping Classes In effect if the package contains (or does not contain any) products from the shipping classes included here.
Package Weight In effect if the total package weight is lower (<) or higher (>=) than this value.
Customer In effect if the current customer’s e-mail is (or is not) found in the e-mails included here.
Customer Role In effect if the current customer’s role is (or is not) found in the specified list of roles.

Creating Product-level Rules

Use product-level restriction rules for shipping methods if you want to exclude/disable one or more shipping methods when a specific product is in the cart. Product-level restrictions can be added from the Product Data > Restrictions tab located in every edit-product screen.

To add a new rule, select the Shipping Methods restriction and click on the Add Restriction button. Then go on to configure its parameters. The Short Description, Shipping Methods, and Show Excluded options are identical with their Global restriction equivalents. However, the available Conditions are slightly different:

  1. The Product Categories and Product Shipping Classes conditions are unavailable, since product-level rules are linked to a specific product.
  2. There is a new condition, Product Quantity:
Condition Description
Product Quantity In effect if the cart item quantity of the product involved is lower (<) or higher (>=) than this value.

Shipping Countries & States ↑ Back to top

Shipping Country & State restrictions allow you to conditionally prevent customers from checkout out when specific shipping countries or states are selected.

Creating Global Rules

You can create global restriction rules for shipping countries & states by navigating to WooCommerce > Settings > Restrictions > Shipping Countries & States.

To add a new rule, click on the Add Global Restriction button. Then go on to configure its parameters:

  1. Enter a Short Description to identify this rule. As you add more rules, short descriptions will make it easier for you to manage them effectively.
  2. Select one or more Shipping Countries that you want to conditionally disable with this new rule. If you need to disable specific Shipping States / Regions from one or more countries, you still need to add these countries here select specific pick states / regions in the next step.
  3. If you need to disable specific states or regions in the countries you added in the previous step, select the Specific States / Regions option from the Exclude States / Regions dropdown. Then select the states or regions that you want to disable.
  4. Optionally set a Custom Checkout Notice to be displayed when this rule is in effect. The default checkout notice should be sufficient in most cases – it is recommended to test what your customers will see when this rule is triggered and change the notice text only if necessary.
  5. Define exclusion conditions – the restriction will work when all defined conditions are satisfied simultaneously. If you don’t use any conditions, the countries/states targeted by the rule will always be restricted.
Condition Description
Cart Total In effect if the cart total (after discounts, including taxes) is lower (<) or higher (>=) than this value.
Product Categories In effect if the cart contains (or does not contain any) products from the categories included here.
Product Shipping Classes In effect if the cart contains (or does not contain any) products from the shipping classes included here.
Customer In effect if the current customer’s e-mail is (or is not) found in the e-mails included here.
Customer Role In effect if the current customer’s role is (or is not) found in the specified list of roles.

Creating Product-level Rules

Use product-level restriction rules for shipping countries & states if you want to prevent customers from using or more shipping country or state options when a specific product is in the cart. Product-level restrictions can be added from the Product Data > Restrictions tab located in every edit-product screen.

To add a new rule, select the Shipping Countries & States restriction and click on the Add Restriction button. Then go on to configure its parameters. The Short Description, Shipping Countries, and Exclude States / Regions options are identical with their Global restriction equivalents. However, the available Conditions are slightly different:

  1. The Product Categories and Product Shipping Classses conditions are unavailable, since product-level rules are linked to a specific product.
  2. There is a new condition, Product Quantity:
Condition Description
Product Quantity In effect if the cart item quantity of the product involved is lower (<) or higher (>=) than this value.

Examples ↑ Back to top

1. Conditional Flat Rates ↑ Back to top

WooCommerce 2.6+

The extension can be used to conditionally disable entire shipping methods, or exclude method instances attached to specific Shipping Zones. For this example, we will create multiple Flat-Rate shipping method instances in 2 Shipping Zones and enable them conditionally, depending on the order weight.

Here, it is assumed that the General Options of WooCommerce have been set to use 3 Selling Locations – Canada, Mexico and the United States (including non-continental States).

For simplicity, the Shipping setup of this Example is based on 2 Shipping Zones:

Zone Name Destinations
Zone A Continental US States only.
Zone B Canada, Mexico and non-continental US States.

Our objective is to offer 2 shipping rate options per Zone, depending on order weight:

Rate Name Zone Weight Rate
Zone A Standard Zone A Less than 2 kg. $7
Zone A Heavy Zone A More than 2 kg but no higher than 5 kg. $14
Zone B Standard Zone B Less than 2 kg. $10
Zone B Heavy Zone B Between 2 kg but no higher than 5 kg. $17

Following the WooCommerce Shipping Zones documentation, start by creating the 2 Zones, and then proceed by adding 2 instances of the Flat-Rate shipping method in each Zone. Use the data from the previous table to fill in the Method Title and Cost fields of each Flat-Rate method instance you create.

Next, create the necessary Shipping Method restrictions by navigating to Settings > Restrictions > Shipping Methods.

This is an overview of the required restriction rules, 3 in total:

Example 1 – Restriction rules overview.
Example 1 – Restriction rules overview.

Rule #1 – 5kg weight limit:

Example 1 – Rule #1: 5kg weight limit.
Example 1 – Rule #1: 5kg weight limit.

Rule #2 – Exclude Zone A Standard and Zone B Standard rates when weight >= 2kg:

Example 1 – Rule #2: Exclude Zone A/B if weight >= 2kg.
Example 1 – Rule #2: Exclude Zone A/B if weight >= 2kg.

Rule #3 – Exclude Zone A Heavy and Zone B Heavy rates when weight < 2kg:

Example 1 – Rule #3: Exclude Zone A/B Heavy if weight < 2kg.
Example 1 – Rule #3: Exclude Zone A/B Heavy if weight < 2kg.

WooCommerce 2.5-

The extension allows you to use the core Flat-Rate shipping method to create quite complex shipping rules and rates. This is possible by making use of the Add-on Rates functionality included with the Flat-Rate method: The idea is to create multiple add-on rates and enable them conditionally based on the shipping destination and/or order weight.

For this example, we will use the Flat-Rate shipping method to create 2 shipping “zones” with 2 rates per “zone”, depending on the order weight.

This method is only practical if you want to create a few shipping zones, using weight-based rates. If you need to create many zones with very complex shipping rules and rates, please use the Table Rate Shipping extension, which was made specifically for this purpose.

Here, it is assumed that the General Options of WooCommerce have been set to use 3 Selling Locations – Canada, Mexico and the United States:

Example 1 – General Settings.
Example 1 – General Options.

The objective is to create the following 4 shipping rate options:

Rate Name Destinations Weight Rate
Zone A Continental US States only. Less than 2 kg. $7
Zone B Canada, Mexico and non-continental US States. Less than 2 kg. $10
Zone A Heavy Continental US States only. More than 2 kg but no higher than 5 kg. $14
Zone B Heavy Canada, Mexico and non-continental US States. Between 2 kg but no higher than 5 kg. $17

First, we will use the Flat-Rate shipping method and its Add-on Rates functionality to create the 4 shipping rate options:

Example 1 – Flat-Rate settings.
Example 1 – Flat-Rate settings.

Note that the Flat-Rate shipping method has been titled Zone A, while Zone B, Zone A Heavy and Zone B Heavy have been created as add-on rates.

Next, we will create the necessary Shipping Method restrictions by navigating to Settings > Restrictions > Shipping Methods.

This is an overview of the required restriction rules, 5 in total:

Example 1 – Restriction rules overview.
Example 1 – Restriction rules overview.

Rule #1 – 5kg weight limit:

Example 1 – Rule #1: 5kg weight limit.
Example 1 – Rule #1: 5kg weight limit.

Rule #2 – Exclude Zone A and Zone B rates when weight >= 2kg:

Example 1 – Rule #2: Exclude Zone A/B if weight >= 2kg.
Example 1 – Rule #2: Exclude Zone A/B if weight >= 2kg.

Rule #3 – Exclude Zone A Heavy and Zone B Heavy rates when weight < 2kg:

Example 1 – Rule #3: Exclude Zone A/B Heavy if weight < 2kg.
Example 1 – Rule #3: Exclude Zone A/B Heavy if weight < 2kg.

Rule #4 – Exclude Zone B and Zone B Heavy rates when selecting Zone A and Zone A Heavy destinations (Continental US States):

Example 1 – Rule #4: Exclude "Zone B" and "Zone B Heavy" when shipping to Continental US States.
Example 1 – Rule #4: Exclude “Zone B” and “Zone B Heavy” when shipping to Continental US States.

Rule #5 – Exclude Zone A and Zone A Heavy rates when selecting Zone B and Zone B Heavy destinations (Non-Continental US States, Mexico and Canada):

Example 1 – Rule #5: Exclude "Zone A" and "Zone A Heavy" when shipping to Non-Continental US States, Mexico and Canada.
Example 1 – Rule #5: Exclude “Zone A” and “Zone A Heavy” when shipping to Non-Continental US States, Mexico and Canada.

Example 2. Shipping Carrier TOS Compliance ↑ Back to top

Working with a Shipping Carrier often requires you to adhere to specific Terms of Service for shipping various types of products, such as dangerous goods. Depending on the shipping destination, shipping method and package contents, a carrier may refuse to handle your shipment, or may have specific pricing, packaging, handling or forwarding requirements.

Here, we are going to look an example we briefly touched upon at the beginning of this guide:

Exclude the Royal Mail method if a package contains products from the Batteries category:

Example 2 – Exclude Royal Mail when shipping Batteries.
Example 2 – Exclude Royal Mail when shipping Batteries.

Example 3. Customs Import Regulations ↑ Back to top

Some countries/states do not permit certain types of goods to be imported – tobacco and vaping gear, for instance, are prohibited in many countries. If your day-to-day routine includes cancelling orders and sending refunds due to customs import restrictions, it might be a good idea to consider a more effective, transparent approach that: i) prevents customers from checking out when choosing a restricted shipping country, and ii) gives them a suitable explanation.

Shipping Country & State restrictions are ideal in such cases, as they allow you to create custom notices that you can use to communicate with your customers.

Use Shipping Country/State rules to implement restrictions that arise from policies, laws or regulations associated with the chosen shipping country or state. When possible, use custom notices to direct customers to alternative courses of action.

Example 4. Payment Gateway TOS Compliance ↑ Back to top

Depending on what you are selling and how, compliance with the terms and conditions of your payment gateways may require some attention on your part. For instance, most payment gateways provide a list of items that you are not allowed to sell through them, or may have specific shipping requirements. In some cases, sellers might be required to use only shipping carriers that provide proof of the exact shipment date and destination, such as a trackable shipment ID.

The extension allows you to define Payment Gateway restrictions based on many conditions, including the selected shipping method(s). In the following example, a Payment Gateway rule is created to exclude PayPal when selecting the Unregistered Postal Delivery shipping method:

Example 4 – Exclude PayPal when shipping via unregistered Snail Mail.
Example 4 – Exclude PayPal when shipping via unregistered Snail Mail.

FAQ ↑ Back to top

How to exclude certain shipping methods of any major shipping courier? For example, FedEx Ground only and not entire FedEx?

Let’s say you want to disable FedEx Ground shipping method if, for example, perishable products have been added to the cart and they need to be shipped faster. You can exclude FedEx Ground by specifying it in the Shipping Rate ID field.

You would need to use exact spelling as in the FedEx settings:

screen-shot-2016-10-27-at-10-01-16-am

You will also need to use placeholder “fedex:” which should precede the name of the shipping method as follows:

fedex:FEDEX_GROUND

As a result, the restriction should look as follows:

screen-shot-2016-10-27-at-10-03-21-am

 

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top