FunctionID In DiscountAutomaticAppCreate

Solved

FunctionID In DiscountAutomaticAppCreate

Thegraske
Shopify Partner
8 0 0

Hello,

I'm using graphQL with discountAutomaticAppCreate query but it keeps saying that my function is not found.

What is the functionId and where do I find it?

Accepted Solution (1)

Hamza_Hussain
Shopify Partner
56 6 13

This is an accepted solution.

When you are done with coding of function you have to deploy the app on to your store. Once you have deployed it. In you .env file the app will create a function id of that Shopify Function and then you can use discountAutomaticAppCreate make the mutation the file should be like the below image

 

Hamza_Hussain_0-1710328963977.png

        `#graphql
        mutation discountAutomaticAppCreate($automaticAppDiscount: DiscountAutomaticAppInput!) {
          discountAutomaticAppCreate(automaticAppDiscount: $automaticAppDiscount) {
            userErrors {
              field
              message
            }
            automaticAppDiscount {
              discountId
              title
              startsAt
              endsAt
              status
              appDiscountType {
                appKey
                functionId
              }
            }
          }
        }`,
        {
            variables: {
                automaticAppDiscount: {
                    title: discount_title,
                    functionId: "you function id goes here",
                    startsAt: enter a starting date it is compulsory
                    endsAt: null,
                }
            },
        },
    );
Honey G Hamza

View solution in original post

Replies 4 (4)

Hamza_Hussain
Shopify Partner
56 6 13

This is an accepted solution.

When you are done with coding of function you have to deploy the app on to your store. Once you have deployed it. In you .env file the app will create a function id of that Shopify Function and then you can use discountAutomaticAppCreate make the mutation the file should be like the below image

 

Hamza_Hussain_0-1710328963977.png

        `#graphql
        mutation discountAutomaticAppCreate($automaticAppDiscount: DiscountAutomaticAppInput!) {
          discountAutomaticAppCreate(automaticAppDiscount: $automaticAppDiscount) {
            userErrors {
              field
              message
            }
            automaticAppDiscount {
              discountId
              title
              startsAt
              endsAt
              status
              appDiscountType {
                appKey
                functionId
              }
            }
          }
        }`,
        {
            variables: {
                automaticAppDiscount: {
                    title: discount_title,
                    functionId: "you function id goes here",
                    startsAt: enter a starting date it is compulsory
                    endsAt: null,
                }
            },
        },
    );
Honey G Hamza
tyuzu
Shopify Partner
24 0 0

Does the function id automatically be added on the .env file ? or I will manually add it based on the shopify partners dashboard ?

Hamza_Hussain
Shopify Partner
56 6 13

When You deploy the app after creating the discount function the app automatically creates a discount ID then you can use that by writing

process.env.SHOPIFY_CQ_PRODUCT_DISCOUNT_ID
Honey G Hamza
tyuzu
Shopify Partner
24 0 0

Found it. Thank you so much.