Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Fix reference to product object property #154

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LukaszFormela
Copy link

@LukaszFormela LukaszFormela commented Feb 23, 2021

There is a discrepancy between JSON returned from fetch('/products/PRODUCT_HANDLE.js') and {{ product | json }}.

In first one, options property contains array of objects:

options: [
   {name: "Option1", position: 1, values: Array(4)},
   {name: "Option2", position: 2, values: Array(4)},
   {name: "Option3", position: 3, values: Array(3)},
]

The latter returns options property that contains direct option names:

options: [
   'Option1',
   'Option2',
   'Option3',
]

To prevent errors being thrown while using this in conjunction with theme-product-form.js on JSON returned with liquid tag, we need to do a quick check on what type of options property does current product object contain.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant