woocommerce_calc_discounts_sequentially option to keep backwards compatible
This commit is contained in:
parent
5e538b88e7
commit
aed8ae36cf
|
@ -68,13 +68,24 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
|
|||
array( 'title' => __( 'Checkout Process', 'woocommerce' ), 'type' => 'title', 'id' => 'checkout_process_options' ),
|
||||
|
||||
array(
|
||||
'title' => __( 'Coupons', 'woocommerce' ),
|
||||
'desc' => __( 'Enable the use of coupons', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_coupons',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
|
||||
'autoload' => false
|
||||
'title' => __( 'Coupons', 'woocommerce' ),
|
||||
'desc' => __( 'Enable the use of coupons', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_coupons',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
|
||||
'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(
|
||||
|
|
|
@ -1804,7 +1804,7 @@ class WC_Cart {
|
|||
|
||||
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( $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 );
|
||||
$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