codeDiscountNodealways returns null using grapgql

Solved

codeDiscountNodealways returns null using grapgql

agandhicb
Shopify Partner
10 1 0

Hi,

So I have created Shopify app using functions and Discount code created. Now when I am trying to get Discount code using Graphql it always return null. I am using "codeDiscountNode" and discount code gid to get discount code using Graphql.

Can anyone please help why it is always returning null.

agandhicb_0-1702908936365.png

 

Accepted Solution (1)
agandhicb
Shopify Partner
10 1 0

This is an accepted solution.

So for anyone who is trying to find I used code of `app.volume-discount.$functionId.$id.jsx` from here https://github.com/Shopify/function-examples/tree/main/sample-apps/discounts/app/routes and its working for me.

Thanks.

View solution in original post

Replies 6 (6)

Liam
Shopify Staff
2846 311 811

Hi Agandhicb,

 

Do you have the read_discounts access scope enabled?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

agandhicb
Shopify Partner
10 1 0

Hi Liam,

 

Thanks for helping me.

App which I created have read_discounts scope in shopify.app.toml file. Screenshot below.
Do I have to enable read_discounts somewhere else?

agandhicb_0-1702913691648.png

 

Thank

Ankur

agandhicb
Shopify Partner
10 1 0

Also I found that discount code created by app are returning null. If I used same graphql with other discount code (Not created by app) then it is returning results.

Liam
Shopify Staff
2846 311 811

Which app is creating the discounts? It sounds like there could be some implementation issue related to the discounts created by an app (or permissions issue). Are there any errors being logged?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

agandhicb
Shopify Partner
10 1 0

Hi Liam,

Thanks for reply.

I have created shopify app which discount products If quantity is 3 or more in cart.

I have created this app using https://shopify.dev/docs/apps/selling-strategies/discounts/experience/getting-started

I can create discount code and discount code is applied to cart properly. Now as we have add discount code feature in admin side, I just want to edit discount code for my app and So I am trying to get discount code details using Graphql

In short I am trying to make "app.volume-discount-one.$functionId.$id.jsx" file work to edit discount code and it is not working.

I have checked and no errors logged (Screenshot below)

agandhicb_0-1703076371474.png


Below is screenshot which shows scopes for app I have created

agandhicb_1-1703076444864.png


THanks for help, I am stuck here and not able to figure out how to edit discount coupon created by my app using interface created in my app.

Thanks.

agandhicb
Shopify Partner
10 1 0

This is an accepted solution.

So for anyone who is trying to find I used code of `app.volume-discount.$functionId.$id.jsx` from here https://github.com/Shopify/function-examples/tree/main/sample-apps/discounts/app/routes and its working for me.

Thanks.