Storefront API Custom field for checkout

Highlighted
New Member
1 0 0

Good day,

I am currently developing a React application and connected your graphql Storefront API.

I have unauthenticated_write_checkouts, unauthenticated_read_checkouts enabled.

 

I require some custom values sent with the order which can be seen on the order overview page.

For example, I require to know if a customer chose the physical or digital version of a given, dynamic product. Adding variants is not an option.

 

I have seen that there is a customAttributes parameter you can give. I've tried it, but the values do not seem to show up.

Is there any way to send tags with the checkout?

 

My current code:

fragment CheckoutFragment on Checkout {
    id
    webUrl
    totalTax
    subtotalPrice
    customAttributes{
      key
      value
    }
    totalPrice
    lineItems (first: 250) {
      edges {
        node {
          id
          title
          variant {
            id
            title
            image {
              src
            }
            price
          }
          quantity
        }
      }
    }
  }
export const checkoutAttributesUpdateInput = gql`
  mutation checkoutAttributesUpdateInput ($key: String!, $value: String!) {
    checkoutAttributesUpdateInput(key: $key, value: $value) {
      userErrors {
        message
        field
      }
      checkout {
        ...CheckoutFragment
      }
    }
  }
  ${CheckoutFragment}
`;

Any hints are welcome. Thanks guys!

0 Likes