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

Fix reference to product options #153

Conversation

LukaszFormela
Copy link

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.

@ghost ghost added the cla-needed label Feb 23, 2021
@LukaszFormela LukaszFormela deleted the fix-reference-to-product-options branch February 23, 2021 21:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants