Can't create discountAutomaticBxgyCreate with customerBuys all items

Topic summary

A developer is unable to create a BXGY (Buy X Get Y) automatic discount using the Shopify API (2023-07) when setting customerBuys to include all items via allItems: true.

Error encountered:

  • API returns: “Items in ‘customer buys’ must be defined” with error code “BLANK”
  • The mutation fails despite following what appears to be documented syntax

Use case:
Creating a discount where customers receive a discount on a specific product when a minimum purchase amount is reached across all products.

Workaround identified:

  • This configuration is also not possible through the Shopify admin UI
  • Instead, create an “all products” collection (e.g., automatic collection where price > 0)
  • Reference that collection ID in the customerBuys.items.collections field rather than using allItems

Status:
Shopify staff member acknowledged the issue and indicated they would consult the product team to determine if this is expected behavior.

Summarized with AI on November 9. AI used: claude-sonnet-4-5-20250929.

API: 2023-07

Use graphql

Query

mutation discountAutomaticBxgyCreate($automaticBxgyDiscount: DiscountAutomaticBxgyInput!) { discountAutomaticBxgyCreate(automaticBxgyDiscount: $automaticBxgyDiscount) { automaticDiscountNode { id automaticDiscount { ... on DiscountAutomaticBxgy { id createdAt startsAt endsAt status summary title usesPerOrderLimit customerGets { items { ... on DiscountProducts { products(first: 2) { nodes { id } } } } value { ... on DiscountOnQuantity { quantity { quantity } } } } customerBuys { items { ... on AllDiscountItems { allItems } } value { ... on DiscountQuantity { quantity } } } } } } userErrors { field code message } } }

Variables

{
  "automaticBxgyDiscount": {
    "usesPerOrderLimit": "1",
    "startsAt": "2023-06-08T04:52:53-04:00",
    "title": "Minium 2tr get 1 A auto",
    "customerGets": {
      "value": {
        "discountOnQuantity": {
          "quantity": "2",
          "effect": {
            "percentage": 1.0
          }
        }
      },
      "items": {
        "products": {
          "productVariantsToAdd": ["gid://shopify/ProductVariant/45002547069218"]
        }
      }
    },
    "customerBuys": {
      "value": {
        "amount": "2000000"
      },
      "items": {
        "all": true
      }
    }
  }
}

Response

{
    "data": {
        "discountAutomaticBxgyCreate": {
            "automaticDiscountNode": null,
            "userErrors": [
                {
                    "field": [
                        "automaticBxgyDiscount",
                        "customerBuys",
                        "items"
                    ],
                    "code": "BLANK",
                    "message": "Items in 'customer buys' must be defined"
                }
            ]
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 22,
            "actualQueryCost": 10,
            "throttleStatus": {
                "maximumAvailable": 1000.0,
                "currentlyAvailable": 990,
                "restoreRate": 50.0
            }
        }
    }
}
1 Like

Hi Nnthuanspf,

Thanks for flagging this - will get in touch with the product team and see if this is expected behaviour and what the best process would be. What is the exact use case you are trying to achieve here?

Hi, @Liam , thanks for your feedback

I want to create a discount that applies to all products (buy), if the minimum price is reached, the customer will get a discount for a special product.

1 Like

Hi,

I was having the same problem. The documentation does make it look like this should work, but if you try and do it in the admin UI you will also see that this is not possible.

The workaround is to create an “all products” collection (use automatic collection and where price > 0 for example), and then use this id in the collection.add

items: {
    all:false,
    collections:{
          add:["gid://shopify/Collection/ALL_COLLECTION_ID"]
   }
}