Don't apply product discount if price is already 0

Closes #8725
This commit is contained in:
Mike Jolley 2015-08-05 13:45:28 +01:00
parent 2954707118
commit d222dd4c37
1 changed files with 12 additions and 10 deletions

View File

@ -634,16 +634,18 @@ class WC_Coupon {
// Handle the limit_usage_to_x_items option
if ( $this->is_type( array( 'percent_product', 'fixed_product' ) ) ) {
if ( '' === $this->limit_usage_to_x_items ) {
$limit_usage_qty = $cart_item_qty;
} else {
$limit_usage_qty = min( $this->limit_usage_to_x_items, $cart_item_qty );
$this->limit_usage_to_x_items = max( 0, $this->limit_usage_to_x_items - $limit_usage_qty );
}
if ( $single ) {
$discount = ( $discount * $limit_usage_qty ) / $cart_item_qty;
} else {
$discount = ( $discount / $cart_item_qty ) * $limit_usage_qty;
if ( $discounting_amount ) {
if ( '' === $this->limit_usage_to_x_items ) {
$limit_usage_qty = $cart_item_qty;
} else {
$limit_usage_qty = min( $this->limit_usage_to_x_items, $cart_item_qty );
$this->limit_usage_to_x_items = max( 0, $this->limit_usage_to_x_items - $limit_usage_qty );
}
if ( $single ) {
$discount = ( $discount * $limit_usage_qty ) / $cart_item_qty;
} else {
$discount = ( $discount / $cart_item_qty ) * $limit_usage_qty;
}
}
}