Let's assume that we have these variables.
// base shipping cost of product
$product_shipping_cost = 10;
// You can send 4 same products in the same pack with $product_shipping_cost
$product_shipping_interval_quantity = 4;
// Your current quantity in cart
$cart_quantity = 9;
// defined total shipping cost, should be in this case 30;
// because 9 in $cart quantity
$total_shipping_cost = 0;
How should this work in real life? So basically we have this:
How to achieve such a formula? I tried to
$total_shipping_cost = $product_shipping_cost * floor($cart_quantity/$product_shipping_interval_quantity)
But it doesn't work, it changing only when 4/8/12 etc not on 5/9/13 and it is not starting with 10 when ie: 2 pcs in cart.
Use ceil instead of floor:
$total_shipping_cost = $product_shipping_cost *
ceil($cart_quantity/$product_shipping_interval_quantity)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.