BxGy with all products

I want to create an automatic discount where a customer gets a free product on a purchase of $100 or more. I am using the discountAutomaticBxgyCreate mutation. Here’s an example:

mutation CreateBxgyDiscount($automaticBxgyDiscount: DiscountAutomaticBxgyInput!) {
  discountAutomaticBxgyCreate(automaticBxgyDiscount: $automaticBxgyDiscount) {
    automaticDiscountNode {
      id
      automaticDiscount {
        ... on DiscountAutomaticBxgy {
          title
          startsAt
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}

Input variables:

{
  "automaticBxgyDiscount": {
    "title": "Free Product on $100 Purchase",
    "startsAt": "2025-01-01T00:00:00Z",
    "customerBuys": {
      "items": {
        "all": true
      },
      "value": {
        "amount": "100"
      }
    },
    "customerGets": {
      "items": {
        "products": {
          "productVariantsToAdd": [
            "gid://shopify/ProductVariant/39960475140163"
          ]
        }
      },
      "value": {
        "discountOnQuantity": {
          "quantity": "1",
          "effect": {
            "percentage": 1
          }
        }
      }
    },
    "usesPerOrderLimit": "1"
  }
}

I receive the below error:

{
    "data": {
        "discountAutomaticBxgyCreate": {
            "automaticDiscountNode": null,
            "userErrors": [
                {
                    "field": [
                        "automaticBxgyDiscount",
                        "customerBuys",
                        "items"
                    ],
                    "message": "Items in 'customer buys' must be defined"
                }
            ]
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 11,
            "actualQueryCost": 10,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1990,
                "restoreRate": 100.0
            }
        }
    }
}

Does {all: true} not work? Is there an alternate way of doing this?

Same question here as well.

Hi Abhishek,

It sounds like you need to explicitly specify the products, collections, or product variants that qualify under customerBuys.items . Could you retry the mutation but include specific items for “customerBuys”?

Hi @Liam-Shopify,
Thank you for the reply.

Adding specific items in customerBuys would work, but then the API suggest using {all: true} if I want the discount to be applied to all products. That doesn’t work then right?

Can I also extend my understanding that Shopify doesn’t allow Free Product discounts only on cart amount? I have also tried from the store’s admin discount, it doesn’t have this functionality.

Thanks!!