UPDATE: Starting with Shopify CLI 3.53 you no longer need to install the GraphiQL app in your store to run the create discount query as GraphiQL comes now built in with the CLI. Check this video out where you can see how to do those steps using the built-in editor ua-cam.com/video/IU9K5evDsEA/v-deo.html
Thanks for this tutorial! My idea is to create an app to manage store credit per customer. This store credit should be always applied automatically as a discount on checkout to the whole cart. Once the order is paid, the store credit for this customer must be updated (take away the credit used in the order). Based on your tutorial and some comments here I think I should create a customer metafield to store credit balance (apart from the prisma db that I use to track activity) so I can dynamically apply this value on the checkout. My question is how'd you update the credit balance after the order is placed? Is there a way to be notified if the discount was really applied? Thank you
Shopify has webhooks, you can subscribe to the order create webhook and from your server get notified when an order is created, Shopify will give you there the id of the order. With that you can use the id to query the admin api and see what discount was applied to that order, if it's your app's discount then update the metafield and your app's db as needed.
Is it possible to tag some clients as VIP. And give an automatic discount of 10% on their ordered products or all the products in the store through this way? And thank you for the tutorials. I'm glad I've found them. Keep up the good work.
You should be able to. Through the Input query you can get the customer and from the customer you can query if they have the VIP tag using hasAnyTag, here are the docs for that shopify.dev/docs/api/functions/reference/product-discounts/graphql/common-objects/customer That being said, you can create a Customer Segment that only includes customers with the VIP tag and then create a regular discount through Shopify's Admin that targets customers in that segment. When creating a discount you'd have to select under Customer eligibility the "Specific customer segments" option and there select your VIP segment. This documentation page may help help.shopify.com/en/manual/customers/customer-segmentation/customer-segments/customer-segments-managing
Your explanation is amazing and tried to create a shopify UI extension but how to get the coupon code value when it is not a valid one. Which function or hook i need to use? And i want to use only default text box and button of shopify checkout Currently i am trying to call applydiscountcodechange and usediscount code but these hooks give me only applied coupon code i want which are not valid and cuustomer trying to apply them Thank you in advance
Hi! in 21:02 you have access for data records, I have access to this data too but only in developer store, but when I have installed shipping discount app on external store I can't check data because row in the table is grayed out. Do you know why? Thank you
I generated distribution link to install it on other production stroes, App is installed, graphql generated, but when I enter coupon code it is not applied. I am not sure what I am doing wrong? Can you please help?
With Shopify Functions alone I don't think it is possible, but if you create a checkout UI extension there's a way to see the applied discount codes with the DiscountCode API shopify.dev/docs/api/checkout-ui-extensions/2023-10/apis/discounts, you could try reading that value to check what discount codes are being applied and render a message on the items that don't apply.
Try running the npm run shopify app config push command and make sure you update your app afterwards so Shopify detects that the scope has been updated. If that didn't solve it run the query shown in the video and make sure you see your function in the response.
There are 4 input in product discounts graphql input (cart, discountNode, localization, presentmentCurrencyRate, shop). Can you explain what discountNode for ?
@@stackingcontextthank you for reply my question and i really appreicate it, but there is not explanation in that documentation, i really confused there is just has metafield, but we know there is no metafield in the discount
Shopify has a step by step tutorial where that is covered shopify.dev/docs/apps/selling-strategies/discounts/experience, there they create a Product Discount App but the steps are very similar for an Order Discount App.
Check minute 29:08 of this video where I go over how to deploy the extension I built there. The process should be roughly the same for the function in this video as they both use Shopify's simplified deployment. ua-cam.com/video/L-Kyx-pRoY/v-deo.html More info on simplified deployment: shopify.dev/docs/apps/deployment/app-versions/deploy
value: { percentage: { // value: 10 value: userDiscountValue } How i can dynamically fetch the percentage value where the merchandise has control the discount value.
The simplest solution for that is to create a Shop metafield where the userDiscountValue is stored, then you query that from your function and use it. To easily create and edit Shop Metafields you'll need to use an app like Metafield Guru because currently they are not available from the Settings menu as the other metafields are. If you want to build something more robust check out this Shopify tutorial where that is addressed shopify.dev/docs/apps/selling-strategies/discounts/experience/ui
@@stackingcontext the store just the basic plan, so this way not able for other store if the store not shopify plus? I try to custom distribute to that store, but after install the app and run the code for show us list the shopify function on graphql, I can't find my function :(
Unfortunately custom Shopify Functions are only available in Shopify Plus as mentioned in their documentation here shopify.dev/docs/apps/functions So I think your best option if upgrading to that plan is not a possibility is to check Shopify's App Store to see if there's an app that does what you're trying to do, as apps that use Shopify Functions installed from Shopify's App Store can be installed on any store as referenced in the same documentation I linked above.
How could I do to apply a new discount when a automatic discount has been applied? How do I get the discount that has been applied in order to put it into the discounts array ? thx.
To interact with the discounts the customer has applied you'll need a Checkout UI Extension instead. This video might help ua-cam.com/video/YyKwAkGopHg/v-deo.html
Thx , but from a Checkout UI Extension, when I get the discount code that the client got applied, how can i get that code into the run.ts file (shopify function)?@@stackingcontext
I am facing one big issue and can not understand how to achieve Gift Card Balancer What do you say about this top for a new video For now, we can create gift cards and send them to customer Customers should have a public page to check the remaining balance of gift cards by entering the email ID and last 4 digits of the gift card into the balance checker form.
I have a video about this planned for the future, but in the meantime check help.shopify.com/en/manual/products/gift-card-products/faq#how-do-customers-check-their-balance as what you're describing is already offered by Shopify out of the box.
UPDATE:
Starting with Shopify CLI 3.53 you no longer need to install the GraphiQL app in your store to run the create discount query as GraphiQL comes now built in with the CLI. Check this video out where you can see how to do those steps using the built-in editor ua-cam.com/video/IU9K5evDsEA/v-deo.html
Great video keep it up!
Thanks for your video. Can you please show how to set up BuyX GetY discount through Shopify function?
very good video .. One of the things I don't like about shopify is that they don't show how to put things together like this video
Thanks for this tutorial! My idea is to create an app to manage store credit per customer. This store credit should be always applied automatically as a discount on checkout to the whole cart. Once the order is paid, the store credit for this customer must be updated (take away the credit used in the order). Based on your tutorial and some comments here I think I should create a customer metafield to store credit balance (apart from the prisma db that I use to track activity) so I can dynamically apply this value on the checkout. My question is how'd you update the credit balance after the order is placed? Is there a way to be notified if the discount was really applied? Thank you
Shopify has webhooks, you can subscribe to the order create webhook and from your server get notified when an order is created, Shopify will give you there the id of the order. With that you can use the id to query the admin api and see what discount was applied to that order, if it's your app's discount then update the metafield and your app's db as needed.
Is it possible to tag some clients as VIP. And give an automatic discount of 10% on their ordered products or all the products in the store through this way?
And thank you for the tutorials. I'm glad I've found them. Keep up the good work.
You should be able to. Through the Input query you can get the customer and from the customer you can query if they have the VIP tag using hasAnyTag, here are the docs for that shopify.dev/docs/api/functions/reference/product-discounts/graphql/common-objects/customer
That being said, you can create a Customer Segment that only includes customers with the VIP tag and then create a regular discount through Shopify's Admin that targets customers in that segment. When creating a discount you'd have to select under Customer eligibility the "Specific customer segments" option and there select your VIP segment. This documentation page may help help.shopify.com/en/manual/customers/customer-segmentation/customer-segments/customer-segments-managing
Your explanation is amazing and tried to create a shopify UI extension but how to get the coupon code value when it is not a valid one. Which function or hook i need to use?
And i want to use only default text box and button of shopify checkout
Currently i am trying to call applydiscountcodechange and usediscount code but these hooks give me only applied coupon code i want which are not valid and cuustomer trying to apply them
Thank you in advance
Hi! in 21:02 you have access for data records, I have access to this data too but only in developer store, but when I have installed shipping discount app on external store I can't check data because row in the table is grayed out. Do you know why? Thank you
If it's greyed out my guess is that you don't have the necessary permissions to access it in that store.
Thanks for this video! Do you have tutorial how to deploy a Shopify function to production store?
You can check this video ua-cam.com/video/0QtGnJMZx7E/v-deo.html
I generated distribution link to install it on other production stroes, App is installed, graphql generated, but when I enter coupon code it is not applied. I am not sure what I am doing wrong? Can you please help?
Check the discounts tab in Shopify admin and verify that the discount code you created with Graphql appears there.
At last, if product is not eligble can we show the message that MYFUNCTION coupon code is not valid for this order?
With Shopify Functions alone I don't think it is possible, but if you create a checkout UI extension there's a way to see the applied discount codes with the DiscountCode API shopify.dev/docs/api/checkout-ui-extensions/2023-10/apis/discounts, you could try reading that value to check what discount codes are being applied and render a message on the items that don't apply.
How about just simple text
Possible to not hard code the tag and let user select one via metaobjects?
Yes, that's also a way to do it. You could create an app metafield of type metaobject with the admin API and then associate the metaobject that way.
Hey! I have changed the "Scopes" still getting function not found in Graphql App, what should be the issue and solution?
Try running the npm run shopify app config push command and make sure you update your app afterwards so Shopify detects that the scope has been updated.
If that didn't solve it run the query shown in the video and make sure you see your function in the response.
@@stackingcontext I am not getting an option to update the app
There are 4 input in product discounts graphql input (cart, discountNode, localization, presentmentCurrencyRate, shop). Can you explain what discountNode for ?
shopify.dev/docs/api/functions/reference/product-discounts/graphql/common-objects/discountnode
@@stackingcontextthank you for reply my question and i really appreicate it, but there is not explanation in that documentation, i really confused there is just has metafield, but we know there is no metafield in the discount
How to create an order discount app. Can you please help me in creating such app?
Shopify has a step by step tutorial where that is covered shopify.dev/docs/apps/selling-strategies/discounts/experience, there they create a Product Discount App but the steps are very similar for an Order Discount App.
Hi, is it possible that the discount will automatically apply instead of adding the code or promo ?
Yes, check this video for an example of that
ua-cam.com/video/wgybzkvC9Q0/v-deo.html
@@stackingcontext thanks
Can this be installed on stores that aren't in developer preview mode?
Yes, but if you are installing it as a custom app the store must be on Shopify Plus.
@@stackingcontext Thank you, do you have any tutorial or resources you can suggest for this?
Check minute 29:08 of this video where I go over how to deploy the extension I built there. The process should be roughly the same for the function in this video as they both use Shopify's simplified deployment.
ua-cam.com/video/L-Kyx-pRoY/v-deo.html
More info on simplified deployment: shopify.dev/docs/apps/deployment/app-versions/deploy
value: {
percentage: {
// value: 10
value: userDiscountValue
}
How i can dynamically fetch the percentage value where the merchandise has control the discount value.
The simplest solution for that is to create a Shop metafield where the userDiscountValue is stored, then you query that from your function and use it.
To easily create and edit Shop Metafields
you'll need to use an app like Metafield Guru because currently they are not available from the Settings menu as the other metafields are.
If you want to build something more robust check out this Shopify tutorial where that is addressed shopify.dev/docs/apps/selling-strategies/discounts/experience/ui
can I do this to other store, where in that store my role is collaborator?
If the store is on Shopify Plus you should be able to.
@@stackingcontext the store just the basic plan, so this way not able for other store if the store not shopify plus?
I try to custom distribute to that store, but after install the app and run the code for show us list the shopify function on graphql, I can't find my function :(
Unfortunately custom Shopify Functions are only available in Shopify Plus as mentioned in their documentation here shopify.dev/docs/apps/functions
So I think your best option if upgrading to that plan is not a possibility is to check Shopify's App Store to see if there's an app that does what you're trying to do, as apps that use Shopify Functions installed from Shopify's App Store can be installed on any store as referenced in the same documentation I linked above.
@@stackingcontext okey thankyou a lot for your suggestion. Hope you will alwys did a great job in the future.
How could I do to apply a new discount when a automatic discount has been applied? How do I get the discount that has been applied in order to put it into the discounts array ? thx.
To interact with the discounts the customer has applied you'll need a Checkout UI Extension instead. This video might help
ua-cam.com/video/YyKwAkGopHg/v-deo.html
Thx , but from a Checkout UI Extension, when I get the discount code that the client got applied, how can i get that code into the run.ts file (shopify function)?@@stackingcontext
I am facing one big issue and can not understand how to achieve
Gift Card Balancer
What do you say about this top for a new video
For now, we can create gift cards and send them to customer
Customers should have a public page to check the remaining balance of gift cards by entering the email ID and last 4 digits of the gift card into the balance checker form.
I have a video about this planned for the future, but in the meantime check help.shopify.com/en/manual/products/gift-card-products/faq#how-do-customers-check-their-balance as what you're describing is already offered by Shopify out of the box.
Can you do Cart Transform?
I now have a video for it in the channel, check it out here ua-cam.com/video/-T82eX2iLiA/v-deo.html
is 5 discount the limit?
No, just an example
how to generate mutation without using graphql app
Use your app's tokens to create an authenticated request to the admin graphql API and run the mutation through it instead.
@@stackingcontext Ya thanks I realize that already