Solved

Delivery Customization API - Cart attributes

sebastiandev
Shopify Partner
58 1 20

Hi,

I would like to condition the display of the shipping method in the cart based on cart attributes. I don't quite understand how it works and how it can be done.

 

query Input {
    cart {
        attribute {
            key
            value
        }
        deliveryGroups {
            deliveryAddress {
                provinceCode
            }
            deliveryOptions {
                handle
                code
                cost {
                    amount
                    currencyCode
                }
                title
                description
            }
        }
    }
}

And in delivery input I have null for attributes:

{
  "cart": {
    "attribute": null,
    "deliveryGroups": [
      {
        "deliveryAddress": {
          "provinceCode": null
        },
        "deliveryOptions": [
          ....
        ]
      }
    ]
  }
}

Exists any way to gets cart attributes?

{
  "token": "",
  "note": null,
  "attributes": {
    "test": "yes"
  },
  "items": [
    ...
  ],
  ...
}

 

Accepted Solution (1)

Nick_Wesselman
Shopify Staff
167 41 64

This is an accepted solution.

Hi @sebastiandev -- When querying `attribute`, you should provide the `key` argument.

Nick Wesselman | 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 the Shopify Help Center or the Shopify Blog

View solution in original post

Reply 1 (1)

Nick_Wesselman
Shopify Staff
167 41 64

This is an accepted solution.

Hi @sebastiandev -- When querying `attribute`, you should provide the `key` argument.

Nick Wesselman | 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 the Shopify Help Center or the Shopify Blog