API request to s2members to apply coupon

Tom2024
Shopify Partner
15 0 3

I must admit that I am new to shopify coding, however I wrote some code that would allow a client in woocommerce to check a subscriber s2member site for a level 2 or above and would allow the use of a coupon code we predetermined and works great in woocommerce checkout.  However we are migrating to shopify and I believe I will need an APP to do this and want to look into it, but was curious if this would even be possible and best ways to attack it?  If it helps, we also do one for a fellow shopify store and check its members email and plan level and as long as it all matches they are allowed to use the coupon or get a message they are not a member of X site.

Replies 4 (4)

Liam
Shopify Staff
2731 301 781

Hi Tom,

 

There's a couple ways that you could achieve what you're looking for - in this scenario would all the customers buying products on the site be entered into the customer database on Shopify's side? If so you could set up a system for applying a tag to customers in Shopify when they are on L2 or above. Then you'd create a discount code that would only apply to customers with that tag - customers without the tag would not be able to apply the discount code at the checkout. 

 

Would this work for your use case? 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Tom2024
Shopify Partner
15 0 3

Ah okay so I think I understand what you are saying, however how would I keep it checking for membership status?  The issue would be that the s2 member site is not under our control so the membership status changes from month to month and that is why we do the API check now so when the enter xxxxmember it does the check and then if good, applies it, if not alerts "you are not a member" 

 

It only works if their email is the same on our site too so the customer would already be created.

Liam
Shopify Staff
2731 301 781

You could set up a webhook on Shopify that fires everytime a new customer account is created, which would then trigger an API call to the s2 member site to check if that account has L2+ status, and if so, then apply the tag to the customer that will enable the discount?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Tom2024
Shopify Partner
15 0 3

That would be great, but I would need this to be a live type of thing, they come to checkout, enter in code and let the coupon be applied if L2 or remove coupon if not a member.