add_action( 'woocommerce_before_cart', 'snipjar_apply_coupon_cart_weight' );
function snipjar_apply_coupon_cart_weight() {
$coupon_code = 'snipdeal';
// if cart content weight is more than 15kg
if( 15 < WC()->cart->get_cart_contents_weight() ) {
if( ! WC()->cart->has_discount( $coupon_code ) ) {
WC()->cart->apply_coupon( $coupon_code );
}
} else {
WC()->cart->remove_coupon( $coupon_code );
WC()->cart->calculate_totals();
}
}