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 ruclips.net/video/IU9K5evDsEA/видео.html
Thanks for the tutorial. I want to provide discount to the customer that has "Employee" tag and check if product has specific tag like "OFF50", "OFF30" and "OFF20" then provide the 50%, 30% and 20% off on the line items based on tag . How can I check product has specific tag.
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
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.
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
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
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
Yes, use the discountAutomaticAppCreate mutation when creating the discount and it should work as an automatic discount. shopify.dev/docs/api/admin-graphql/2024-10/mutations/discountAutomaticAppCreate
We have successfully created an app and its working as expected, however our shipping app is not able to get the discounted rate , is it because the discout is applied using this app ? we are currently working on migrating script editor app discount script to Shopify function.
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.
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?
@@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.
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. ruclips.net/video/L-Kyx-pRoY/видео.html More info on simplified deployment: shopify.dev/docs/apps/deployment/app-versions/deploy
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.
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 ruclips.net/video/YyKwAkGopHg/видео.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
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
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 ruclips.net/video/IU9K5evDsEA/видео.html
Amazing video and explanation! Your insights really clarified everything for me. Thank you so much for sharing your expertise!
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 the tutorial. I want to provide discount to the customer that has "Employee" tag and check if product has specific tag like "OFF50", "OFF30" and "OFF20" then provide the 50%, 30% and 20% off on the line items based on tag . How can I check product has specific tag.
Thanks for your video. Can you please show how to set up BuyX GetY discount through Shopify function?
Can I add this application to my live website?, thank you :)
Great video keep it up!
Thanks for this video! Do you have tutorial how to deploy a Shopify function to production store?
You can check this video ruclips.net/video/0QtGnJMZx7E/видео.html
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 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.
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
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
If hasLimitedEditionTag === false wouldn't it NOT return that item?
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
my hero
Hello. Can the created discount be applied automatically? I want to create a free shipping and apply it on the checkout page
Yes, use the discountAutomaticAppCreate mutation when creating the discount and it should work as an automatic discount.
shopify.dev/docs/api/admin-graphql/2024-10/mutations/discountAutomaticAppCreate
Is this only compatible with Shopify Plus or any plan? I keep getting "No Organization Found" error.
Only stores on a Shopify Plus plan can use custom apps that contain Shopify Function APIs.
We have successfully created an app and its working as expected, however our shipping app is not able to get the discounted rate , is it because the discout is applied using this app ? we are currently working on migrating script editor app discount script to Shopify function.
── external error ─────────────────────────────────────────
Error coming from `C:/Users/admin/AppData/Roaming/nvm/v20.11.0/node_modules/@shopify/cli/bin/javy compile -d -o
C:/Users/satyajeet/Desktop/Amit/kolkata/shopify_App/Discount-app-2sep/productdiscount-app/product-discount-app/extensions/product-discount-demo/dist/function.wasm
dist/function.js --wit C:/Users/SATYAJ~1/AppData/Local/Temp/296900423c3e9173af547dddb3ffdecd/javy-world.wit -n
shopify-function`
please help me
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
Can you do Cart Transform?
I now have a video for it in the channel, check it out here ruclips.net/video/-T82eX2iLiA/видео.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.
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
ruclips.net/video/wgybzkvC9Q0/видео.html
@@stackingcontext thanks
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 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.
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.
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.
ruclips.net/video/L-Kyx-pRoY/видео.html
More info on simplified deployment: shopify.dev/docs/apps/deployment/app-versions/deploy
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
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
ruclips.net/video/YyKwAkGopHg/видео.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
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
is 5 discount the limit?
No, just an example
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.
thank you
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