Use something like this in your functions:
—-
add_action(‘woocommerce_check_cart_items’,’check_cart_weight’);
function check_cart_weight(){
global $woocommerce;
$weight = $woocommerce->cart->cart_contents_weight;
if( $weight > 30 ){
wc_add_notice( sprintf( __( ‘You have %sKg weight and we allow only 30Kg of weight per order.’, ‘woocommerce’ ), $weight ), ‘error’ );
}
}
Plugin Support
Doug – a11n
(@dougaitken)
Automattic Happiness Engineer
Hi @zarou88,
It looks like exact question was asked on Stack Overflow almost 3 years ago which gives the same solution as @rlinsoliveira
Alternatively you could look at using our Table Rate Shipping extension and setting a max weight.
Thanks
We haven’t heard back from you in a while, so I’m going to mark this as resolved. If you have any further questions, you can start a new thread.
Is there also a code,
for this if you work with grams? But also till a maximum of order till 30 kg?
Because it shows only kilo error, while i have all my products in grams.
Greetings, Marika