diff --git a/classes/class-wc-cart.php b/classes/class-wc-cart.php index 8549e0bca5e..196dee3d429 100644 --- a/classes/class-wc-cart.php +++ b/classes/class-wc-cart.php @@ -954,6 +954,7 @@ class WC_Cart { $this_item_is_discounted = false; $product_cats = wp_get_post_terms( $values['product_id'], 'product_cat', array("fields" => "ids") ); + $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); // Specific products get the discount if ( sizeof( $coupon->product_ids ) > 0 ) { @@ -985,9 +986,8 @@ class WC_Cart { $this_item_is_discounted = false; // Sale Items excluded from discount - if ( $coupon->exclude_sale_items() && sizeof( woocommerce_get_product_ids_on_sale() ) > 0 ) - $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); - if ( in_array( $values['product_id'], $product_ids_on_sale ) || in_array( $values['variation_id'], $product_ids_on_sale ) || in_array( $values['data']->get_parent(), $product_ids_on_sale ) ) + if ( $coupon->exclude_sale_items == 'yes' ) + if ( in_array( $values['product_id'], $product_ids_on_sale, true ) || in_array( $values['variation_id'], $product_ids_on_sale, true ) || in_array( $values['data']->get_parent(), $product_ids_on_sale, true ) ) $this_item_is_discounted = false; // Apply filter @@ -1106,7 +1106,7 @@ class WC_Cart { * @param mixed $price */ public function apply_product_discounts_after_tax( $values, $price ) { - + if ( ! empty( $this->applied_coupons) ) { foreach ( $this->applied_coupons as $code ) { $coupon = new WC_Coupon( $code ); @@ -1120,6 +1120,7 @@ class WC_Cart { if ( ! $coupon->apply_before_tax() ) { $product_cats = wp_get_post_terms( $values['product_id'], 'product_cat', array("fields" => "ids") ); + $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $this_item_is_discounted = false; @@ -1153,9 +1154,8 @@ class WC_Cart { $this_item_is_discounted = false; // Sale Items excluded from discount - if ( $coupon->exclude_sale_items() && sizeof( woocommerce_get_product_ids_on_sale() ) > 0 ) - $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); - if ( in_array( $values['product_id'], $product_ids_on_sale ) || in_array( $values['variation_id'], $product_ids_on_sale ) || in_array( $values['data']->get_parent(), $product_ids_on_sale ) ) + if ( $coupon->exclude_sale_items == 'yes' ) + if ( in_array( $values['product_id'], $product_ids_on_sale, true ) || in_array( $values['variation_id'], $product_ids_on_sale, true ) || in_array( $values['data']->get_parent(), $product_ids_on_sale, true ) ) $this_item_is_discounted = false; // Apply filter diff --git a/classes/class-wc-coupon.php b/classes/class-wc-coupon.php index 0d599d9ff2e..42b4ec736a6 100644 --- a/classes/class-wc-coupon.php +++ b/classes/class-wc-coupon.php @@ -317,12 +317,12 @@ class WC_Coupon { } // Exclude Sale Items - if ( exclude_sale_items() && sizeof( $woocommerce_get_product_ids_on_sale) > 0 ) { + if ( $this->exclude_sale_items == 'yes' ) { $valid_for_cart = true; $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) { foreach( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) { - if ( in_array( $cart_item['product_id'], $product_ids_on_sale ) || in_array( $cart_item['variation_id'], $product_ids_on_sale ) || in_array( $cart_item['data']->get_parent(), $product_ids_on_sale ) ) { + if ( in_array( $cart_item['product_id'], $product_ids_on_sale, true ) || in_array( $cart_item['variation_id'], $product_ids_on_sale, true ) || in_array( $cart_item['data']->get_parent(), $product_ids_on_sale, true ) ) { $valid_for_cart = false; } } diff --git a/templates/cart/totals.php b/templates/cart/totals.php index 47e003f4aef..6d04619a5f7 100644 --- a/templates/cart/totals.php +++ b/templates/cart/totals.php @@ -192,4 +192,11 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods(); +
+ +
+ \ No newline at end of file