How can I add product data to customer metafield through code?

Can I add data to customer metafiled. It’s type is ‘products’ (list of products). I would like to create a button for every product, that adds them to wishlist page and also to customer metadata.

Hello @kurs , Welcome to the Shopify Community!

Yes, you can add data to customer metafields in Shopify. To create a wishlist functionality that also updates customer metafields with product data:

  1. Create a metafield for customers to store the list of products.
  2. Implement a button on product pages to add products to the wishlist and update customer metafields.
  3. Use Shopify’s APIs and JavaScript for backend logic and frontend interaction.

If you need more assistance, provide further details.

Thank you for answear. How can I use javascript and apis for adding values to customer metafields? Right now I have simple javascript code incorporated in theme code, that saves products to localstorage. Every product and product card has like button, that updates wishlist and wishlist page. I’ve also created metafield for customers to store liked products (type: list of products).

We need to add an app for the wishlist so that we can use it on every page of the website and for a particular product we can use a meta field.