Hello @howy,
Thank you for your message.
For now, this feature is not available, but we are really into providing it to our clients because we received much feedback that tells us that it could be a useful feature for admins. So I think it could be released very soon, and of course, I will let you know.
We will be really grateful if you write more about your case, like what exactly do you sell and what you would like to have in this feature. The examples will be great. That information will be really helpful to us because we want to provide a useful feature for you.
Best regards,
Marta
Thread Starter
howy
(@howy)
Hi @martapaw,
Thank you for your support.
My shop sells furnitures and home decorations. These are my current table rates based on weight (kg, VAT not included):
- 0 – 1 —> 6.90
- 1.1 – 3 —> 7.30
- 3.1 – 5 —> 8.40
- 5.1 – 10 —> 11.50
- 10.1 – 20 —> 12.30
- 20+ —> 27.30
Before calculating the weight I have to check the dimensions of the products box to see if they exceed a certain value:
- if the sum of all the dimensions of all the products of the cart exceeds 170cm I have to apply the maximum weight rule (20+ kg)
- if the sum of only one dimension (length or width or height) exceeds 100cm I have to apply the maximum weight rule (20+ kg)
If I have these products in my cart
Product 1 (10l x 80w x 20h – 3kg) x 1
Product 2 (5l x 30w x 10h – 1kg) x 1
The shipment will cost 27.30 because the width has exceeded 100cm
If I have these products in my cart
Product 1 (10l x 80w x 50h – 3kg) x 3
The shipment will cost 27.30 because the sum of all sizes of all products has exceeded 170cm
If I have these products in my cart
Product 1 (5l x 7w x 5h – 1kg) x 1
Product 2 (8l x 30w x 20h – 5kg) x 1
Product 1 (20l x 20w x 20h – 3kg) x 1
The shipment will cost 11.50 because the dimensions do not exceed the limits and the weight rule is applied.
This is the code I’m still testing
function my_woocommerce_package_rates($rates) {
$items = WC()->cart->get_cart();
$length = $width = $height = 0;
foreach ($items as $key => $value) {
$dimentions = $value['data']->get_dimensions(false);
$length = $length + $dimentions['length'] * $value['quantity'];
$width = $width + $dimentions['width'] * $value['quantity'];
$height = $height + $dimentions['height'] * $value['quantity'];
}
if ($length + $width + $height > 170 or $length > 100 or $width > 100 or $height > 100) {
foreach ($rates as $rate) {
$rate->set_cost(27.30);
$rate->set_taxes([7.70]);
}
}
return $rates;
}
add_filter('woocommerce_package_rates', 'my_woocommerce_package_rates', 100);
Hope this helps!
-
This reply was modified 6 years, 1 month ago by
howy.
-
This reply was modified 6 years, 1 month ago by
howy.
-
This reply was modified 6 years, 1 month ago by
howy.
@howy,
Thank you very much!
I’ll talk about your case with the dev team. Maybe, we’ll be able to make this much faster. I’ll let you know.
Best regards,
Marta