Recharge products subscription add item in cart using ajax

Kumar2573
Shopify Partner
123 6 12
<script>
  $('#add-to-cart-button').click(function(){
    addItemToCart(949931647, 1, "1", "Months")
  });
</script>
<script>
  function addItemToCart(variant_id, qty, frequency, unit_type) {
    data = {
"id": variant_id, "quantity": qty,
"properties": {
"shipping_interval_frequency": frequency,
"shipping_interval_unit_type": unit_type
} } jQuery.ajax({ type: 'POST', url: '/cart/add.js', data: data, dataType: 'json', success: function() { window.location.href = '/cart'; } }); window.location = '/checkout'; } </script>




{
"type": "text",
"id": "var_id",
"label": "Subscription variant ID"
}
<script>
$('.kg-add-to-cart-button').click(function(){
addItemToCart({{block.settings.var_id}}, 1, "1", "Months");
});
</script>

for more Help

https://support.rechargepayments.com/hc/en-us/articles/360008683774-Adding-an-item-to-the-cart-with-....

 

Expert Shopify Plus & shopify Developer & Theme customizer
- If the problem is solved remember to click to Accept Solution
- Press Like ?? if the answer was helpful
- Still, Facing issue, Reach out to me Email :- jitendra3496@gmail.com | Skype :- jitendra2573_1
- Direct Hire me :- Direct Contact me
Replies 0 (0)