New Shopify Certification now available: Liquid Storefronts for Theme Developers

Can't create discountAutomaticBxgyCreate with customerBuys all items

nnthuanspf
Shopify Partner
4 0 2

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
            }
        }
    }
}
Replies 2 (2)
Liam
Shopify Staff
Shopify Staff
1917 204 580

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?

 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me 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

nnthuanspf
Shopify Partner
4 0 2

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.