From fb67343611d226e24b6f7158cb38d6117f779005 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 29 Jan 2013 13:58:57 +0000 Subject: [PATCH] Tweak content. Closes #2311 --- admin/post-types/writepanels/writepanel-coupon_data.php | 2 +- classes/class-wc-cart.php | 8 ++++---- classes/class-wc-coupon.php | 6 ++++-- readme.txt | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/admin/post-types/writepanels/writepanel-coupon_data.php b/admin/post-types/writepanels/writepanel-coupon_data.php index 4a96a7e7ec0..2ae4599f87b 100644 --- a/admin/post-types/writepanels/writepanel-coupon_data.php +++ b/admin/post-types/writepanels/writepanel-coupon_data.php @@ -57,7 +57,7 @@ function woocommerce_coupon_data_meta_box( $post ) { woocommerce_wp_checkbox( array( 'id' => 'apply_before_tax', 'label' => __( 'Apply before tax', 'woocommerce' ), 'description' => __( 'Check this box if the coupon should be applied before calculating cart tax.', 'woocommerce' ) ) ); // Exclude Sale Products - woocommerce_wp_checkbox( array( 'id' => 'exclude_sale_items', 'label' => __( 'Exclude sale item', 'woocommerce' ), 'description' => __( 'Check this box if the coupon should not apply to sale items. Be sure when ticking this box for cart coupons as the presence of any sale item in the cart will stop the coupon from applying', 'woocommerce' ) ) ); + woocommerce_wp_checkbox( array( 'id' => 'exclude_sale_items', 'label' => __( 'Exclude sale items', 'woocommerce' ), 'description' => __( 'Check this box if the coupon should not apply to items on sale. Per-item coupons will only work if the item is not on sale. Per-cart coupons will only work if there are no sale items in the cart.', 'woocommerce' ) ) ); echo '
'; diff --git a/classes/class-wc-cart.php b/classes/class-wc-cart.php index 196dee3d429..f085ee2161f 100644 --- a/classes/class-wc-cart.php +++ b/classes/class-wc-cart.php @@ -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 ); @@ -1154,9 +1154,9 @@ class WC_Cart { $this_item_is_discounted = false; // Sale Items excluded from discount - 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; + 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 $this_item_is_discounted = apply_filters( 'woocommerce_item_is_discounted', $this_item_is_discounted, $values, $before_tax = false, $coupon ); diff --git a/classes/class-wc-coupon.php b/classes/class-wc-coupon.php index dac9ac5df0a..1d86094674f 100644 --- a/classes/class-wc-coupon.php +++ b/classes/class-wc-coupon.php @@ -178,7 +178,9 @@ class WC_Coupon { public function enable_free_shipping() { return $this->free_shipping == 'yes' ? true : false; } -/** + + + /** * Check if a coupon excludes sale items. * * @access public @@ -329,7 +331,7 @@ class WC_Coupon { } if ( ! $valid_for_cart ) { $valid = false; - $error = __( 'Sorry, this coupon is not applicable if your cart contains sale items.', 'woocommerce' ); + $error = __( 'Sorry, this coupon is not valid for sale items.', 'woocommerce' ); } } diff --git a/readme.txt b/readme.txt index 055bdded176..19aa75d40ef 100644 --- a/readme.txt +++ b/readme.txt @@ -196,6 +196,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Feature - Added set_stock() method to product class. * Feature - Linking to mydomain.com/product#review_form will now open the review form on load (if WooCommerce lightbox is turned on) * Feature - Customers can sort by popularity + rating. +* Feature - Option to exclude coupons from sale items (thanks aj-adl) * Templating - Revised pagination, sorting areas (sorting is now above products, numbered pagination below) and added a result count. * Templating - email-order-items.php change get_downloadable_file_url() to get_downloadable_file_urls() to support multiple files. * Templating - loop-end and start for product loops, allow changing the UL's used by default to something else.