Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am looking for a button click to render a section template or reload the current product via AJAX. Currently, I have all the products set up and can click a button to trigger an API call to get the section. But even though I am passing the product ID the section comes back without product data. Is there a way to have an AJAX call on a product page that will allow me to replace the current product with another one?
request = new XMLHttpRequest()
request.open('GET', '/?section_id=product-name-template&product_id='+event.target.dataset.productId, true)
request.send()
My current request including the product_id
Hey
Your API call is a request for a homepage's section! So, obviously, it has no product/collection data
With section rendering, if you want to add product/collection context simply call
fetch(`/products/your-product-handle?section_id=your-section-id`)
Same for collection.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024