Prompt
How do I apply shipping rules like free shipping thresholds and carrier fallback?
Latest observation
Nov 4, 2026
OpenAI APIWeb search: off
To apply shipping rules such as free shipping thresholds and carrier fallback, you typically want to set them up in your shipping logic in this order:
1) Define the shipping rule conditions
Common rule inputs:
- Cart subtotal
- Destination (country/state/postal code)
- Weight / dimensions
- Product tags / categories
- Customer group / membership
- Carrier availability (API response, serviceable zones)
2) Free shipping threshold
A common rule is:
- If
cart subtotal >= threshold, then shipping cost =0 - Otherwise, use normal rates
Example logic:
if cart.subtotal >= 50:
shipping_method = "Free Shipping"
shipping_cost = 0
else:
shipping_method = "Standard Shipping"
shipping_cost = calculate_standard_rate(cart)
You can also make it conditional by zone:
- Free shipping only in domestic regions
- Exclude hazardous or oversized items
- Require pre-tax subtotal vs post-tax subtotal
3) Carrier fallback
Carrier fallback means if your preferred carrier/rate source fails, you switch to a backup option.
Example priority:
- Live carrier rate from Carrier A
- Live carrier rate from Carrier B
- Flat rate
- Local pickup
- Free shipping if eligible
Example logic:
rate = get_rate_from_carrier_a(order)
if rate unavailable:
rate = get_rate_from_carrier_b(order)
if rate unavailable:
rate = flat_rate
4) Combine both rules
A typical combined flow:
if cart.subtotal >= free_shipping_threshold:
return free_shipping
else:
rate = get_live_rate(primary_carrier)
if rate unavailable:
rate = get_live_rate(backup_carrier)
if rate unavailable:
rate = default_flat_rate
return rate
5) Best practices
- Make rule priority explicit
- Log carrier failures for debugging
- Cache live rates briefly to reduce API calls
- Use clear labels like “Free Shipping”, “Standard Shipping”, “Backup Carrier Rate”
- Decide whether threshold uses subtotal before or after discounts/tax
6) If you’re using a platform
If you’re implementing this in:
- Shopify: shipping profiles, rate rules, apps, or carrier service API
- WooCommerce: shipping zones + flat rate/free shipping methods + plugins for carrier fallback
- Magento: shipping rules/rate processors/extensions
- Custom backend: implement the logic in your shipping quote service
If you want, I can also give you:
- a SQL/config-style rule example,
- pseudo-code for a checkout service, or
- platform-specific steps for Shopify/WooCommerce/Magento.