Hey Shopify Community,
I’m building custom “add to cart” buttons with AJAX and was wondering if using data attributes to pass variant IDs into a javascript function would be bad practice.
I need to change variant IDs on the fly, so when a user clicks on an option to choose between two products, they populate an add to cart button with the final choice.
This is what the option button would look like:
Then I would just use the ID passed into the attribute and use it in an ajax function.
Are there security issues tied to this? Or any reason why this wouldn’t be a good idea. Also, if there is a better solution, it would be great to get some insight.
Thank you.