From afcf7821f3dc6ebc75c487f4679426a4c706368a Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 31 Jul 2023 12:24:01 +0530 Subject: [PATCH] Fix new voucher generation issue on order creation --- classes/PaymentModule.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 3e89319f2..5e5fb6f52 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -646,17 +646,17 @@ abstract class PaymentModuleCore extends Module // THEN // The voucher is cloned with a new value corresponding to the remainder $reduction_amount_converted = $cart_rule['obj']->reduction_amount; - if ((int) $cart_rule['obj']->reduction_currency !== (int) $cart->id_currency) { + if ((int) $cart_rule['obj']->reduction_currency !== (int) $this->context->cart->id_currency) { $reduction_amount_converted = Tools::convertPriceFull( $cart_rule['obj']->reduction_amount, new Currency($cart_rule['obj']->reduction_currency), - new Currency($cart->id_currency) + new Currency($this->context->cart->id_currency) ); } if ($cart_rule['obj']->reduction_tax) { - $remaining_amount = $reduction_amount_converted - $values['tax_incl']; + $remaining_amount = $values['tax_incl'] - $order->total_products_wt; } else { - $remaining_amount = $reduction_amount_converted - $values['tax_excl']; + $remaining_amount = $values['tax_excl'] - $order->total_products; } if ($remaining_amount > 0 && $cart_rule['obj']->partial_use == 1 && $reduction_amount_converted > 0) { // Create a new voucher from the original