addLineItems[...]
shopClient.addLineItems(cart.id, [{
variantId: variant.id,
quantity: 1,
customAttributes: [{
key: 'foo',
value: 'bar'
}],
}]);
mutation {
checkoutLineItemsAdd(
checkoutId: "Z2lkOi8vc2hvcGlmeS9DaGVja291dC9jZjBhNzZkZTEwNTNmMDhhYjdlMjUxNzA1MzZiMDU5Zj9rZXk9ZDNhODE4ZGUzNjkzZjYzZDc2ZjI2NTliY2NlZThhODc=",
lineItems: [{
variantId: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC80MDMxNDU2MTkzNA==",
quantity: 1,
customAttributes: [{key: "foo", value: "bar"}]
}]
) {
userErrors {
message
field
}
checkout {
id
ready
lineItems(first: 250) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
cursor
node {
id
title
variant {
id
title
price
weight
image {
id
src
altText
}
selectedOptions {
name
value
}
}
quantity
customAttributes {
key
value
}
}
}
}
shippingAddress {
address1
address2
city
company
country
firstName
formatted
lastName
latitude
longitude
phone
province
zip
name
countryCode
provinceCode
id
}
shippingLine {
handle
price
title
}
requiresShipping
customAttributes {
key
value
}
note
paymentDue
webUrl
order {
id
cancelReason
cancelledAt
createdAt
updatedAt
processedAt
orderNumber
subtotalPrice
totalShippingPrice
totalTax
totalPrice
currencyCode
totalRefunded
displayFulfillmentStatus
displayFinancialStatus
customerUrl
shippingAddress {
address1
address2
city
company
country
firstName
formatted
lastName
latitude
longitude
phone
province
zip
name
countryCode
provinceCode
id
}
lineItems(first: 250) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
cursor
node {
title
variant {
id
title
price
weight
image {
id
src
altText
}
selectedOptions {
name
value
}
}
quantity
customAttributes {
key
value
}
}
}
}
}
orderStatusUrl
taxExempt
taxesIncluded
currencyCode
totalTax
subtotalPrice
totalPrice
completedAt
createdAt
updatedAt
}
}
}
Either:
This expectation stems from the Storefront API documentation, which is referred to by the SDK Api Reference, and the Javascript SDK Github Issue about custom line items attribute (#105)
{"errors":[{"message":"Internal error"}]}TypeError: Cannot read property 'checkoutLineItemsAdd' of undefinedAny feedback ?
This should actually work now. Sorry for the way late follow up. There was definitely a bug internally.
thanks for the update, tested now with alpha.8 and it's working correctly - the field is accepted by the API and the attribute shows up when viewing the order in the backoffice.
It seems it's not working when you pass an integer as value. Otherwise, It's working ;)
Yeah, all values are strings. That should be more clearly documented. Thanks for the reminder!!
Most helpful comment
Yeah, all values are strings. That should be more clearly documented. Thanks for the reminder!!