Ecommerce Shopify WordPress Discussion

Event Handler Not Executing During Shopify Checkout

I am trying to execute some code when the Shopify checkout form is submitted but it is not firing. $(document).ready(function () { $(document).on('submit', '.ajax-cart__cart-form', function(e) { e.preventDefault(); // Prevent the default form submission alert('testing'); if ($('#add-product-checkbox').is(':checked')) { // Use Shopify AJAX API to add the product to the cart $.ajax({ type: 'POST', url: '/cart/add.js', data: { quantity: 1, // Adjust the quantity as needed id: 12345 // Variant ID of the product to add }, dataType: 'json', success: function(response) { // Redirect the user to the checkout page window.location.href = '/checkout'; }, error: function(jqXHR, textStatus, errorThrown) { console.log('Error adding the product to the cart'); console.log(textStatus); } }); } else { // If the checkbox is not checked, proceed to the regular checkout window.location.href = '/checkout'; } }); }); Other jQuery code fires within the document.ready block but this doesn't get touched.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.