I’m building a discount based on GraphQL called Free Gift based on the shipping address. Currently, I’m facing a problem with the DeliveryOutput field in the GraphQL input query. I’ll explain the detail below.
How do I think Shopify Function works? Shopify will run multiple times at the specific event to calculate the discount such as View Cart, Customer Infomation step, and Shipping Address step. Every run will have an input for me to qualify whether the cart info is valid.
For the discount that I’m working on, I need Delivery Address info in the input to qualify for the discount, but the Shopify function only sends in one of those steps I have listed above. Here are some videos and images to help you easier to understand the problem.
Shopify will only apply the last discount run, even if cart info is valid for the discount. Is there any way I can config or fix this issue?
Thank you!
July 6, 2023 at 10:13:05 AM
===============================================INPUT===================================================
{
"presentmentCurrencyRate": "1.0",
"cart": {
"deliveryGroups": [
{
"deliveryAddress": {
"address1": "Test",
"city": "New York",
"countryCode": "VN",
"provinceCode": null,
"zip": "700000"
}
}
],
"cost": {
"subtotalAmount": {
"amount": "150.0"
}
},
"lines": [
{
"id": "gid://shopify/CartLine/0",
"quantity": 1,
"cost": {
"subtotalAmount": {
"amount": "150.0",
"currencyCode": "USD"
}
},
"merchandise": {
"__typename": "ProductVariant",
"id": "gid://shopify/ProductVariant/45255130710328",
"product": {
"id": "gid://shopify/Product/8318842765624",
"handle": "short-leeves-t-shirt",
"productType": "general",
"vendor": "xxx",
"isGiftCard": false
},
"sku": "10"
}
}
]
},
"discountNode": {
"metafield": {
"value": "{\"selectCartBy\":{\"name\":\"ZipCodeQualifier\",\"inputs\":[\"does\",\"match\",\"[\\\"700000\\\"]\"]},\"selectLineItemBy\":{\"name\":\"none\",\"inputs\":[]},\"discount\":{\"name\":\"PercentageDiscount\",\"inputs\":[\"50\",\"\\\"Test\\\"\"]}}"
}
}
}
===============================================OUTPUT===================================================
{ "discountApplicationStrategy": "FIRST", "discounts": [ { "targets": [ { "productVariant": { "id": "gid://shopify/ProductVariant/45255130710328", "quantity": 1 } } ], "value": { "percentage": { "value": "50" } } } ] }
July 6, 2023 at 10:13:06 AM
===============================================INPUT===================================================
{
"presentmentCurrencyRate": "1.0",
"cart": {
"deliveryGroups": [],
"cost": {
"subtotalAmount": {
"amount": "150.0"
}
},
"lines": [
{
"id": "gid://shopify/CartLine/0",
"quantity": 1,
"cost": {
"subtotalAmount": {
"amount": "150.0",
"currencyCode": "USD"
}
},
"merchandise": {
"__typename": "ProductVariant",
"id": "gid://shopify/ProductVariant/45255130710328",
"product": {
"id": "gid://shopify/Product/8318842765624",
"handle": "short-leeves-t-shirt",
"productType": "general",
"vendor": "xxx",
"isGiftCard": false
},
"sku": "10"
}
}
]
},
"discountNode": {
"metafield": {
"value": "{\"selectCartBy\":{\"name\":\"ZipCodeQualifier\",\"inputs\":[\"does\",\"match\",\"[\\\"700000\\\"]\"]},\"selectLineItemBy\":{\"name\":\"none\",\"inputs\":[]},\"discount\":{\"name\":\"PercentageDiscount\",\"inputs\":[\"50\",\"\\\"Test\\\"\"]}}"
}
}
}
===============================================OUTPUT===================================================
{ "discountApplicationStrategy": "FIRST", "discounts": [] }

