DEV Community

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

Collapse
 
benbalderas profile image
Ben Balderas

@iskurbanov Thanks! I think it does help.

Are these "customAttributes" per product? or per cart?

If I purchase your course, does it come with this type of support? 🙂 I'm a bit new to these parts

Thread Thread
 
iskurbanov profile image
iskurbanov

You would add the customAttributes per line item into your cart/checkout.

Definitely! I think after the course you would have a good idea on how to create custom option/variants for your products. We go in-depth with using GraphQL to interact with the Storefront API.

Thread Thread
 
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.