Buy X get Y discount with enabled Minimum purchase amount option not return in request

Solved
Highlighted
Shopify Partner
7 0 0

I'm using discount API https://help.shopify.com/en/api/reference/discounts/discountcode#show-2020-01 and try to get the location of discount code "Buy X get Y" with Minimum purchase amount enabled option with a request like GET /admin/api/2020-01/discount_codes/lookup.json?code=SUMMERSALE10OFF. And in response, I get that there is no such code. But if I change this option to Minimum quantity of items it returns the correct location of this discount.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
493 98 88

This is an accepted solution.

Hi @alex_gonor 

 

As this is a newer feature, the minimum $ purchase BXGY is only returned on the GraphQL Admin API. 

 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


1 Like
Highlighted
New Member
1 0 0

Ok well here is an example  as we all know buy x get y does not auto add the y product to the cart so people are left to do this for them selfs ... 

related:

https://community.shopify.com/c/Shopify-Apps/Buy-X-Get-Y/td-p/427926
and 
https://community.shopify.com/c/Shopify-Discussion/Automatic-Discount-Buy-X-Get-Y-Automatically-add-...

we don't want or don't like the answers "there is an app for that". as don't want to spend money per month indefinitely on something that should be a simple fix .
so the option is to make a private app that will hook in to the discount code system to auto add the product in question  to the cart if eligible ... 

the only issue is  when using the graphQL  "items" are empty 

 

example 

query {
  codeDiscountNodeByCode(code: "SOMECODE") {
    id
    codeDiscount() {
      __typename
      ... on DiscountCodeBxgy {
          title
        status
        endsAt
        summary
        asyncUsageCount
        usageLimit
        customerGets {
          items // <-- = NONE so cant then do any thing like add item to cart :(
        }
      }
    }
 }
}

 
responce .... 

{
  "data": {
    "codeDiscountNodeByCode": {
      "id": "gid://shopify/DiscountCodeNode/XXX",
      "codeDiscount": {
        "__typename": "DiscountCodeBxgy",
        "title": "somecode",
        "status": "ACTIVE",
        "endsAt": null,
        "summary": "the expected summery ",
        "asyncUsageCount": 51,
        "usageLimit": null,
        "customerGets": {
          "items": {} <!-- no items 
        }
      }
    }
  },
  "extensions": {
    "cost": {
  

have tried this with 

https://XX.myshopify.com/admin/api/2020-01/graphql.json
https://XX.myshopify.com/admin/api/2020-04/graphql.json

what are the suggestions for getting over this issue. is there any working examples of accomplishing this ?

0 Likes