Jump to content

prestashop 1.7.8 : How to get product_id in custom js file with javascript or jquery


dupont max

Recommended Posts

Hello,

I want to get product_id in custom js file with javascript or jquery,

This is path of custom js file : \themes\theme_name\assets\js\custom.js

I have already get product_id in tpl file and it working fine but in javascript there not working, i have undefined value

Thanks.

 

Link to comment
Share on other sites

Hello,

I success managed to retrieve the variables in the javascript code from the TPL code

In fact the idea is to disable the add cart button dynamically, instantly without reloading the page when the quantity in the basket is greater than the quantity in stock To avoid excess orders in addition to stock.

I put this tpl code in this file \themes\nomtheme\templates\catalog\_partials\product-add-to-cart.tpl :

image.thumb.png.828903dca87681fd49d080fb5169dd79.png.20822cd7da2dcce4f35cd351d329c007.png

and i put javascript code in this file \themes\nomtheme\assets\js\custom.js

image.thumb.png.8fbfebefed1b2212290bcc407a32491b.png.c173a7fd12ea674ff0173a43ffd49652.png

image.png.5bc50d6646eb02eeb5189dbb7216aed6.thumb.png.2995ec8c8acd0b4953a5b62c0a0a38da.png

 

But it does not work

How to solve this problem ?

Thank you in advance for your help.

 

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...