HELP - Adding line item properties to Cart using Shopify.addItem

New Member
1 0 0

I'm trying to add product metafield properties to line items in my cart but am unable to figure out how to pass that value.

What i've tried to do is to include the metafield properties as hidden input:

<input type="hidden" name="properties[goodFor]" value="{{ product.metafields.storageTips.goodFor }}"> 
<input type="hidden" name="properties[where]" value="{{ product.metafields.storageTips.where }}">

Then have the products added to cart (it's current in the Collections page) using a link:
<a onclick="Shopify.addItem({{ }}, $('#{{}}-quantity').val()); return false" href="#" class="btn product-form__btn {{ }}-add">

But i've found that they don't get passed into the cart (probably because the link above doesn't include code to pass those metafield data on). My question is how I should tweak my code to have it added?


Replies 2 (2)
Shopify Expert
10440 169 2081

Hey YH Chang,

It's always best to add this info when posting in the design threads:

  • a link to the store
  • a link a page that shows the issue
  • a note of the theme in use. Each theme is different (and may be customised) so the code will also differ.

Looking at this:

<a onclick="Shopify.addItem({{ }}, $('#{{}}-quantity').val()); return false" href="#" class="btn product-form__btn {{ }}-add">

It looks like there is JavaScript being triggered when that link is clicked. It would be a fair assumption that the function being run doesn't use the metafield / line item properties data. You can see it's only sending the id and the quantity:

{{ }}, $('#{{}}-quantity')

I'd expect changes to the theme code would be needed here.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.
Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.
★ ★
New Member
5 0 0

Were you ever able to get this working?