-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discount not delete when another payment select #40
Comments
HI, I have the same problem. Two payment methods, bank transfer and another one, I want a discount only for bacs, when the user isinto the checkout page, if he switchs from bacs to the other methos, the copoun is removed but the total is not updated. Can you help to fix? Best |
Olá, |
Bom Día ! I´m having the same problem as described here. Woocommerce 3.2.3 , and using the last version of this plugin. When i select the payment method with the discount, the coupon gets added, but the total price doesn´t change. I have to reload the page to make it work. The same thing happens when i select the payment without the discount. The coupon gets deleted but no changes in price. I´m using the Official MercadoLibre Plugin, Versión 3.0.3 . Thanks !! |
Not fixed yet, I'm trying to have free time to work in a new version of this plugin, |
Hi @claudiosanches ,
Work for me, hope it could help. |
Hi @Bproductiv , |
Oops it's not the good php file sorry, it's class-wc-payment-discounts-apply-discount.php (i update the first post). This the complete function /**
* Add discount.
*
* @param WC_Cart $cart Cart object.
*/
public function add_discount( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) || is_cart() ) {
return;
}
// Gets the settings.
$settings = get_option( 'woocommerce_payment_discounts' );
// Always set coupons calculation as enabled.
add_filter( 'woocommerce_coupons_enabled', '__return_true' );
if ( isset( $settings[ WC()->session->chosen_payment_method ]['amount'] ) ) {
// Gets the gateway discount.
$amount = $settings[ WC()->session->chosen_payment_method ]['amount'];
if ( apply_filters( 'wc_payment_discounts_apply_discount', 0 < $amount, $cart ) ) {
// Gets the gateway data.
$methods = WC()->payment_gateways->payment_gateways();
$gateway = $methods[ WC()->session->chosen_payment_method ];
$coupon = WC_Payment_Discounts_Coupons::get_coupon( $gateway->id, array( 'amount' => $amount ) );
// Remove other coupons and apply method coupon.
$this->remove_payment_coupons( $cart, $coupon->get_code() );
if ( ! $cart->has_discount( $coupon->get_code() ) ) {
$cart->add_discount( $coupon->get_code() );
}
} else {
$this->remove_payment_coupons( $cart );
}
}else{
$methods = WC()->payment_gateways->payment_gateways();
$gateway = $methods[ WC()->session->chosen_payment_method ];
$coupon = WC_Payment_Discounts_Coupons::get_coupon( $gateway->id, array( 'amount' => $amount ) );
$this->remove_payment_coupons( $cart, $coupon->get_code() );
wc_add_notice('Désolé par de réduction sur ce mode de paiement','notice');
}
} |
didn't work for me. when i change the payment back, the discount still leave there |
is there a solution now? |
Hi.. what´s the solution? thank you |
I use this plugin : https://fr.wordpress.org/plugins/woo-payment-discounts/ |
Hi @claudiosanches, can you estimate when you will implement ajax function in checkout to solve this issue? Thanks! |
Hi. I have the same problem. I have 2 payments methods. Bank Transfer and MercadoPago. I want to apply a discount only to Bank Transfer. When I click on the Bank Transfer method it will applied the discount, but if I change to MercadoPago the discount is not remove. Please I need help! |
Hi,
i have a problem, i have just one payment method with a discount. When the user select another payment method (without discount) the old discount won't delete.
is there an solution?
best Frank
The text was updated successfully, but these errors were encountered: