Jump to content

Refresh TPL Files after changing product attribute


Recommended Posts

Hello,

I am setting up a "sticky add to cart" banner on the product page. I have created a new TPL file in my theme, however I have a problem with products with attributs.


Indeed, we can not directly change the attributs on the banner but there is only a reminder of the declination chosen with the price and the button "add to cart". However, when you change attribut without refreshing the page, the attribut displayed on the banner does not change.


How can I make sure that the TPL file is reloaded each time I change product attribut ?


Thank you for your answers, please be lenient, I am not a developer by formation. 

Link to comment
Share on other sites

  • 4 weeks later...

Hello,

I finally found the solution for all those who would struggle like me lol

We need to add a block section name like :

{block name='my_section'}

{include file='my_file.tpl'}

{/block}

And add the line to ProductController.php :

'my_section' => $this->render('my_file.tpl'),

And finally add this to the file core.js :

(0,r.default)(".quickview .my_file_class_name, #product .my_file_class_name").replaceWith(e.my_section),

AND IT'S WORK!!

Just if someone could confirm me that the core.js file can be modified without worries?

Hoping to have helped someone !

Link to comment
Share on other sites

  • 7 months later...

Hi bendobush,

I am looking to do the same as you. Can you explain to me how and where to insert the portion of code in the ProductController.php? Regarding the core.js, isn't it better to insert it in the custom.js? Please note that I am not a development expert. By the way my version of prestashop is 1.7.7.8

Think's for your reply. Regards

Edited by [email protected] (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...