Saving data to cart / order meta fields

@Alan_G thanks for getting back to me, and for the helpful suggestions.

Using cart notes is an interesting idea, though I worry it might get a little messy. As for the feature request: that would be great if it’s possible. Totally understand if it doesn’t get prioritised or actioned, but right now I’m struggling to understand the logic of why cart attributes persist into orders while cart metafields do not. It would feel more consistent if they did, and in our case, it would solve the problem cleanly.

Regarding the use case – I’m not sure if you need this in a particular format, but here’s our situation:

  1. We’re using cart attributes to persist PostHog IDs, allowing us to share them between our headless frontend (built in Next.js) and Shopify’s hosted checkout. There’s more context on why we’re doing this here: Cookies in pixel sandbox
  2. We use various third-party extensions, some of which write to cart attributes. It seems like race conditions may be occurring here – in theory we could try to refactor things, but I’m not confident we’ll ever be able to guarantee the order in which those attributes are written.
  3. Metafields would help avoid these conflicts, since they can be scoped to specific fields – meaning one service won’t accidentally overwrite another’s data unless it’s explicitly updating the same field (which would be highly unlikely, particularly in the case of third-party services). With attributes, the whole object gets overwritten, which is much riskier.

Hope that all makes sense. Let me know if you need any clarification. I’ll give the cart note approach a go, otherwise we’ll stick to using attributes – the occasional loss of analytics data isn’t a huge issue, but longer term it would be great to have a more robust solution.