Storing Data/State management/Data Caching

I need to be able to store some temporary data prior to checking out, specifically the customers will be building a list of recipient addresses for whom they purchase the products to be sent. I know I can do it in localStorage more or less, but my app search has been fruitless and I know I can’t be the only person with this specific need/functionality.

Essentially, I need a means to store some input data (preferably in a JSON object) that I can later append to the order itself upon submission.

Limited budget and limited timeline, so really hoping there is an existing app that could fill the gap here.

Cart / Order notes or attributes can serve as a limited means of storing session metadata, with the caveat that Buy It Now / Dynamic Checkout buttons obliterate anything stored in them.

https://shopify.dev/api/ajax/reference/cart#post-cart-update-js

As long as cart attributes aren’t being used for anything else and there’s no Dynamic Checkout set up on the site, you can use the ‘attributes’ Object for arbitrary JSON-blob data, and pull it into Checkout Additional Scripts via the Liquid macro ‘{{ attributes.foo }}’.

If you’re using Dynamic Checkout buttons, the only safe way I know of is to code your own LocalStorage solution; I would love for someone to chime in with a better alternative if one exists!

1 Like

Thanks for the response! I was just talking it through with a buddy (both of us Shopify noobs) and we mapped out almost exactly what you suggested, so thanks for the confirmation!

I’ll leave the question open for a little while longer in case someone else has a different idea, but I’ll come back and accept your solution after some time if no one else responds.

Thanks again.

1 Like