Shopify Tutorial - Create a Discount Shopify Function

Поділитися
Вставка
  • Опубліковано 22 лип 2024

КОМЕНТАРІ • 59

  • @stackingcontext
    @stackingcontext  6 місяців тому +5

    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

  • @hacun3jr
    @hacun3jr 7 місяців тому

    Great video keep it up!

  • @tithvorlakmok1365
    @tithvorlakmok1365 20 днів тому

    Thanks for your video. Can you please show how to set up BuyX GetY discount through Shopify function?

  • @FixEcomm
    @FixEcomm 5 місяців тому +1

    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

  • @user-ls2vz3pg3v
    @user-ls2vz3pg3v 6 місяців тому

    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

    • @stackingcontext
      @stackingcontext  6 місяців тому

      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.

  • @yveveke
    @yveveke 8 місяців тому

    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.

    • @stackingcontext
      @stackingcontext  8 місяців тому

      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

  • @nightcode5281
    @nightcode5281 4 місяці тому

    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

  • @borooLIVE
    @borooLIVE 4 місяці тому

    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

    • @stackingcontext
      @stackingcontext  4 місяці тому

      If it's greyed out my guess is that you don't have the necessary permissions to access it in that store.

  • @raymartosido7879
    @raymartosido7879 Місяць тому

    Thanks for this video! Do you have tutorial how to deploy a Shopify function to production store?

    • @stackingcontext
      @stackingcontext  Місяць тому +1

      You can check this video ua-cam.com/video/0QtGnJMZx7E/v-deo.html

  • @robertsheppard9297
    @robertsheppard9297 7 місяців тому

    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
      @stackingcontext  7 місяців тому

      Check the discounts tab in Shopify admin and verify that the discount code you created with Graphql appears there.

  • @nri_raj
    @nri_raj 7 місяців тому

    At last, if product is not eligble can we show the message that MYFUNCTION coupon code is not valid for this order?

    • @stackingcontext
      @stackingcontext  7 місяців тому +1

      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.

    • @nri_raj
      @nri_raj 7 місяців тому

      How about just simple text

  • @fazaljarral2792
    @fazaljarral2792 9 місяців тому

    Possible to not hard code the tag and let user select one via metaobjects?

    • @stackingcontext
      @stackingcontext  9 місяців тому

      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.

  • @user-ub7fl7ny4s
    @user-ub7fl7ny4s 8 місяців тому

    Hey! I have changed the "Scopes" still getting function not found in Graphql App, what should be the issue and solution?

    • @stackingcontext
      @stackingcontext  8 місяців тому

      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.

    • @user-ub7fl7ny4s
      @user-ub7fl7ny4s 8 місяців тому

      @@stackingcontext I am not getting an option to update the app

  • @kemasghanis.7358
    @kemasghanis.7358 3 дні тому

    There are 4 input in product discounts graphql input (cart, discountNode, localization, presentmentCurrencyRate, shop). Can you explain what discountNode for ?

    • @stackingcontext
      @stackingcontext  3 дні тому

      shopify.dev/docs/api/functions/reference/product-discounts/graphql/common-objects/discountnode

    • @kemasghanis.7358
      @kemasghanis.7358 3 дні тому

      @@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

  • @sheetalsharma6299
    @sheetalsharma6299 8 місяців тому

    How to create an order discount app. Can you please help me in creating such app?

    • @stackingcontext
      @stackingcontext  8 місяців тому

      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.

  • @WaqasAli-xs5gf
    @WaqasAli-xs5gf 2 місяці тому

    Hi, is it possible that the discount will automatically apply instead of adding the code or promo ?

    • @stackingcontext
      @stackingcontext  2 місяці тому +1

      Yes, check this video for an example of that
      ua-cam.com/video/wgybzkvC9Q0/v-deo.html

    • @WaqasAli-xs5gf
      @WaqasAli-xs5gf 2 місяці тому

      @@stackingcontext thanks

  • @bruceistired
    @bruceistired 5 місяців тому

    Can this be installed on stores that aren't in developer preview mode?

    • @stackingcontext
      @stackingcontext  5 місяців тому

      Yes, but if you are installing it as a custom app the store must be on Shopify Plus.

    • @bruceistired
      @bruceistired 5 місяців тому

      @@stackingcontext Thank you, do you have any tutorial or resources you can suggest for this?

    • @stackingcontext
      @stackingcontext  5 місяців тому

      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

  • @user-wk3qb1lg1t
    @user-wk3qb1lg1t 8 місяців тому

    value: {
    percentage: {
    // value: 10
    value: userDiscountValue
    }
    How i can dynamically fetch the percentage value where the merchandise has control the discount value.

    • @stackingcontext
      @stackingcontext  8 місяців тому

      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

  • @ditanoviyanti-mv6te
    @ditanoviyanti-mv6te 8 місяців тому

    can I do this to other store, where in that store my role is collaborator?

    • @stackingcontext
      @stackingcontext  8 місяців тому

      If the store is on Shopify Plus you should be able to.

    • @ditanoviyanti-mv6te
      @ditanoviyanti-mv6te 8 місяців тому

      @@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 :(

    • @stackingcontext
      @stackingcontext  8 місяців тому

      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.

    • @ditanoviyanti-mv6te
      @ditanoviyanti-mv6te 8 місяців тому

      @@stackingcontext okey thankyou a lot for your suggestion. Hope you will alwys did a great job in the future.

  • @diego_elohim
    @diego_elohim 5 місяців тому

    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.

    • @stackingcontext
      @stackingcontext  5 місяців тому

      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

    • @diego_elohim
      @diego_elohim 5 місяців тому

      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

  • @muhammadaqibshahzad9494
    @muhammadaqibshahzad9494 8 місяців тому

    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.

    • @stackingcontext
      @stackingcontext  7 місяців тому +1

      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.

  • @virtutu
    @virtutu 6 місяців тому

    Can you do Cart Transform?

    • @stackingcontext
      @stackingcontext  5 місяців тому +1

      I now have a video for it in the channel, check it out here ua-cam.com/video/-T82eX2iLiA/v-deo.html

  • @Perpthegreat
    @Perpthegreat 7 місяців тому

    is 5 discount the limit?

  • @joewho1446
    @joewho1446 7 місяців тому

    how to generate mutation without using graphql app

    • @stackingcontext
      @stackingcontext  7 місяців тому +1

      Use your app's tokens to create an authenticated request to the admin graphql API and run the mutation through it instead.

    • @joewho1446
      @joewho1446 7 місяців тому

      @@stackingcontext Ya thanks I realize that already