For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
Hi, I have a checkout app in wich I would like to add a "custom attribute" to the order
something like this (made with liquid)
in my app now I have this
useEffect(() => { // fetching data await applyAttributeChange({ key: 'dal_min', value: json.dals[0].dalMin.slice(0, 10) }); await applyAttributeChange({ key: 'dal_max', value: json.dals[0].dalMax.slice(0, 10) }); } catch (err) { console.error(err) } } fetchDal(); }, []);
I test in my dev store and when I make an order I don't have the data in my order when I look in my back office
Did I make a mistake? is this a bug or is there no way to do that anymore?
Solved! Go to the solution
This is an accepted solution.
Hey @AW1234
What do you see if you log the result?
const result = await applyAttributeChange({
key: '...',
type: 'updateAttribute',
value: '...',
});
console.log(
'applyAttributeChange result',
result,
);
Scott | Developer Advocate @ Shopify
Sounds like you're updating attributes on the cart not the order.
The Cart API is not the same as the Order API.
From what I understand, the `cart_token` is the only way to associate the cart with an order, and that's now deprecated. I would love if someone could point in the right direction of how to pass attributes from the cart to the order.
From what I can tell, there's no way to link a cart token to an order without relying on the Admin REST Order API which is deprecating the `cart_token` field.
Want to see it in action? Check out our demo store.
This is an accepted solution.
Hey @AW1234
What do you see if you log the result?
const result = await applyAttributeChange({
key: '...',
type: 'updateAttribute',
value: '...',
});
console.log(
'applyAttributeChange result',
result,
);
Scott | Developer Advocate @ Shopify
there were some errors and after fixing them it worked thank you.