We’ve recently migrated Recharge to native Shopify checkout.
Previously, using Recharge’s checkout for any orders with subscriptions in them allowed us to give free shipping using a 0 weight shipping rule as Recharge was using duplicate products for the order.
After the migration, all the products are unified now and this 0 weight rule can no longer be applied.
So I need to make any orders with a subscription in them to have free shipping. This is just on the first order as I have shipping turned off in Recharge for subsequent orders.
It seems like this can be handled with Scripts but I’m not exactly sure on the syntax.
Just on first guess:
loop through line items and look for a selling plan id
hasSub = 0
Input.cart.line_items.each do |item|
if (item.selling_plan_id > 0)
hasSub = 1
end
end
if (hasSub && Input.cart.shipping_address.country_code == 'US')
Input.shipping_rates.each do |shipping_rate|
next unless shipping_rate.source == "USPS First Class"
shipping_rate.apply_discount(shipping_rate.price * 1, message: "Free Subscriber Shipping")
end
end
Output.shipping_rates = Input.shipping_rates