Hello,
I need to update some of my product.tpl page when the customer selects a variant.
I managed to get the variant id after selection in my theme custom.js file:
prestashop.on('updatedProduct',function(event) { let product_id = event.id_product_attribute; });
Now I need to get the variant images ids in an array to be able to call the original images.
On the first load I display these images with (it's not very clean I know but I need unprocessed images here to be able to have multiple sizes):
<img class="" src="{$tpl_dir}../../img/p/{$image.id_image}/{$image.id_image}.jpg" alt="{$image.legend}" title="{$image.legend}" itemprop="image">
As the front ProductController.php already exists I should not have to make my own controller for this and be able to make an ajax request to it but I can't get it done. I'm struggling on the url for this request.
I tried with some threads on this form to build my request like (knowing I still need to put the product id in there):
prestashop.on('updatedProduct',function(event) { let product_id = event.id_product_attribute; var postdata = { ajax: 1, controller: 'Product', action: 'getProduct' $.ajax({ type: 'POST', url: 'index.php', data: postdata, success: function(data){ console.log(data); } }); });
But I get a 404 error, still struggling with url.
This thread:
https://www.prestashop.com/forums/topic/869456-how-to-display-a-product-with-ajax/
looks fine to me too but can't figure out the url part neither.
Any idea on how I could get this done please?