Created
March 3, 2015 12:50
-
-
Save lucprincen/18bf4f742b789c39e1b8 to your computer and use it in GitHub Desktop.
Woocommerce check weight
This file contains hidden or 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_add_to_cart', 'check_total_weight' ); | |
function check_total_weight( $itemkey, $product_id, $quantity ){ | |
$product = wc_get_product( $product_id ); | |
$weight = $product->get_weight() * $quantity; | |
$cart_weight = WC()->cart->cart_contents_weight; | |
if( $weight + $cart_weight > {TOTAL} ){ | |
wp_redirect( {URL} ); | |
die(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment