Adding custom events in Shopify Buy SDK for not one but all cases of Shopify buy buttons

dev1711
New Member
2 0 0

I am using the Shopify buy button SDK for some products on my webpage while my other buy buttons use the /cart.js AJAX API endpoint to add to my wordpress cart. I've added DOMEvents in my Shopify build UI which collects my line items in the shopify cart UI, sends a redirect link to /cart.js/update and updates the cart with the line items that were added to the UI. I've done this because the Shopify add to cart SDK does not sync with my wordpress cart. Now, they are successfully synced.

To my question: I want to add this DOMEvents snippet to all occurrences on my webpage that use Shopify UI.createComponent without manually adding the code to each buy button. The DOMEvents snippet is inside the create component JSON but it creates the JSON string through the use of javascript variables and array iterations. Does anyone know how I can successfully update the JSON for every instance on my webpage that uses the shopify buy SDK?

0 Likes