Scripts + Buy SDK

Kisuka
New Member
2 0 0

Our business uses Shopify Plus to handle our product purchasing for our service. We've been using it for about 3 or 4 years now.

We implemented the Buy SDK a while back on our main site which allows the user to quickly purchase a product instead of going to the store subdomain. They're able to click on a 'buy button' and be prompted with a list of variants of the product, then they hit checkout and are immediately taken to checkout.

This was all great until we started wanting to use Shopify Scripts to give discounts to our users who are VIP members. When one of these users places an order through the actual Shopify hosted storefront, the Line Item scripts run and apply discounts just fine.

However, when the user uses the Buy Button SDK on our main site, Line Item Scripts do not run at all during checkout. This results in a mess of a situation for us where some users get the discounts when going directly through the store, and other users do not. This results in customers sending us support tickets asking for partial refunds for their discount.

Why do Line Item scripts not apply for checkouts generated via the Buy SDK? It seems very weird that they are limited only to a POST request from the Shopify hosted site to /cart on the Shopify hosted site.

Is there a reason why they cannot be applied at the initialization of any checkout? Is there plans to support them at all when creating a checkout via the buy sdk? Is there a solution at all to make sure they trigger while still keeping our current flow from Our Site -> Shopify Checkout?

0 Likes
Jason
Shopify Expert
10039 119 1876

Channels (like buy button, js buy, etc) only create checkouts. The online storefront creates carts and checkouts. It's a subtle point but not all checkout flows are the same behind the scenes.

If you must use Shopify Scripts you'd need to look into adjusting how the cart is created. This could be a process in which you

  • compile the list of items in the cart offsite - you're doing that now
  • redirect the customer to the shopify store, along with the cart list
  • add the items to a cart using the AJAX API
  • redirect to checkout

That process will give you a cart and checkout via the online storefront and Shopify Scripts will trigger. 

Not without drawbacks for something to consider if you're running into enough customer service issues. Also be sure to push the feedback to your MSM.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Kisuka
New Member
2 0 0

Yeah, that's pretty much the idea I also had come to the conclusion of. Just was curious if there was another possible solution as the whole like redirecting to cart then quickly populating via ajax and then submit thru to checkout seemed like such a hacky solution.

0 Likes