Created
August 17, 2019 14:26
-
-
Save gaiqus/7da24f16458b4952e68c906e247e3162 to your computer and use it in GitHub Desktop.
Set max weight in WooCommerce orders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('woocommerce_check_cart_items','check_cart_weight'); | |
function check_cart_weight(){ | |
global $woocommerce; | |
$weight = $woocommerce->cart->cart_contents_weight; | |
if( $weight > 20 ){ | |
wc_add_notice( sprintf( __( 'You have %sKg weight and we allow only 20Kg of weight per order.', 'woocommerce' ), $weight ), 'error' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment