Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function was_match_condition_contains_shipping_class( $match, $operator, $value, $package ) {
- // True until proven false
- if ( $operator == '!=' ) :
- $match = true;
- endif;
- foreach ( $package['contents'] as $key => $product ) {
- do_action( 'woocommerce/cart_loop/start', $product );
- $id = ! empty( $product['variation_id'] ) ? $product['variation_id'] : $product['product_id'];
- $product = wc_get_product( $id );
- if ( $operator == '==' ) {
- if ( $product->get_shipping_class() == $value ) {
- do_action( 'woocommerce/cart_loop/end', $product );
- return true;
- }
- }
- elseif ( $operator == '!=' ) {
- if ( $product->get_shipping_class() == $value ) {
- do_action( 'woocommerce/cart_loop/end', $product );
- return false;
- }
- }
- do_action( 'woocommerce/cart_loop/end', $product );
- }
- return $match;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement