DEV Community

Discussion on: Shopify + Next.js + Tailwind CSS: Modern eCommerce

 
benbalderas profile image
Ben Balderas

I was hoping it would be as easy as adding customAttributes here:

```mutation {
  checkoutCreate(input: {
    lineItems: [{ variantId: "${id}", quantity: ${quantity}, customAttributes: ${customAttributes}}],
  }) {
    checkout {
      id
      webUrl
    }
  }
}```
Enter fullscreen mode Exit fullscreen mode

And passing this as an object with a value from a textfield in the UI:

customAttributes: [{ name: 'Name', value: 'David' }]

But this doesn't seem to work

Thread Thread
 
iskurbanov profile image
iskurbanov • Edited

Hey Ben,

Almost! It has to be a key-value pair, so something like this:

mutation {
  checkoutCreate(input: {
    lineItems: [
      { 
        variantId: "VARIANT_ID",
        quantity: 1
      }
    ],
    customAttributes: [
      {
        key: "Name",
        value: "David"
      }
    ]
  }) {
    checkout {
       id
       webUrl
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

If you click on the [AttributeInput!] it tells you the format: shopify.dev/api/storefront/referen...

Let me know if that helps!

Thread Thread
 
prebenwulff profile image
PrebenWulff

Great! But, now where do I see the custom attributes? I cant see them on the order page.

Great course btw!

Thread Thread
 
iskurbanov profile image
iskurbanov

You should see them on your Shopify admin dashboard under orders.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
prebenww profile image
Preben Wulff

nvm, I figured it out.