Shopify Tutorial - Create a Discount Shopify Function

Поделиться
HTML-код
  • Опубликовано: 9 янв 2025

Комментарии •

  • @stackingcontext
    @stackingcontext  Год назад +7

    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

  • @jaimesanchezgalvis
    @jaimesanchezgalvis 4 месяца назад

    Amazing video and explanation! Your insights really clarified everything for me. Thank you so much for sharing your expertise!

  • @FixEcomm
    @FixEcomm 11 месяцев назад +2

    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

  • @priyankadasila1129
    @priyankadasila1129 3 месяца назад

    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.

  • @tithvorlakmok1365
    @tithvorlakmok1365 6 месяцев назад

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

  • @akilvarl1725
    @akilvarl1725 3 месяца назад

    Can I add this application to my live website?, thank you :)

  • @hacun3jr
    @hacun3jr Год назад

    Great video keep it up!

  • @raymartosido7879
    @raymartosido7879 7 месяцев назад

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

    • @stackingcontext
      @stackingcontext  6 месяцев назад +1

      You can check this video ruclips.net/video/0QtGnJMZx7E/видео.html

  • @borooLIVE
    @borooLIVE 10 месяцев назад

    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  10 месяцев назад

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

  • @FabianMartinez-d7j
    @FabianMartinez-d7j Год назад

    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  Год назад

      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.

  • @nightcode5281
    @nightcode5281 10 месяцев назад

    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

  • @yveveke
    @yveveke Год назад

    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  Год назад

      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

  • @omarguzman1112
    @omarguzman1112 3 месяца назад

    If hasLimitedEditionTag === false wouldn't it NOT return that item?

  • @kemasghanis.7358
    @kemasghanis.7358 5 месяцев назад

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

    • @stackingcontext
      @stackingcontext  5 месяцев назад

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

    • @kemasghanis.7358
      @kemasghanis.7358 5 месяцев назад

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

  • @teaman7v
    @teaman7v Месяц назад

    my hero

  • @MusicChanelMetall
    @MusicChanelMetall 27 дней назад

    Hello. Can the created discount be applied automatically? I want to create a free shipping and apply it on the checkout page

    • @stackingcontext
      @stackingcontext  22 дня назад

      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

  • @george480
    @george480 4 месяца назад

    Is this only compatible with Shopify Plus or any plan? I keep getting "No Organization Found" error.

    • @stackingcontext
      @stackingcontext  4 месяца назад

      Only stores on a Shopify Plus plan can use custom apps that contain Shopify Function APIs.

  • @pravinchhasatiya7607
    @pravinchhasatiya7607 5 месяцев назад

    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.

    • @dollydey8273
      @dollydey8273 4 месяца назад

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

  • @nri_raj
    @nri_raj Год назад

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

    • @stackingcontext
      @stackingcontext  Год назад +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 Год назад

      How about just simple text

  • @virtutu
    @virtutu Год назад

    Can you do Cart Transform?

    • @stackingcontext
      @stackingcontext  11 месяцев назад +1

      I now have a video for it in the channel, check it out here ruclips.net/video/-T82eX2iLiA/видео.html

  • @robertsheppard9297
    @robertsheppard9297 Год назад

    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  Год назад

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

  • @WaqasAli-xs5gf
    @WaqasAli-xs5gf 8 месяцев назад

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

    • @stackingcontext
      @stackingcontext  8 месяцев назад

      Yes, check this video for an example of that
      ruclips.net/video/wgybzkvC9Q0/видео.html

    • @WaqasAli-xs5gf
      @WaqasAli-xs5gf 7 месяцев назад

      @@stackingcontext thanks

  • @ditanoviyanti-mv6te
    @ditanoviyanti-mv6te Год назад

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

    • @stackingcontext
      @stackingcontext  Год назад

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

    • @ditanoviyanti-mv6te
      @ditanoviyanti-mv6te Год назад

      @@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  Год назад

      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 Год назад

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

  • @sheetalsharma6299
    @sheetalsharma6299 Год назад

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

    • @stackingcontext
      @stackingcontext  Год назад

      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.

  • @fazaljarral2792
    @fazaljarral2792 Год назад

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

    • @stackingcontext
      @stackingcontext  Год назад

      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.

  • @bruceistired
    @bruceistired 10 месяцев назад

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

    • @stackingcontext
      @stackingcontext  10 месяцев назад

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

    • @bruceistired
      @bruceistired 10 месяцев назад

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

    • @stackingcontext
      @stackingcontext  10 месяцев назад

      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

  • @SheetalSharma-q1e
    @SheetalSharma-q1e Год назад

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

    • @stackingcontext
      @stackingcontext  Год назад

      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.

    • @SheetalSharma-q1e
      @SheetalSharma-q1e Год назад

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

  • @diego_elohim
    @diego_elohim 10 месяцев назад

    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  10 месяцев назад

      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

    • @diego_elohim
      @diego_elohim 10 месяцев назад

      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

  • @TahaAhmed-t5l
    @TahaAhmed-t5l Год назад

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

    • @stackingcontext
      @stackingcontext  Год назад

      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

  • @Perpthegreat
    @Perpthegreat Год назад

    is 5 discount the limit?

  • @muhammadaqibshahzad9494
    @muhammadaqibshahzad9494 Год назад

    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  Год назад +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.

  • @resulterror2381
    @resulterror2381 5 месяцев назад

    thank you

  • @joewho1446
    @joewho1446 Год назад

    how to generate mutation without using graphql app

    • @stackingcontext
      @stackingcontext  Год назад +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 Год назад

      @@stackingcontext Ya thanks I realize that already