Installation
- Download the optimizeform core .zip file from your Optimizeform account.
- Go to: WordPress Admin > Plugins > Add New and Upload Plugin with the file you downloaded with Choose File.
- Install Now and Activate the extension.
The extension does not create any new shipping/payment methods for you. You can use it to conditionally exclude existing shipping/payment methods based on various parameters, such as: the selected billing/shipping country/state, the total package/order weight, package/cart contents, the current customer/user role or e-mail, and more.
How it Works
Depending on how you have set up WooCommerce, the checkout page of your store probably offers at least a few:
- Country/State options
- Shipping Method options
- Payment Gateway options
Conditional Shipping and Payments allows you to conditionally hide/remove some of these options, or display a helpful notice when a customer attempts to use an excluded option. This is possible by creating exclusion rules that may include conditional logic. These rules are called Restrictions.
Some examples:
- 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.
Some great information about setting up WooCommerce can be found at Configuring WooCommerce Settings. The Shipping Methods archive is particularly useful if you want to learn more about Shipping Zones and Shipping Methods. If you are just starting out with Payment Gateways, Core Payment Options lists all Payment Gateways included in WooCommerce out-of-the-box. Finally, have a look at Payment Gateway Extensions — a handy guide that will help you pick the one(s) you need.
Getting Started
The extension lets you create two types of Restrictions:
- Global Restrictions
- Product-level Restrictions
Global Restrictions
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 OptimizeForm > Restrictions:
There are 3 sections dedicated to managing restrictions for:
- Shipping Countries & States,
- Payment Gateways and
- Shipping Methods.
Here’s a Payment Gateway restriction example:
This global restriction disables the Direct Bank Transfer option if an order has a total value lower than $1000.
Note that you can add multiple rules, even for the same restriction type. For example, you can create multiple restrictions to exclude the same Payment Gateway, with different conditions each time.
Product-level Restrictions
Product-level Restrictions are exclusion rules associated with specific products. They are evaluated for each product found in the cart during checkout and can be created from the Product Data > Restrictions tab.
The following example shows you how to associate a Shipping Countries & States restriction with a Rechargeable Lithium Battery product. The Restriction prevents customers from choosing the United States as a shipping destination for this product, unless the order total is higher than $100.
You can create 3 types of product-level restrictions for:
- Payment Gateways
- Shipping Methods
- Shipping Countries & States
As with global restrictions, you can create multiple rules for the same restriction type.
Conditions
Every restriction can be accompanied by some conditions, which determine whether the restriction will be activated. A restriction is activated only if all defined conditions match at the same time.
To understand this better, here’s an example:
This restriction excludes all available shipping methods if:
- an order contains products from the Batteries category,
- the order is shipped to the United States,
- the order total is under $100.
The restriction works only when all 3 conditions match. Otherwise, all shipping methods are available at checkout, as usual.
Restrictions Reference
Payment Gateways
Payment Gateway restrictions allow you to conditionally disable/exclude payment gateways.
Global Restrictions
To create a global Payment Gateway restriction:
- Navigate to OptimizeForm> Restrictions > Payment Gateways.
- Click the Add Restriction button.
- Configure options.
Payment Gateway restrictions include the following options:
- Short Description — Identifies this rule. As you add more rules, short descriptions will make it easier for you to manage them effectively.
- Exclude Gateways — The Payment Gateways disabled by this new rule.
- Show Excluded — When enabled, excluded Payment Gateways are visible at checkout. Select this option if you prefer to have a notice displayed when customers attempt to place an order using an excluded Payment Gateway.
- Custom Notice — Custom notice displayed to customers when attempt to place an order using an excluded Payment Gateway. Overrides the default notice.
- Show Static Notices — By default, when Show Excluded is enabled, a notice is displayed when customers attempt to place an order using a restricted Payment Gateway. Select this option if you also want to display a static notice under each restricted Payment Gateway.
Use Conditions to introduce conditional logic into the restrictions you create. The following table provides a summary of all Conditions available in global Payment Gateway restrictions:
CONDITION | MODIFIER | DESCRIPTION |
---|---|---|
Backorder | in cart | Satisfied if the cart contains at least one product on backorder. |
not in cart | Satisfied if the cart does not contain any product on backorder. | |
all cart items | Satisfied if the cart contains only products on backorder. | |
not all cart items | Satisfied if the cart contains at least one product that is not on backorder. | |
Billing Country | is | Satisfied if one of the listed billing countries is selected at checkout. |
is not | Satisfied if none of the listed billing countries is selected at checkout. | |
Category | in cart | Satisfied if the cart contains at least one product from a listed category. |
not in cart | Satisfied if the cart does not contain any product from a listed category. | |
all cart items | Satisfied if the cart contains only products from the listed categories. | |
not all cart items | Satisfied if the cart contains at least one product that does not belong in any of the listed categories. | |
Coupon Code | used | Satisfied if a listed coupon is applied in the cart. |
not used | Satisfied if none of the listed coupons is applied in the cart. | |
Customer | e-mail is | Satisfied if the list of e-mails includes the current customer’s e-mail. |
e-mail is not | Satisfied if the list of e-mails does not include the current customer’s e-mail. | |
Customer Role | is | Satisfied if the listed roles include the current customer’s role. |
is not | Satisfied if the listed roles do not include the current customer’s role. | |
Order Total | < | Satisfied if the checkout order total is lower (<) than this value. |
>= | Satisfied if the checkout order total is greater (>=) than this value. | |
Package Item Count | < | Satisfied if the quantity of items in a package is lower (<) than this value. |
>= | Satisfied if the quantity of items in a package is greater (>=) than this value. | |
Shipping Class | in cart | Satisfied if the cart contains at least one product from a listed shipping class. |
not in cart | Satisfied if the cart does not contain any product from a listed shipping class. | |
all cart items | Satisfied if the cart contains only products from the listed shipping classes. | |
not all cart items | Satisfied if the cart contains at least one product that does not belong in any of the listed shipping classes. | |
Shipping Country | is | Satisfied if the listed shipping countries include the shipping country selected at checkout. If any States/Regions are specified, the condition will match only if a listed State/Region is selected at checkout, as well. |
is not | Satisfied if the listed shipping countries do not include the shipping country selected at checkout. If one of the listed shipping countries is selected at checkout and States/Regions are specified, the condition will match only if a non-listed State/Region is selected. | |
Shipping Method | is | Satisfied if one of the listed shipping methods is selected at checkout. |
is not | Satisfied if none of the listed shipping methods is selected at checkout. | |
Shipping Postcode | is | Satisfied if the shipping postcode entered at checkout is equal to the specified value, or included in the specified range. |
is not | Satisfied if the shipping postcode entered at checkout is not equal to the specified value, or not included in the specified range. | |
Membership Plan 1 | active exists | Satisfied if the current customer is a member of one of the listed Membership Plans. |
all inactive | Satisfied if the current customer is not a member of any of the listed Membership Plans. | |
inactive exists | Satisfied if the current customer is not a member of at least one of the listed Membership Plans. | |
all active | Satisfied if the current customer is a member of all listed Membership Plans. | |
Product on Subscription 2 | in cart | Satisfied if the cart contains at least one subscription product with the specified billing period. |
not in cart | Satisfied if the cart does not contain any subscription product with the specified billing period. | |
all in cart | Satisfied if the cart contains only subscription products with the specified billing period. | |
not all in cart | Satisfied if the cart contains at least one non-subscription product, or a subscription product with a billing period other than the specified one. | |
Currency 3 | is | Satisfied if one of the listed currencies is currently active. |
is not | Satisfied if none of the listed currencies is currently active. |
1 Available if WooCommerce Memberships is installed and activated.
2 Available if WooCommerce Subscriptions is installed and activated.
3 Available if WooCommerce Multi-Currency is installed and activated.
Product-level Restrictions
Product-level Payment Gateway restrictions are useful if you want to exclude one or more Payment Gateways when a specific product is in the cart. To add a new product-level Payment Gateway restriction:
- Navigate to Product Data > Restrictions.
- Choose the Payment Gateways restriction type.
- Click the Add Restriction button.
- Configure options.
Product-level restrictions include the same options as the ones found in global restrictions of the same type. However, the available Conditions are slightly different:
- Some conditions are unavailable, since product-level rules are linked to a specific product.
- There is a new Product Quantity condition.
CONDITION | MODIFIER | DESCRIPTION |
---|---|---|
Product Quantity | < | Satisfied if the cart item quantity of the product is lower (<) than this value. |
>= | Satisfied if the cart item quantity of the product is higher (>=) than this value. |
Shipping Methods
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+.
Global Restrictions
To create a global Shipping Method restriction:
- Navigate to OptimizeForm> Restrictions > Shipping Methods.
- Click the Add Restriction button.
- Configure options.
Shipping Method restrictions include the following options:
- Short Description — Identifies this rule. As you add more rules, short descriptions will make it easier for you to manage them effectively.
- Exclude Methods — The Shipping Methods disabled by this new rule.
- Exclude Rate IDs — advanced option for excluding Shipping Method options generated by external APIs.
- Show Excluded — When enabled, excluded Shipping Methods are visible at checkout. Select this option if you prefer to have a notice displayed when customers choose an excluded Shipping Method.
- Custom Notice — Custom notice displayed to customers when choosing an excluded Shipping Method. Overrides the default notice.
- Show Static Notices — By default, when Show Excluded is enabled, a notice is displayed when customers attempt to place an order using a restricted Shipping Method. Select this option if you also want to display a static notice under each restricted Shipping Method.
Use Conditions to introduce conditional logic into the restrictions you create. The following table provides a summary of all Conditions available in global Shipping Method restrictions:
CONDITION | MODIFIER | DESCRIPTION |
---|---|---|
Backorder | in package | Satisfied if the package contains at least one product on backorder. |
not in package | Satisfied if the package does not contain any product on backorder. | |
all package items | Satisfied if the package contains only products on backorder. | |
not all package items | Satisfied if the package contains at least one product that is not on backorder. | |
Billing Country | is | Satisfied if one of the listed billing countries is selected at checkout. |
is not | Satisfied if none of the listed billing countries is selected at checkout. | |
Cart Total | < | Satisfied if the cart total (after discounts, including taxes) is lower (<) than this value. |
>= | Satisfied if the cart total (after discounts, including taxes) is greater (>=) than this value. | |
Category | in package | Satisfied if the package contains at least one product from a listed category. |
not in package | Satisfied if the package does not contain any product from a listed category. | |
all package items | Satisfied if the package contains only products from the listed categories. | |
not all package items | Satisfied if the package contains at least one product that does not belong in any of the listed categories. | |
Coupon Code | used | Satisfied if a listed coupon is applied in the cart. |
not used | Satisfied if none of the listed coupons is applied in the cart. | |
Customer | e-mail is | Satisfied if the list of e-mails includes the current customer’s e-mail. |
e-mail is not | Satisfied if the list of e-mails does not include the current customer’s e-mail. | |
Customer Role | is | Satisfied if the listed roles include the current customer’s role. |
is not | Satisfied if the listed roles do not include the current customer’s role. | |
Package Item Count | < | Satisfied if the quantity of items in the package is lower (<) than this value. |
>= | Satisfied if the quantity of items in the package is greater (>=) than this value. | |
Package Total | < | Satisfied if the package total is lower (<) than this value. |
>= | Satisfied if the package total is greater (>=) than this value. | |
Package Weight | < | Satisfied if the total package weight is lower (<) than this value. |
>= | Satisfied if the total package weight is greater (>=) than this value. | |
Shipping Class | in package | Satisfied if the package contains at least one product from a listed shipping class. |
not in package | Satisfied if the package does not contain any product from a listed shipping class. | |
all package items | Satisfied if the package contains only products from the listed shipping classes. | |
not all package items | Satisfied if the package contains at least one product that does not belong in any of the listed shipping classes. | |
Shipping Country | is | Satisfied if the listed shipping countries include the shipping country selected at checkout. If any States/Regions are specified, the condition will match only if a listed State/Region is selected at checkout, as well. |
is not | Satisfied if the listed shipping countries do not include the shipping country selected at checkout. If one of the listed shipping countries is selected at checkout and States/Regions are specified, the condition will match only if a non-listed State/Region is selected. | |
Shipping Postcode | is | Satisfied if the shipping postcode of the package is equal to the specified value, or included in the specified range. |
is not | Satisfied if the shipping postcode of the package is not equal to the specified value, or not included in the specified range. | |
Membership Plan 1 | active exists | Satisfied if the current customer is a member of one of the listed Membership Plans. |
all inactive | Satisfied if the current customer is not a member of any of the listed Membership Plans. | |
inactive exists | Satisfied if the current customer is not a member of at least one of the listed Membership Plans. | |
all active | Satisfied if the current customer is a member of all listed Membership Plans. | |
Product on Subscription 2 | in package | Satisfied if the package contains at least one subscription product with the specified billing period. |
not in package | Satisfied if the package does not contain any subscription product with the specified billing period. | |
all in package | Satisfied if the package contains only subscription products with the specified billing period. | |
not all in package | Satisfied if the package contains at least one non-subscription product, or a subscription product with a billing period other than the specified one. | |
Recurring Package 2 | is | Satisfied if the package being evaluated is the recurring package of an initial subscription purchase, or a subscription renewal, with the specified billing schedule. |
is not | Satisfied if the package being evaluated is for an initial subscription order. Also satisfied for recurring packages and subscription renewals with a billing period other than the specified one. | |
all in package | Satisfied if the package contains only subscription products. | |
not all in package | Satisfied if the package contains at least one non-subscription product. | |
Currency 3 | is | Satisfied if one of the listed currencies is currently active. |
is not | Satisfied if none of the listed currencies is currently active. |
1 Available if WooCommerce Memberships is installed and activated.
2 Available if WooCommerce Subscriptions is installed and activated.
3 Available if WooCommerce Multi-Currency is installed and activated.
Product-level Restrictions
Product-level Shipping Method restrictions are useful if you want to exclude one or more Shipping Methods when a specific product is in the cart. To add a new product-level Shipping Method restriction:
- Navigate to Product Data > Restrictions.
- Choose the Shipping Methods restriction type.
- Click the Add Restriction button.
- Configure options.
Product-level restrictions include the same options as the ones found in global restrictions of the same type. However, the available Conditions are slightly different:
- Some conditions are unavailable, since product-level rules are linked to a specific product.
- There is a new Product Quantity condition.
CONDITION | MODIFIER | DESCRIPTION |
---|---|---|
Product Quantity | < | Satisfied if the cart item quantity of the product is lower (<) than this value. |
>= | Satisfied if the cart item quantity of the product is higher (>=) than this value. |
Shipping Countries & States
Shipping Country/State restrictions allow you to conditionally prevent customers from checking out when specific shipping countries or states are selected.
Global Restrictions
To create a global restriction:
- Navigate to WooCommerce > Settings > Restrictions > Shipping Countries & States.
- Click the Add Restriction button.
- Configure options.
Shipping Country/State restrictions include the following options:
- Short Description — Identifies this rule. As you add more rules, short descriptions will make it easier for you to manage them effectively.
- Exclude Countries — The Shipping Countries excluded by this rule.
- Exclude States/Regions — The Shipping States/Regions excluded by this rule.
- Custom Notice — Custom notice displayed to customers when choosing an excluded Shipping Country/State. Overrides the default notice.
Use Conditions to introduce conditional logic into the restrictions you create. The following table provides a summary of all Conditions available in global Shipping Method restrictions:
CONDITION | MODIFIER | DESCRIPTION |
---|---|---|
Backorder | in package | Satisfied if a package contains at least one product on backorder. |
not in package | Satisfied if a package does not contain any product on backorder. | |
all package items | Satisfied if a package contains only products on backorder. | |
not all package items | Satisfied if a package contains at least one product that is not on backorder. | |
Cart Total | < | Satisfied if the cart total (after discounts, including taxes) is lower (<) than this value. |
>= | Satisfied if the cart total (after discounts, including taxes) is greater (>=) than this value. | |
Category | in package | Satisfied if a package contains at least one product from a listed category. |
not in package | Satisfied if a package does not contain any product from a listed category. | |
all package items | Satisfied if a package contains only products from the listed categories. | |
not all package items | Satisfied if a package contains at least one product that does not belong in any of the listed categories. | |
Customer | e-mail is | Satisfied if the list of e-mails includes the current customer’s e-mail. |
e-mail is not | Satisfied if the list of e-mails does not include the current customer’s e-mail. | |
Customer Role | is | Satisfied if the listed roles include the current customer’s role. |
is not | Satisfied if the listed roles do not include the current customer’s role. | |
Package Item Count | < | Satisfied if the quantity of items in a package is lower (<) than this value. |
>= | Satisfied if the quantity of items in a package is greater (>=) than this value. | |
Package Total | < | Satisfied if a package total is lower (<) than this value. |
>= | Satisfied if a package total is greater (>=) than this value. | |
Shipping Class | in package | Satisfied if a package contains at least one product from the shipping classes included here. |
not in package | Satisfied if a package contains does not contain any product from the shipping classes included here. | |
all package items | Satisfied if a package contains only products from the shipping classes included here. | |
not all package items | Satisfied if a package contains at least one product not from the shipping classes included here. | |
Membership Plan 1 | active exists | Satisfied if the current customer is a member of one of the listed Membership Plans. |
all inactive | Satisfied if the current customer is not a member of any of the listed Membership Plans. | |
inactive exists | Satisfied if the current customer is not a member of at least one of the listed Membership Plans. | |
all active | Satisfied if the current customer is a member of all listed Membership Plans. | |
Product on Subscription 2 | in package | Satisfied if the package contains at least one subscription product with the specified billing period. |
not in package | Satisfied if the package does not contain any subscription product with the specified billing period. | |
all in package | Satisfied if the package contains only subscription products with the specified billing period. | |
not all in package | Satisfied if the package contains at least one non-subscription product, or a subscription product with a billing period other than the specified one. | |
Currency 3 | is | Satisfied if one of the listed currencies is currently active. |
is not | Satisfied if none of the listed currencies is currently active. |
1 Available if WooCommerce Memberships is installed and activated.
2 Available if WooCommerce Subscriptions is installed and activated.
3 Available if WooCommerce Multi-Currency is installed and activated.
Product-level Restrictions
Product-level Shipping Country/State restrictions are useful if you want to exclude one or more Shipping Countries/States when a specific product is in the cart. To add a new product-level restriction:
- Navigate to Product Data > Restrictions.
- Choose the Shipping Countries & States restriction type.
- Click the Add Restriction button.
- Configure options.
Product-level restrictions include the same options as the ones found in global restrictions of the same type. However, the available Conditions are slightly different:
- Some conditions are unavailable, since product-level rules are linked to a specific product.
- There is a new Product Quantity condition.
CONDITION | MODIFIER | DESCRIPTION |
---|---|---|
Product Quantity | < | In effect if the cart item quantity of the product involved is lower (<) than this value. |
>= | In effect if the cart item quantity of the product involved is higher (>=) than this value. |
Examples
1. Conditional Flat Rates
The extension can be used to conditionally disable entire shipping methods, or exclude method instances attached to specific Shipping Zones.
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).
2 Shipping Zones have been created:
ZONE NAME | DESTINATIONS |
---|---|
Zone A | Continental US States only. |
Zone B | Canada, Mexico and non-continental US States. |
The objective is to offer 2 shipping rate options per Zone, depending on order weight:
RATE NAMEZONEWEIGHTRATE
Zone A StandardZone ALess 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 |
Follow the WooCommerce Shipping Zones documentation to:
- Create the 2 Zones.
- Add 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.
- Create the necessary Shipping Method restrictions by navigating to Settings > Restrictions > Shipping Methods.
Here’s an overview of the required restrictions, 3 in total:
Rule #1 – Exclude Zone A Standard and Zone B Standard rates if weight >= 2kg:
Rule #2 – Exclude Zone A Heavy and Zone B Heavy rates if weight < 2kg:
Rule #3 – 5kg weight limit:
Example 2. Shipping Terms of Service Compliance
Most courier companies require you to comply to their Terms of Service for shipping various types of products, e.g. products labelled as “dangerous goods”. Depending on the shipping destination, shipping method and package contents, a courier company may refuse to ship an order, or may have specific pricing, packaging, handling or forwarding requirements.
In the following example, a restriction excludes some shipping methods if a shipping package contains products from the Batteries category:
Example 3. Customs Import Regulations
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 very effective here as they handle both requirements gracefully.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 Terms of Service Compliance
Depending on what you are selling and how, compliance with Payment Gateway terms and conditions may require some effort on your part. For instance, some payment service providers may:
- refuse to process payments for specific types of products, or
- require merchants to present some proof-of-shipment in order to resolve disputes that may arise between buyers/sellers, such as a shipment tracking IDs.
The extension allows you to define Payment Gateway restrictions based on various conditions, including the chosen Shipping Method(s). In the following example, a Payment Gateway restriction is created to exclude PayPal when selecting an Unregistered Postal Delivery shipping method:
FAQ
How can I exclude specific shipping rates supplied by major courier APIs? For example, ‘FedEx Ground’ only?
To calculate shipping rates, some Shipping Methods may connect WooCommerce to an external API that fetches shipping costs based on the dimensions and weights of all items contained in a customer’s cart. The returned rates often include options for different services, such as Ground/Air, or Standard/Express. Often these rates are not known to WooCommerce in advance, and you may find that Conditional Shipping and Payments does not make them individually available for exclusion.
As a workaround, the extension allows you to exclude Shipping Rates by ID. However, you will need to do some extra work to find the IDs associated with the shipping options you want to exclude. To find the rate ID associated with a shipping method option:
- Activate your browser’s Developer Tools/Console. If you are using Firefox, press
Ctrl+Shift+K
(orCmd+Option+K
on OS X) to toggle the console. - Right-click on the shipping option you want to exclude, and choose Inspect Element.
- Copy the value seen in the following screenshot. In most cases, it should be something like
fedex:FEDEX_GROUND
- Paste it into the Excluded Rate IDs field.