Tweak content. Closes #2311

This commit is contained in:
Mike Jolley 2013-01-29 13:58:57 +00:00
parent 1cded83298
commit fb67343611
4 changed files with 10 additions and 7 deletions

View File

@ -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 '</div><div class="options_group">';

View File

@ -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 );

View File

@ -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' );
}
}

View File

@ -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.