Shipping Cost Formular
-
Following Scenario
I have a min order qty of 6 Items for which I set up € 7.50 Flat postage fee. But if they order MORE than 6 Items I need to charge more than 7.50
How to formulate that best?
I tried 7.50 +(1*[qty])
but that adds 7.50 plus 1 EURO to each item even if its only 6, but for 6 Items it should only be 7.50.
-
Hi @manfredk ,
I see you’re looking to set up a shipping strategy in your WooCommerce store, where you charge a flat €7.50 for orders of up to 6 items, and an additional charge for each item beyond that.
For this, WooCommerce’s Built-in Flat Rate Shipping will do the trick, as it allows you to add basic customizations with placeholders like [qty].
The following formula should work for your case.
7.50 + ( [qty] - 6 ) * 1Here’s how it works:
- €7.50 is the base shipping cost for the first 6 items.
- [qty] retrieves the total quantity of items in the cart.
- Subtracting 6 from [qty] gives you the number of items beyond the sixth.
- Multiplying the result by 1 adds €1 for each additional item.
For more detailed steps, feel free to check out this guide: https://woocommerce.com/document/flat-rate-shipping/#advanced-costs
I hope this helps!
Thank you so much. It works.
-
This reply was modified 1 year, 2 months ago by
manfredk.
And in one other scenario
Up to 6 Items Base Shipping 7.50
Any other Order qty i.e 7 or 8 or 9 or more add 7.50.
But 7.50 for each 6 qty i.,e.
For 6 = EUR 7.50
For 7 (up to 12) EUR 15.00 So even if somebody would order 8 or 9 it would still be EUR 15.00
For 13(up to 18) EUR 22.50
and so on
Is this also possible?Hi @manfredk,
You can achieve your desired shipping calculation using the following formula in WooCommerce’s Flat Rate Shipping:
CEIL( [qty] / 6 ) * 7.50This works by dividing the total quantity of items by 6, rounding up to the nearest whole number, and then multiplying by €7.50.
For example:
- 1 to 6 items → €7.50
- 7 to 12 items → €15.00
- 13 to 18 items → €22.50
- And so on…
This ensures that every set of 6 items (or part of it) gets charged €7.50, just as you described. Let me know if you need further adjustments!
Hi Moses
Thank you for your answer. It works to a certain extend but not quite right.
First If I add the Formula it gives me this Error Message:
undefined variable ‘CEIL’
If i leave CEIL off (in other words like this)
( [qty] / 6 ) * 7.50
It kind of works but only for 6 or 12 or 18
Qty in between like for example 7 or 8 The postage is wrong
Any ideas?
The link is
https://www.marmeladen-pfoten.berlin/shopHi @manfredk ,
I understand you’re looking to set up a shipping rate where every set of 6 items costs €7.50—for example,
€7.50 for 1-6 items, €15.00 for 7-12 items,and so on.To achieve this, we recommend using a specialized plugin like Flat Rate Shipping Plugin for WooCommerce. This plugin allows you to create multiple shipping methods and set up unlimited rules for shipping conditions.
Alternatively, you can use the following code snippet to implement this setup:
function custom_quantity_based_shipping( $rates, $package ) {
$quantity = WC()->cart->get_cart_contents_count();
$base_rate = 7.50;
if ( $quantity > 0 ) {
$sets_of_six = ceil( $quantity / 6 );
$shipping_cost = $sets_of_six * $base_rate;
} else {
$shipping_cost = 0;
}
foreach ( $rates as $rate_key => $rate ) {
$rates[ $rate_key ]->cost = $shipping_cost;
}
return $rates;
}
add_filter( 'woocommerce_package_rates', 'custom_quantity_based_shipping', 10, 2 );If you’re comfortable with editing your site’s code, you can add this snippet to your child theme’s
functions.phpfile. Alternatively, for a safer method, you can use a plugin like Code Snippets to apply the code without directly editing your files.
Please note that under our Support Policy, we cannot provide extensive assistance with customizations. For more complex or advanced changes, we recommend reaching out to Codeable or a Certified WooExpert.I hope this helps point you in the right direction!
The topic ‘Shipping Cost Formular’ is closed to new replies.