Shipping Classes: Pet Food, Toys, Accessories
Base Shipping Fee: $6.95 per order
Weight & Volume Integration:
– If the items belong to the Pet Food shipping class, add $4 per 1 kg.
– If the items belong to the Accessories shipping class, add $2 per 1 item.
– If the items belong to the Toys shipping class, add $1 per 1 item.
Additional Conditions:
– Bundle Discount: If the order includes 5 or more items (from any shipping class), subtract $5 from the total shipping fee.
– Insurance: Automatically apply a 5% insurance fee for orders valued over $100.
– Special Handling: Each product that has a perishable tag adds a $2 handling fee; each product that has a fragile product tag adds an additional $2 packaging fee.
– Free Shipping Conditions: Orders valued at $300 or more qualify for free standard shipping.
The store owner charges a base shipping fee of $6.95 for every order. Then, depending on the shipping class of the items, we add extra charges:
If the order has 5 or more items in total, a $5 discount (negative cost) is applied to encourage bigger purchases.
In addition, each product marked with the perishable tag adds $2 per item, and each product marked with the fragile tag also adds $2 per item.
If the order value exceeds $100, a 5% insurance fee (based on the order value) is charged.
Finally, if the total order value reaches $300 or more, shipping is free, overriding all other shipping charges (in this configuration, that also means we do not apply other shipping fees).
Below, you will find edge cases:
The configuration starts by checking if the order value is $300 or more. If it is, we set shipping cost to $0 and stop further rule processing (so shipping remains free). If that initial free-shipping rule does not apply, we then proceed with:
If all of these rules are processed, they are added up cumulatively to form the final shipping cost. However, if any single rule includes a “special_action”: “stop,” no subsequent rules are evaluated for the shipping cost.
Below is a JSON configuration that follows the provided schema and applies the described shipping scenario. Please note it must strictly adhere to the rules-table-schema.json
, and we must implement each condition as a separate rule. Each rule either adds or subtracts from the shipping cost depending on whether the condition is met. You can import this directly into the plugin.
{
"rules_table": {
"rules": [
{
"conditions": [
{
"condition_id": "value",
"operator": "is",
"min": "300",
"max": ""
}
],
"cost_per_order": "0",
"additional_costs": [],
"special_action": "stop"
},
{
"conditions": [
{
"condition_id": "none"
}
],
"cost_per_order": "6.95",
"additional_costs": [],
"special_action": "none"
},
{
"conditions": [
{
"condition_id": "shipping_class",
"operator": "any",
"shipping_class": [
"Pet Food"
]
}
],
"cost_per_order": "0",
"additional_costs": [
{
"additional_cost": "4",
"per_value": "1",
"based_on": "weight"
}
],
"special_action": "none"
},
{
"conditions": [
{
"condition_id": "shipping_class",
"operator": "any",
"shipping_class": [
"Accessories"
]
}
],
"cost_per_order": "0",
"additional_costs": [
{
"additional_cost": "2",
"per_value": "1",
"based_on": "item"
}
],
"special_action": "none"
},
{
"conditions": [
{
"condition_id": "shipping_class",
"operator": "any",
"shipping_class": [
"Toys"
]
}
],
"cost_per_order": "0",
"additional_costs": [
{
"additional_cost": "1",
"per_value": "1",
"based_on": "item"
}
],
"special_action": "none"
},
{
"conditions": [
{
"condition_id": "item",
"operator": "is",
"min": "5",
"max": ""
}
],
"cost_per_order": "-5",
"additional_costs": [],
"special_action": "none"
},
{
"conditions": [
{
"condition_id": "product_tag",
"operator": "any",
"product_tag": [
"perishable"
]
}
],
"cost_per_order": "0",
"additional_costs": [
{
"additional_cost": "2",
"per_value": "1",
"based_on": "item"
}
],
"special_action": "none"
},
{
"conditions": [
{
"condition_id": "product_tag",
"operator": "any",
"product_tag": [
"fragile"
]
}
],
"cost_per_order": "0",
"additional_costs": [
{
"additional_cost": "2",
"per_value": "1",
"based_on": "item"
}
],
"special_action": "none"
},
{
"conditions": [
{
"condition_id": "value",
"operator": "is",
"min": "100.01",
"max": ""
}
],
"cost_per_order": "0",
"additional_costs": [
{
"additional_cost": "0.05",
"per_value": "1",
"based_on": "value"
}
],
"special_action": "none"
}
]
}
}
To use this configuration, copy the above JSON and paste it into the Flexible Shipping PRO plugin’s rule table (click the “Paste” button within the plugin interface).
Let’s analyze how some example orders behave with the final rules:
cost_per_order = 0
and special_action = stop
. We stop processing further rules. The final shipping cost is $0, fulfilling “free shipping.”
When shipping pet-related products, store owners often face a few common challenges:
All these considerations must be weighed when implementing a shipping cost table. The above configuration, though complex, demonstrates how to handle multiple real-world conditions in a single, cumulative system.