woocommerce_calc_discounts_sequentially option to keep backwards compatible
This commit is contained in:
parent
5e538b88e7
commit
aed8ae36cf
|
@ -73,10 +73,21 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
|
||||||
'id' => 'woocommerce_enable_coupons',
|
'id' => 'woocommerce_enable_coupons',
|
||||||
'default' => 'yes',
|
'default' => 'yes',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => 'start',
|
||||||
'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
|
'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
|
||||||
'autoload' => false
|
'autoload' => false
|
||||||
),
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ),
|
||||||
|
'id' => 'woocommerce_calc_discounts_sequentially',
|
||||||
|
'default' => 'no',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'desc_tip' => __( 'When applying multiple coupons, apply the first coupon to the full price and the second coupon to the discounted price and so on.', 'woocommerce' ),
|
||||||
|
'checkboxgroup' => 'end',
|
||||||
|
'autoload' => false
|
||||||
|
),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'title' => _x( 'Checkout', 'Settings group label', 'woocommerce' ),
|
'title' => _x( 'Checkout', 'Settings group label', 'woocommerce' ),
|
||||||
'desc' => __( 'Enable guest checkout', 'woocommerce' ),
|
'desc' => __( 'Enable guest checkout', 'woocommerce' ),
|
||||||
|
|
|
@ -1804,7 +1804,7 @@ class WC_Cart {
|
||||||
|
|
||||||
foreach ( $this->coupons as $code => $coupon ) {
|
foreach ( $this->coupons as $code => $coupon ) {
|
||||||
if ( $coupon->is_valid() && ( $coupon->is_valid_for_product( $product, $values ) || $coupon->is_valid_for_cart() ) ) {
|
if ( $coupon->is_valid() && ( $coupon->is_valid_for_product( $product, $values ) || $coupon->is_valid_for_cart() ) ) {
|
||||||
$discount_amount = $coupon->get_discount_amount( $undiscounted_price, $values, $single = true );
|
$discount_amount = $coupon->get_discount_amount( ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ? $price : $undiscounted_price ), $values, $single = true );
|
||||||
$discount_amount = min( $price, $discount_amount );
|
$discount_amount = min( $price, $discount_amount );
|
||||||
$price = max( $price - $discount_amount, 0 );
|
$price = max( $price - $discount_amount, 0 );
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Update WC to 2.4.0
|
||||||
|
*
|
||||||
|
* @author WooThemes
|
||||||
|
* @category Admin
|
||||||
|
* @package WooCommerce/Admin/Updates
|
||||||
|
* @version 2.4.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maintain the old coupon logic for upgrades
|
||||||
|
update_option( 'woocommerce_calc_discounts_sequentially', 'yes' )
|
Loading…
Reference in New Issue