Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Automatically Apply Discount for VIP Customers

Automatically Apply Discount for VIP Customers

mark_macrae_
Shopify Partner
11 1 6

I've seen a similar question being asked about giving specific customers an automatic discount, but no clear solution to the problem has been posted that I can see.

Shopify provides by default the "Automatic Discount", but unlike promo codes, for some reason you cannot create an automatic discount that applies to groups of customers.

So fine.  I am creating a Custom App in order to try to accomplish this.

Before I spend a week or two going down a rabbit hole that won't work, I thought I would put it to this community to weigh-in on the relative stupidity of the ideas I have come up with:

Idea #1:

  1. Create a webhook to fire off on the createCheckout action.
  2. The webhook responder will (somehow??) figure out which customer created the checkout, query the app's own database to find the discount rate for that customer then use Discount API to create a one-time use promo code on Shopify
  3. Use PUT /admin/api/2021-04/checkouts/{token}.json  from the Sales Channel API to update the Checkout with the one-time use discount code.

Idea #2:

  1. Use script tags?? It seems theoretically possible use script tags to inserts JavaScript on the store based on which customer is logged in.
  2. Basically do the same as above: somehow figure out which customer this is and create a one-time use Promo Code based on their discount
  3. Using our Script Tag javascript, reload the customer's browser with the Shopify discount URL shortcut "/discount/{one-time-use-promo-code}" added to the shop URL

Neither of these solutions seems particularly robust.  I have also read that webhooks don't reliably get received within any particular timeframe, so I don't know that I could rely upon them to be fast enough to update the checkout before the customer actually checks out.  Using javascript to reload the page with a discount code just seems kludge-y.

Am I missing something?  Is there an obvious better way to do this? Should we have used WooCommerce after all??

 

Reply 1 (1)

mark_macrae_
Shopify Partner
11 1 6

My post was marked as "spam" for the first day, so giving it a bump - hopefully gets some views.