Hi All,
is it at all possible to prevent a ‘product list carousel’ section from opening the product page? Rather id like to just add to cart.
Theme Pitch URL: – Ticket Tech
Hi All,
is it at all possible to prevent a ‘product list carousel’ section from opening the product page? Rather id like to just add to cart.
Theme Pitch URL: – Ticket Tech
Hi @DASCPA ,
Yes, it’s possible! You can prevent the product page from opening and instead trigger “Add to Cart” directly from a product list carousel in Shopify - but it requires a bit of code customization.
<a href="{{ product.url }}">
<button class="quick-add" data-product-id="{{ product.variants.first.id }}">
Add to Cart
</button>
document.querySelectorAll('.quick-add').forEach(button => {
button.addEventListener('click', function () {
const productId = this.dataset.productId;
const qtyInput = this.closest('.product-card').querySelector('.quantity-input');
const quantity = parseInt(qtyInput.value) || 1;
fetch('/cart/add.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ id: productId, quantity })
})
.then(res => res.json())
.then(data => {
alert('Added to cart!');
});
});
});
Hi @DASCPA ,
Could you please share with me the password to access your website?