Checkout conditions use the payment method, the shipping method and the shipping address the customer has chosen. Payment method and shipping method conditions are available in cart discounts and checkout fees. The shipping address conditions (Checkout - Address) are also available in product pricing rules since Pricepep 2.6.0, so product prices can depend on the customer's country, state, postcode or shipping zone.
The cart and checkout totals update when the customer changes the payment method, on the classic checkout page and in the Checkout block. Addresses come from what WooCommerce knows about the customer: the checkout form, the shipping calculator, the customer's account, or the default customer location set in WooCommerce.
Where can you use these conditions?
| Condition | Product pricing | Cart discounts | Checkout fees |
|---|---|---|---|
| Payment method | no | Conditions | Conditions |
| Shipping method | no | Conditions | Conditions |
| Shipping country | Conditions (2.6.0) | Conditions | Conditions |
| Shipping state | Conditions (2.6.0) | Conditions | Conditions |
| Shipping postcode | Conditions (2.6.0) | Conditions | Conditions |
| Shipping zone | Conditions (2.6.0) | Conditions | Conditions |
Checkout conditions
Checkout conditions use the payment and shipping method the customer has chosen.
Payment method
The payment method selected at checkout.
- Fields: Payment methods
- Operators: "in list", "not in list"
- Available in: Cart discounts (Conditions); Checkout fees (Conditions)
- Example: Payment method in list "Cash on delivery" for a cash handling fee.
- Totals update when the customer changes the payment method, on the classic checkout page and in the Checkout block.
- In the cart (before checkout) the method is the one WooCommerce remembers for the session, if any.
Shipping method
The shipping methods chosen for the cart's shipping packages.
- Fields: Shipping methods
- Operators: "in list", "not in list"
- Available in: Cart discounts (Conditions); Checkout fees (Conditions)
- Example: Shipping method in list "Local pickup - All zones" for a pickup discount.
- Each method is listed once as "Flat rate - All zones" (the method in every zone) and once per zone as the method's own title in that zone (a renamed method shows its new name) and the zone name, for example "Flat rate - Europe" (only that zone; "Other locations" is the zone for addresses outside your zones).
- When the Checkout block is your checkout, WooCommerce's block pickup is listed as a second "Local pickup - All zones": for a pickup discount, select both.
- Table Rate Shipping: the per-zone entries of WooCommerce's Table Rate Shipping extension don't match its rates. Select its "All zones" entry instead, and add a Shipping zone condition to limit the rule to one zone.
- When the cart is split into several shipping packages, every package counts: "in list" matches when at least one package uses a selected method, "not in list" when none does. Developers can check the first package only, as in earlier versions, by returning false from the
rightpress_condition_shipping_method_all_packagesfilter (see RightPress library hooks).
Checkout - Address conditions
Checkout - Address conditions use the shipping address WooCommerce has for the customer: the address entered in the cart or checkout, a logged-in customer's saved address, or, for new visitors, WooCommerce's Default customer location (WooCommerce > Settings > General).
In product pricing rules (since 2.6.0):
- Where the prices show: in the cart and the checkout always, and in the volume pricing table (Bulk and Tiered pricing rules) whenever it's on. On shop and product pages and in the Store API (block themes, headless shops) only with Change display prices in shop set to a Change option, and with Change - Include simple adjustments only for Simple adjustment rules. See prices shown vs charged.
- New visitors: to show them prices by country, set Default customer location to Geolocate, or to Geolocate (with page caching support) on stores with page caching. With the shop's country as the default location, new visitors get that country's prices until they enter an address. With No location by default they have no address until they enter one: Shipping country, Shipping state and Shipping postcode conditions with in list or matches fail and those with not in list or does not match pass, and Shipping zone sees the zone Locations not covered by your other zones.
- Address changes: when the customer changes the address in the checkout (classic or block), prices update in the same step.
- Without a visitor (WP-Cron tasks, such as product feeds built in the background) there is no address: in list and matches conditions fail, and not in list and does not match conditions pass. So "Shipping country not in list United States" applies there, and a feed that includes Pricepep's prices shows that price.
- WP-CLI and admin-ajax.php: WP-CLI commands run like a storefront visit: with
--user(whichwp wccommands need) as that user, with their role and their address (from their WooCommerce session or account, otherwise the default customer location); without it as a new visitor at the store's default customer location. WP-Cron events run withwp cron event runcount as WP-Cron tasks: no address, as above. Background tasks that run through admin-ajax.php, such as Action Scheduler's async runner, run as the user whose page view started them, usually an administrator. - Feeds: Google Merchant Center wants the feed price to match the product page. Write country rules with in list, use a separate feed per country, or leave such rules out while a feed is built (developers: the
rp_wcdpd_use_rulefilter in the filter reference). - Speed: while any active product pricing rule has an address condition, Pricepep doesn't use its shop price cache at all: every product's shop price is calculated on each page view, for every visitor. On large catalogs, keep such rules few. See slow site with many rules.
- Page caching: a full-page cache shows the prices of the visitor who filled it to everyone else. Use Geolocate (with page caching support), or keep shop and product pages out of the page cache. That option separates cached pages by the billing address, while these conditions read the shipping address: if many of your orders ship to another address, keep shop and product pages out of the page cache. See caching.
Shipping country
The shipping country of the customer.
- Fields: Countries
- Operators: "in list", "not in list"
- Available in: Product pricing (Conditions, since 2.6.0); Cart discounts (Conditions); Checkout fees (Conditions)
- Example: Shipping country in list "Canada" for a cross-border fee, or for lower Canadian shop prices in a product pricing rule.
- Uses the shipping address WooCommerce has (checkout, shipping calculator, account or the store's default customer location).
Shipping state
The shipping state or province.
- Fields: States
- Operators: "in list", "not in list"
- Available in: Product pricing (Conditions, since 2.6.0); Cart discounts (Conditions); Checkout fees (Conditions)
- Example: Shipping state in list "California".
Shipping postcode
The shipping postcode against your list of postcodes and patterns.
- Fields: Postcodes, separated by commas
- Operators: "matches", "does not match"
- Available in: Product pricing (Conditions, since 2.6.0); Cart discounts (Conditions); Checkout fees (Conditions)
- Example: Shipping postcode matches
90210, 902**, 90200-90299. - Separate entries with commas.
*stands for any one character. - Ranges: two numbers, the first smaller, joined by a dash or by
...:90200-90299or90200...90299. Numbers are compared by value whatever their lengths:800-899includes0820, and800-2999is a range too. - Exact postcodes ignore upper/lower case, spaces and dashes, and a two-letter country code in front: "LT-12345", "LT12345" and "12345" are the same.
- Since 2.6.0 an entry of two numbers joined by a dash is an exact postcode, not a range, when the first number isn't the smaller one (
1000-001in Portugal), when it's written like a Polish postcode or a US ZIP+4 code (00-950,90210-1234), or when it's written like the customer's own postcode (604-8005for a Japanese address). For a customer in another country,604-8005is the range 604 to 8005, so for Japanese postcodes add a Shipping country condition or write the postcode without its dash (6048005). - A postcode in two parts also matches a range by its first part when the range's numbers are no longer than that part: a US ZIP+4 code (90210-1234) is in
90200-90299. For an exact code or a wildcard, add the 9-digit form too, for example90210, 90210****.
Shipping zone
The WooCommerce shipping zone of the shipping address.
- Fields: Shipping zones
- Operators: "in list", "not in list"
- Available in: Product pricing (Conditions, since 2.6.0); Cart discounts (Conditions); Checkout fees (Conditions)
- Example: Shipping zone in list "Europe".
What do the operators mean?
| Operator | Matches when |
|---|---|
| in list | Matches when the value is one of the selected items (for values with several items, such as the categories of a product: when at least one of them is selected). |
| not in list | Matches when none of the values is selected, including when there is no value at all (for example a guest for Customer, or a simple product for Product variation). |
| Operator | Matches when |
|---|---|
| matches | The postcode matches one of the patterns. |
| does not match | The postcode matches none of the patterns. |
Related
Frequently asked questions
How do I add a fee for cash on delivery?
Create a checkout fee (for example Fixed fee 2.00) and add the condition Payment method, in list, Cash on delivery.
Do payment method conditions work in the Checkout block?
Yes. The block sends the selected payment method to the store, so discounts and fees update when the customer picks another method.
Does the Shipping method condition work with Table Rate Shipping?
Yes, with the method's All zones entry. To limit the rule to one zone, add a Shipping zone condition; the per-zone entries don't match table rates.
How do I match a range of postcodes?
Use Shipping postcode, matches, and enter for example 90200-90299 or 902**. Separate several entries with commas. A US ZIP+4 code such as 90210-1234 matches the range by its first five digits, but not 902**.