yaso Posted February 16, 2016 Share Posted February 16, 2016 Hello, I hope someone can help with this issue that i have with Klarna payment module(no one else is probly using it currently on prestashop). We have webstores running multiple versions 1.6.1.(1-3), all of them have the same problem. Uncaught TypeError: price.toFixed is not a function ^^ ->This error occurs on default installation of klarna payment module and while using the klarna checkout. (When customer is pressing - / + or del on product). ->The Error causes klarna's checkout frame to not refresh(it should refresh on every modification on the cart). ->Plenty of customers continue to the payment after modifying their cart without refreshing page(only solution to refresh klarna without coding). ->This event causes payment errors, i.e when customers actually pay the original cart price instead of the one they ordered. So i tracked the problem to -> tools.js inside tools.js there is a function -> formatCurrency row 63 has line of price = parseFloat(price.toFixed(10)); for some reason klarna's module doesn't want to work with that line of code. so what i've tried is the two methods below. Both of them does make the klarna checkout to refresh properly when shopping cart is modified (-/+/del products). -> price = parseFloat(price).toFixed(10); OR -> price = parseFloat(price).toFixed(10); price = parseInt(price, 10); Problem is that i don't know if this has an effect on something else or is it even proper way of solving the error. also after this fix the klarna checkout finds a new error "Uncaught TypeError: Cannot read property 'postMessage' of null" which is in one of the klarna's side js files that are unreachable for me to check. Any thoughts? Link to comment Share on other sites More sharing options...
bellini13 Posted February 16, 2016 Share Posted February 16, 2016 Are you saying this problem only occurs when using that payment module? What happens if you disable that payment module and use bankwire payment module instead? Does this error continue to occur? Link to comment Share on other sites More sharing options...
yaso Posted February 16, 2016 Author Share Posted February 16, 2016 Hi bellini, Yes the problem only occurs with Klarna payment module, because that is the only payment method we currently have (we've had others before without this problem). Other modules wouldn't probly have this problem since this one uses their own checkout part in a iframe. i have a image here to make the problem maybe more clearer. (in the picture i have added the quantity of one product in the shopping cart, so you can clearly see that the amounts doesn't match because the iframe doesn't reload). Link to comment Share on other sites More sharing options...
bellini13 Posted February 16, 2016 Share Posted February 16, 2016 Two things 1) disable CCC so that you can see the exact error and where it originates from 2) disable this payment module and enable bankwire so that you can test to see if this issue is caused by the payment module or is something completely different Link to comment Share on other sites More sharing options...
yaso Posted February 17, 2016 Author Share Posted February 17, 2016 Okay, so i did both things you mentioned. results: 1) 2) No errors anywhere, everything worked as it should. Link to comment Share on other sites More sharing options...
bellini13 Posted February 17, 2016 Share Posted February 17, 2016 /js/tools.js line 63 price = parseFloat(price.toFixed(10)); which is inside the javascript function formatCurrency. I believe this is a theme issue and not a payment module issue. Perhaps bankwire does not have a need to use this function, but for some reason your other payment module is trying to use it. You will need debug the module further and see what would be causing it. Link to comment Share on other sites More sharing options...
yaso Posted February 29, 2016 Author Share Posted February 29, 2016 okay i've done some more inspection to this, seems like the problem is not in our theme but in the settings. The module is looking for a value from json data that free_ship: false or free_ship: true Here is where the problem occurs, if (json.free_ship > 0 && !json.is_virtual_cart) { $('.cart_free_shipping').fadeIn(); $('#free_shipping').html(formatCurrency(json.free_ship, currencyFormat, currencySign, currencyBlank)); } We use free shipping in our stores, so free_ship will be true. so the module is just checking if it is > 0 and that if happens. In that if it is trying to look for #free_shipping html which doesn't exist in our stores. (because #free_shipping doesn't exist the js breaks here on the formatcurrency and won't reload the checkout) So, if i set the shipping cost, this problem doesn't occur and the module works fine. (this will not do it for us.) Now, i'm wondering if it is okay to add this to the if sentence if (json.free_ship > 0 && !json.is_virtual_cart && json.free_ship != true) this would make the module work (reload when shopping cart quantities are changed) with free shipping. Link to comment Share on other sites More sharing options...
yaso Posted February 29, 2016 Author Share Posted February 29, 2016 okay i've done some more inspection to this, seems like the problem is not in our theme but in the settings. The module is looking for a value from json data that free_ship: false or free_ship: true Here is where the problem occurs, if (json.free_ship > 0 && !json.is_virtual_cart) { $('.cart_free_shipping').fadeIn(); $('#free_shipping').html(formatCurrency(json.free_ship, currencyFormat, currencySign, currencyBlank)); } We use free shipping in our stores, so free_ship will be true. so the module is just checking if it is > 0 and that if happens. In that if it is trying to look for #free_shipping html which doesn't exist in our stores. (because #free_shipping doesn't exist the js breaks here on the formatcurrency and won't reload the checkout) So, if i set the shipping cost, this problem doesn't occur and the module works fine. (this will not do it for us.) Now, i'm wondering if it is okay to add this to the if sentence if (json.free_ship > 0 && !json.is_virtual_cart && json.free_ship != true) this would make the module work (reload when shopping cart quantities are changed) with free shipping. Actually looked into this again, tried to create that #free_shipping element, that wasn't the problem. The problem was that the module is trying to turn true/false value into "formatcurrency". Link to comment Share on other sites More sharing options...
yaso Posted March 1, 2016 Author Share Posted March 1, 2016 Don't know if anyone is reading this topic, but it is kind of solved. My last post pretty much explains the bug that is actually in the klarna payment module.(anyone else having this bug will have to hack past that if sentence or wait for fix) I tested the bug with clean install of prestashop and confirmed that it is bugging with the clean install too. 1 Link to comment Share on other sites More sharing options...
bkmust Posted February 6, 2020 Share Posted February 6, 2020 Hi, I have the same problem, when I change the quantity Klarna does not update, could you please help me, which Java file I should change? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now