New Shopify Certification now available: Liquid Storefronts for Theme Developers

Shopify function - Delivery customization

Ecommerce5
Shopify Partner
11 0 2

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
}

Replies 3 (3)
SBD_
Shopify Staff
Shopify Staff
1671 235 346

Hey @Ecommerce5 

 

Try using aliases:

 

something: attribute(key:"something"){
  value
}
another: attribute(key:"another"){
  value
}

Scott | Developer Advocate @ Shopify 

Ecommerce5
Shopify Partner
11 0 2

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. 

Ecommerce5_0-1688724611833.png

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" >

SBD_
Shopify Staff
Shopify Staff
1671 235 346

Hey @Ecommerce5

 

You should be able to get discount codes via cart.discountCodes.

Scott | Developer Advocate @ Shopify