Closed FabioReims closed 5 years ago
Hi @Apury Thanks for opening this issue!
It is indeed really strange that gift wrapping is being added to the cart even though it is not enabled. Are you using or have you used any gift card modules that could be using the gift wrapping field as a workaround? Looking at this line I think this number is coming from the actual PrestaShop Cart object itself: https://github.com/mollie/PrestaShop/blob/b127fdf32e20d140d96e6fe8e9a165cd0d898a17/mollie.php#L2534 so I think we might be able to find the source if we can track what modules are able to add a gift wrapping price to the cart.
What happens if you comment that line out and instead use:
$wrapping = 0;
Hi @Apury Thanks for opening this issue!
It is indeed really strange that gift wrapping is being added to the cart even though it is not enabled. Are you using or have you used any gift card modules that could be using the gift wrapping field as a workaround? Looking at this line I think this number is coming from the actual PrestaShop Cart object itself:
Line 2534 in b127fdf
$wrapping = round($cart->getGiftWrappingPrice(), $apiRoundingPrecision);
so I think we might be able to find the source if we can track what modules are able to add a gift wrapping price to the cart. What happens if you comment that line out and instead use:
$wrapping = 0;
Somehow that results in an Error 500. The backoffice throws this error message at me:
[PrestaShop] Fatal error in module file: /var/www/html/store/app/bootstrap.php.cache:3231 Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Parse error: syntax error, unexpected '$remaining' (T_VARIABLE) in /var/www/html/store/modules/mollie/mollie.php:2535 Stack trace: #0 /var/www/html/store/classes/module/Module.php(1071): ModuleCore::coreLoadModule('mollie') #1 /var/www/html/store/classes/Hook.php(837): ModuleCore::getInstanceByName('mollie') #2 /var/www/html/store/classes/controller/AdminController.php(2811): HookCore::exec('displayBackOffi...', Array) #3 /var/www/html/store/classes/controller/Controller.php(234): AdminControllerCore->init() #4 /var/www/html/store/classes/Dispatcher.php(428): ControllerCore->run() #5 /var/www/html/store/chaeyeonryu/index.php(96): DispatcherCore->dispatch() #6 {main} Next LogicException: Request stack is empty in /var/www/html/store/app/bootstrap.php.cache:3231 Stack trace: #0 [internal function]: Symfony\Component\HttpKernel\HttpKernel->terminateWithException(Object(Symfony\Component\Debug\Exception\FatalThrowableError)) #1 /var/www/html/store/v...
The change I've made to the mollie.php looks like this:
$remaining = round($amount, $apiRoundingPrecision); $shipping = round($cart->getTotalShippingCost(null, true), $apiRoundingPrecision); / $wrapping = round($cart->getGiftWrappingPrice(), $apiRoundingPrecision); / $wrapping = 0 $remaining = round($remaining - $shipping - $wrapping, $apiRoundingPrecision); $cartItems = $cart->getProducts();`
I'm drunk. I forgot the ";" ..
forgot the ;
I think:
$remaining = round($amount, $apiRoundingPrecision);
$shipping = round($cart->getTotalShippingCost(null, true), $apiRoundingPrecision);
/* $wrapping = round($cart->getGiftWrappingPrice(), $apiRoundingPrecision); */
$wrapping = 0;
$remaining = round($remaining - $shipping - $wrapping, $apiRoundingPrecision);
$cartItems = $cart->getProducts();`
Yes, correct :slightly_smiling_face:
This indeed solves the problem. I now 'fixed' it in a less 'forgettable' way by reducing the price for gift wrapping from 2€ to 0€. Appareantly, albite disabled, the 2€ that would've been charged, if it were disabled, were still being included in the calculation. No idea where the 5€ something came from though. Now it matches perfectly. Thank you. Sincerely.
Does everything match? Can you reach the payment screen?
BTW: has the other thread you opened a while ago been solved by the update(s)? https://github.com/mollie/PrestaShop/issues/76
Marking as solved. Feel free to open a new issue if this returns.
It appears this issue is still present in the current version of this module. I had the exact same error where gift wrapping is added to the total amount, even though this was not set by the customer. The solution by firstred still works and allows charging the customer for wrapping correctly, but requires modification of the module itself. The other solution of disabling gift wrapping in Prestashop does fix the problem temporarily, but of course, we do want to offer our customers the option of having their gifts wrapped. Can the code be changed permanently by the developer to fix this issue in future versions as well?
Expected behavior
I expected to be redirected to the payment screen.
Actual behavior
This error message:
Looking at the values in it, I can find: unit price: 5.49€, another unit price: 2.99€ and a random 2.00€ which together would indeed result in a total of 10.48€. The products original price is 4.99€ with a 30% discount dropping it to 3.49€ + 2,99€ shipping = 6.48€. Thus, I can't explain where the 5.49€ are coming from. The last 2.00€ would be the exact same amount that is charged for gift wrapping. Which is also set to "quantity" 1 which is curious, given that gift wrapping is disabled in my store.
Steps to reproduce the behavior
Activate oders API and check out.
Environment