How to update metafield through ajax call

How to update metafield through ajax call

Khasim1
Shopify Partner
20 0 0

Hi

 

I am trying to implement wishlist functionality through customer metafields. Can anyone help me on how to update the customer metafield when a product is added to or removed from wishlist in liquid store through ajax call. 

 

I implemented in a different way earlier where product data is stored in local storage but the drawback here is it doesnt store data for the registered uers when they log out and then log in. So to save logged in users wishlist I need help on updating metafields with product data.

 

Thanks

Khasim

Replies 2 (2)

BSSCommerce-B2B
Shopify Partner
565 114 137

There is no way to update metafields through ajax API but admin apis because it requires write_products scopes 

You could create a custom app in Admin, and check Admin API integration scopes: write_products and read_products to manage product metafields.

BSSCommerceB2B_0-1718853468940.png

 

Then, you could use the given access token to make a Shopify API call to update product metafields. But, access token is too dangerous to be exposed to the storefront, you should hide the real logic behind the app proxy. In general, you must develop a simple server for that 😫

BSSCommerceB2B_1-1718853534641.png

 

 

If our suggestions are useful, please let us know by giving it a like, marking it as a solution.


B2B Solution & Custom Pricing |BSS: B2B Portal, Quote, Net 30 | BSS: B2B Login Lock Hide Price


Need help from our expert? Kindly share your request with us via community@bsscommerce.com


BSS Commerce - Full-service eCommerce Agency
Khasim1
Shopify Partner
20 0 0

If possible can you provide any reference which I can follow to implement this?