Liquid support for shipping formulas
Last updated
Last updated
This feature allows you to make shipping options dynamically available based on conditions, eliminating the need for complex JavaScript on the frontend.
If a shipping formula returns a blank string, that shipping option will not be available. If a shipping option was previously set in the cart but becomes unavailable due to a condition change, it will be automatically removed from the cart, and the cheapest available option will be set instead.
For example, to make a shipping option available only when shipping to the US, use a formula like {% if cart.address.country.name == 'United States' %} 5.0 {% endif %}
.
A demo is available at , where one option is available only for US addresses, another for Canadian addresses, and a third option is always available.
The previous JavaScript used in the checkout/shipping-details
snippet to auto-submit the shipping selector form is no longer needed. The cheapest available shipping option is now automatically selected in the cart. The JS has been removed from the snippets on shopper24 and theprintrefinery.
Package Pricing Not Yet Supported: Currently, you cannot use Liquid in package pricing formulas, and shipping services with package pricing are always available. This feature might be added in the future if needed.