Filters for coupons

This commit is contained in:
Mike Jolley 2011-11-21 16:44:33 +00:00
parent 53ccc12361
commit cf248ff114
2 changed files with 14 additions and 7 deletions

View File

@ -374,7 +374,7 @@ class woocommerce_cart {
elseif ($coupon->type=='percent_product') :
$percent_discount = ( $values['data']->get_price_excluding_tax() / 100 ) * $coupon->amount;
$percent_discount = ( $values['data']->get_price_excluding_tax( false ) / 100 ) * $coupon->amount;
$this->discount_product = $this->discount_product + ( $percent_discount * $values['quantity'] );
@ -407,7 +407,7 @@ class woocommerce_cart {
case "percent" :
// Get % off each item - this works out the same as doing the whole cart
$percent_discount = ( $values['data']->get_price_excluding_tax() / 100 ) * $coupon->amount;
$percent_discount = ( $values['data']->get_price_excluding_tax( false ) / 100 ) * $coupon->amount;
$this->discount_product = $this->discount_product + ( $percent_discount * $values['quantity'] );
@ -420,7 +420,7 @@ class woocommerce_cart {
endif;
endforeach;
return $price;
return apply_filters( 'woocommerce_get_discounted_price_', $price, $values, $this );
}
/**
@ -431,6 +431,8 @@ class woocommerce_cart {
if ($this->applied_coupons) foreach ($this->applied_coupons as $code) :
$coupon = &new woocommerce_coupon( $code );
do_action( 'woocommerce_product_discount_after_tax_' . $coupon->type, $coupon );
if ($coupon->type!='fixed_product' && $coupon->type!='percent_product') continue;
if ( !$coupon->apply_before_tax() && $coupon->is_valid() ) :
@ -484,6 +486,8 @@ class woocommerce_cart {
if ($this->applied_coupons) foreach ($this->applied_coupons as $code) :
$coupon = &new woocommerce_coupon( $code );
do_action( 'woocommerce_cart_discount_after_tax_' . $coupon->type, $coupon );
if ( !$coupon->apply_before_tax() && $coupon->is_valid() ) :
switch ($coupon->type) :
@ -503,7 +507,7 @@ class woocommerce_cart {
break;
endswitch;
endif;
endforeach;
}

View File

@ -82,11 +82,14 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
== Changelog ==
= 1.3 - 18/11/2011 =
= 1.3 - xx/11/2011 =
* Minor bug fixes
* Schema.org markup for products and reviews
* Option to apply coupons before tax
* Rewritten cart calculations to support coupons before tax and after tax (optional)
* Option to apply coupons before tax (per coupon)
* Rewritten cart tax calculations to support coupons before tax and after tax
* 2 lines of discounts on total tables - 1 for product discounts, 1 for after tax discounts (e.g. store credit)
* Tweaked paypal to work with tax inclusive prices without screwing up rounding
* Stored ex. prices with higher precision to prevent rounding errors
= 1.2.4 - 18/11/2011 =
* More sale price logic fixes for variations. Now correctly compares variation's prices.