Where to place new AJAX code in theme files for recharge checkout integration?

Where to place new AJAX code in theme files for recharge checkout integration?

biznazz101
Shopify Partner
494 50 97

Hello, I am updating a store from the recharge checkout to recharge shopify checkout integration. I have been told that when the conversion takes place the current AJAX parameters will need to be updated along with widget customizations. I have reviewed this guide but am a little out of my depth.

It shows this code will need to be used, my question is where do I place this code in my theme files? I don't see the AJAX code I will need to replace:
STORE URL: hairtieclub.com

New AJAX Code:

 

<input type="button" id="add-to-cart-button" value="ADD TO CART" onClick="addItemToCart(36807328039071, 1, {{product.selling_plan_groups[0].selling_plans[0].id}})">       
<script>  
function addItemToCart(variant_id, qty, selling_plan) {

    data = {
      "id": variant_id,
      "quantity": qty,
      "selling_plan": selling_plan
    }
    jQuery.ajax({
      type: 'POST',
      url: '/cart/add.js',
      data: data,
      dataType: 'json',
      success: function() { 
        window.location.href = '/cart'; 
      }
    });
  }
</script>    

 

 

 

 Current Page:
Screen Shot 2023-04-11 at 10.27.11 AM.png

 

The theme files I see that seem to be like they could be relevant are:
snippets/ajax-cart-template.liquid
assets/ajax-cart.js.liquid
templates/page.sign-up.liquid
snippets/subscription-product.liquid

I cannot seem to figure out where I will be putting this new code, or how it will interact with the rest of the theme files and help would be appreciated, thanks guys!

Don't hesitate to reach out for more help with your store.
SEE OUR TASK STORE or check us out via our profile! FREE STORE AUDIT
Replies 0 (0)