I got a problem on a Prestashop website (1.7.7.8) , with updating price when changing options.
In some particular cases, an error occured and the price is not displayed.
You can see the bug here : https://bacom.lebonweb.fr/accueil/32-bache.html
This append in a specific scenario, when we have several options ; and not all are availables for all others options (not sure to be clear..). In this case :
- the type "Roll up" has only 1 dimension available (200cm and 85cm).
- the type "Bache" has others dimensions available, but not the same as the type ROLL UP
So to see the bug, you can follow those steps :
1/ go to https://bacom.lebonweb.fr/accueil/32-bache.html
2/ by default TYPE is rollup. Change the type select, choosing "Bache"
3/ the selects Hauteur and Largeur are well updated, with the available values for BACHE type (different from the ROLLUP type values). But the price disapears, and the error is "Can not retrieve the id_product_attribute" (debug mode is on)
If you reload the page, the bug disapear.
Some tests confirms the problem comes from the theme ; with classic default theme the same scenario works fine (http://www.lebonweb.fr/dev/bacom-test/femmes/2-42-brown-bear-printed-sweater.html)
I’ve tried, file by file (tpl and js) , to replace custom theme code with default theme code.
But impossible to solve this error….
I’m probably missing something with ajax & JS.
I’ve noticed this warning on console : "jQuery(window).on(‘load’…) called after load event occurred"…
But after 2 days of searching, reading, and testings, still unable to find a solution.
Would you have advice or suggestion on where I should investigate more ?
Thanks a lot
EDIT : To explain diferently (and shortlier ^^) the problem with combinations I’m encountering :
EXEMPLE : We got 3 combinations of a t-shirt :
T shirt – RED – Size : 1
T-shirt – RED – Size 2
T-shirt – BLACK – Size 1
Changing one option may automatically change another option value :
step 1 : choose options : color : RED / Size 2
step 2 : change option color to BLACK = Size change automatically to 1
In my case, it seems that the default combination datas (the one loaded automatically in this exemple scenario) is not sent to the ajax request that gets the price datas.
Wheras in other place in the page, those default datas are well get.
Maybe something like the ajax call to get price is called BEFORE another call that calculate the default combination according to option changes…?
Hope this other presentation of my problem will help 🙂
Thanks !
3
Answers
I finally found how to solve the problem (but didn't understand why) : dis-activate the ttcountdown module and clean ALL caches. The informations given by Patrick were very helpful, so thanks again Patrick for taking time to help ! This solution is okay, because my client doesn't need any countdown functionality.
But very frustrating, cause I did not clearly understand where and what in the code provocates the bug ; whereas we had quite a lot of elements and datas about it.
Maybe there's a link with changes on prestashop 1.7 about attributes (see : PrestaShop 1.7 How to get id_product_attribute on product page?) :
With those informations, I've supposed maybe the bugging theme author didn't make clean and stable adaptation of his script after this change...? So I've tried some corrections on ttproductcountdown.php code, just for better understanding, around those lines (function hookPSPC at line 1360 of module/ttproductcountdown/ttproductcountdown.php)
Without success... So as long as I don't plan to work often with prestashop ; and a day gets only 24h ; I will "give up" try to understand the problem.
Patrick, just for information, Prestashop is already using Boostrap. I'd like to make all by myself, but creating a theme for prestashop is quite long cause it covers a lots of pages and functionality (cart, catalog, user account etc..).
As I said, I avoid to work with CMS... Cause correcting a bug by clicking on a button without learning anything is not the way I like to work.
Thanks Patrick !
this took some debugging, I don’t know how much this might be helpful to you but thought I would try anyway….
the js is making a call to
with the following form data:
and the following body data
this api is then throwing the following error:
The call is coming from
So I wonder is this a php error rather than a jquery one as even when I refresh the page in edge, chrome or firefox I always get the error?
I hope this helps
so i dug into this a bit more, this is a rather long detail so please bare with me, the php stack trace is :
the call is still/now coming from:
there seams to be a function in core.js
this line is where that error message is coming from:
it is injecting the following htlm :
if i reply the same ajax call though postman or fiddler i can re-create the error, the
witch as you say is a theme script I assume this is something that is added by the site host your using or some sort of plug in ?
when I compare it to the theme that works (http://www.lebonweb.fr/dev/bacom-test/femmes/2-42-brown-bear-printed-sweater.html)
the request is totally different :
moreover the core.js file is totally different, for a start its minimized …so you could try copying the core.js file from the theme that works to the theme that dose not and see what happens, in theory if it’s just a theme script the core functionality should still work, failing that contact the site provider or raise an issue worth the theme provider (assuming that have github or some equivalent) and ask why their theme script is failing as theme script shouldn’t act differently that’s kinda the point of them, better still do away with the theme and use your own, a very good and widely used theme is https://getbootstrap.com/docs/5.0/getting-started/introduction/ it is easy to use and offers very good customisable styling and functionality
I hope this helps