Skip to content

Commit

Permalink
Use undiscounted price for coupons
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Mar 24, 2015
1 parent a49ac39 commit 5e538b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions includes/class-wc-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -1797,13 +1797,15 @@ public function get_discounted_price( $values, $price, $add_totals = false ) {
return $price;
}

if ( ! empty( $this->coupons ) ) {
$undiscounted_price = $price;

if ( ! empty( $this->coupons ) ) {
$product = $values['data'];

foreach ( $this->coupons as $code => $coupon ) {
if ( $coupon->is_valid() && ( $coupon->is_valid_for_product( $product, $values ) || $coupon->is_valid_for_cart() ) ) {
$discount_amount = $coupon->get_discount_amount( $price, $values, $single = true );
$discount_amount = $coupon->get_discount_amount( $undiscounted_price, $values, $single = true );
$discount_amount = min( $price, $discount_amount );
$price = max( $price - $discount_amount, 0 );

// Store the totals for DISPLAY in the cart
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==

* Fix - Ensure coupon taxes are reset when calculating totals.
* Tweak - Base discounts on the undiscounted price. #5874

= 2.3.7 - 18/03/2015 =
* Fix - Allow saving of empty download expiry date on orders.
Expand Down

0 comments on commit 5e538b8

Please sign in to comment.