Hello, I am trying to generate discount code on my application. I want to generate some kind of codes that follow the pattern “Buy X get Y”. If I understand correctly it means if you buy item X you get Y for free. I am trying to follow this mutation:
discountCodeBxgyCreate (discountCodeBxgyCreate - GraphQL Admin)
But I am having troubles with “customerBuys.items” where I want to apply it to all my items in my store. But I am getting error “Field: bxgyCodeDiscount,customerBuys,items, Message: Items in ‘customer buys’ must be defined”
Even though in my variable I send to the API I have the following:
customerBuys: {
items: buyProductGid ? {
products: {
productsToAdd: buyProductGid,
}
} : { all: true },
value: {
quantity: "1",
},
},
Basically if buyProductGid is provided then we create the discount when customer buy this item but if not provided then we create for any item in our shop.
The documentation of the mutation mention you can set all in items but it seems like it does not work for some reason?
If anyone can help me with that I would greatly appreciate