FROM CACHE - en_header

Is there a way to check My discount code’s status is Expired or Active using API?

Solved
IngEoGeoBuk
Shopify Partner
4 0 0

Hi there.

Is there a way to check My discount code’s status is Expired or Active using API?

 

스크린샷 2022-11-28 오후 6.36.15.png

 

(ex: ‘czxloikasnjfpois’ status is Active. ‘asdasdassdasdsa’ status is Expired)

 

Thank you.

Accepted Solution (1)

Accepted Solutions
ShopifyDevSup
Shopify Staff
Shopify Staff
520 78 144

This is an accepted solution.

Hi @IngEoGeoBuk 👋

You should be able to check the the status of your discount code using the `codeDiscountNodes` query with a fragment on the `DiscountCode` union type. It should look something like the below: 

{
    codeDiscountNodes (first:10){
        nodes {
            id
            codeDiscount {
                ...DiscountCodes
            }
        }
    }
}

fragment DiscountCodes on DiscountCode {
    ... on DiscountCodeApp {
        status
    }
    ... on DiscountCodeBasic{
        status
    }
    ... on DiscountCodeBxgy{
        status
    }
    ... on DiscountCodeFreeShipping{
        status
    }
}

 

Alternatively, you can filter the `codeDiscountNodes` query by the status (active or expired):

{
    codeDiscountNodes (first:10, query:"status:active"){
        nodes {
            id
        }
    }
}

 

Hope that helps!

 

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

View solution in original post

Replies 2 (2)
ShopifyDevSup
Shopify Staff
Shopify Staff
520 78 144

This is an accepted solution.

Hi @IngEoGeoBuk 👋

You should be able to check the the status of your discount code using the `codeDiscountNodes` query with a fragment on the `DiscountCode` union type. It should look something like the below: 

{
    codeDiscountNodes (first:10){
        nodes {
            id
            codeDiscount {
                ...DiscountCodes
            }
        }
    }
}

fragment DiscountCodes on DiscountCode {
    ... on DiscountCodeApp {
        status
    }
    ... on DiscountCodeBasic{
        status
    }
    ... on DiscountCodeBxgy{
        status
    }
    ... on DiscountCodeFreeShipping{
        status
    }
}

 

Alternatively, you can filter the `codeDiscountNodes` query by the status (active or expired):

{
    codeDiscountNodes (first:10, query:"status:active"){
        nodes {
            id
        }
    }
}

 

Hope that helps!

 

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

IngEoGeoBuk
Shopify Partner
4 0 0