|
@@ 468-478 (lines=11) @@
|
| 465 |
|
$valid_for_cart = false; |
| 466 |
|
$product_ids_on_sale = wc_get_product_ids_on_sale(); |
| 467 |
|
|
| 468 |
|
if ( ! WC()->cart->is_empty() ) { |
| 469 |
|
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { |
| 470 |
|
if ( ! empty( $cart_item['variation_id'] ) ) { |
| 471 |
|
if ( ! in_array( $cart_item['variation_id'], $product_ids_on_sale, true ) ) { |
| 472 |
|
$valid_for_cart = true; |
| 473 |
|
} |
| 474 |
|
} elseif ( ! in_array( $cart_item['product_id'], $product_ids_on_sale, true ) ) { |
| 475 |
|
$valid_for_cart = true; |
| 476 |
|
} |
| 477 |
|
} |
| 478 |
|
} |
| 479 |
|
if ( ! $valid_for_cart ) { |
| 480 |
|
throw new Exception( self::E_WC_COUPON_NOT_VALID_SALE_ITEMS ); |
| 481 |
|
} |
|
@@ 571-581 (lines=11) @@
|
| 568 |
|
if ( $this->exclude_sale_items == 'yes' ) { |
| 569 |
|
$valid_for_cart = true; |
| 570 |
|
$product_ids_on_sale = wc_get_product_ids_on_sale(); |
| 571 |
|
if ( ! WC()->cart->is_empty() ) { |
| 572 |
|
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { |
| 573 |
|
if ( ! empty( $cart_item['variation_id'] ) ) { |
| 574 |
|
if ( in_array( $cart_item['variation_id'], $product_ids_on_sale, true ) ) { |
| 575 |
|
$valid_for_cart = false; |
| 576 |
|
} |
| 577 |
|
} elseif ( in_array( $cart_item['product_id'], $product_ids_on_sale, true ) ) { |
| 578 |
|
$valid_for_cart = false; |
| 579 |
|
} |
| 580 |
|
} |
| 581 |
|
} |
| 582 |
|
if ( ! $valid_for_cart ) { |
| 583 |
|
throw new Exception( self::E_WC_COUPON_NOT_VALID_SALE_ITEMS ); |
| 584 |
|
} |