Discussing Shopify Functions development, deployment, and usage in Shopify apps.
How can I get multiple cart attributes in input.graphql? the current solution is single attributes; the following is my code, but my requirements are to check various attributes. We are using the delivery customization function.
attribute(key:"attribute name"){
value
}
Hey @Ecommerce5
Try using aliases:
something: attribute(key:"something"){
value
}
another: attribute(key:"another"){
value
}
Scott | Developer Advocate @ Shopify
The solution seems legitimate as I was able to run the type gen command using aliases. But again I am facing an issue with output.
This is the output I get in my following code.
query Input {
cart {
orderSat: attribute(key:"Ordered saturday"){
value
}
discountCode: attribute(key:"Discount Code"){
value
}
deliveryGroups {
deliveryAddress {
provinceCode
zip
}
deliveryOptions {
handle
title
cost{
amount
}
}
}
cost {
subtotalAmount {
amount
}
}
}
}
could you explain why I am not getting proper results?
attributes under my cart form:
<input id="hasdiscount" type="hidden" name="attributes[Discount Code]" value="Welcome" >
Hey @Ecommerce5
You should be able to get discount codes via cart.discountCodes.
Scott | Developer Advocate @ Shopify