Shopify Recharge Subscription Cart Update

Job ID: 39315807

Budget: $250 – $750 USD

We have a shopify site with recharge subscription, bakersbesthealth.com
Products have variants: Buy 1, Buy 2, Buy 3 get 1 Free, Buy 5 get 2 Free
There is an additional discount when adding as subscription.
We need the quantity of the items to be reflected in the cart
Buy 1 = 1
Buy 2 = 2
B3G1F = 4
B5G2F = 7
So that item and quantity can be passed to ERP system with Ordoro

Below are the steps recommended by recharge to make this function:
Shopify Checkout integration
Add an item to the cart from outside of the product page with Ajax by specifying the variant_id, quantity, and selling_plan.
Step 1 - Add a listener
1. Add a listener to the Add to cart link button.
2. Within the listener, call the addItemToCart function, and specify parameters for:
• variant_id
• quantity
• selling_plan

Note:
It is recommended that you run an Ajax cart/clear before calling the Ajax add-to-cart function.
Step 2 - Identify parameters
1. Refer to Shopify's guide find a variant id to identify the variant_id.
2. Locate the selling_plan.
i. If the product only has one subscription interval option, you can use liquid code to get the first selling plan ID associated with the subscription: {{product.selling_plan_groups[0].selling_plans[0].id}}
ii. If a product has multiple interval options, you must loop through the selling_plan_groups and then the selling_plans parameter to get the relevant ID for the given interval option.
Related categories: PHP JavaScript Website Design HTML Shopify