Created
May 13, 2020 16:08
-
-
Save obrien-k/dfcd990755b337db13606e47fd0bd1c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{~inject 'template' template}} | |
{{inject 'token' settings.storefront_api.token}} | |
<!-- Declare an empty Array as arr | |
Then iterate over the custom fields for the intended name ('foo' here) | |
Inject into the current context --> | |
<script> | |
let jsContext = JSON.parse({{jsContext}}); | |
let arr = []; | |
{{#forEach product.custom_fields}} | |
{{#if name '===' 'foo'}} | |
{{inject 'productIds' value }} | |
// Now within the iteration, we want to push to the previously created Array | |
arr.push({{value}}) | |
{{/if}} | |
{{/forEach}} | |
</script> | |
<!-- Close out the forEach, but we're not done with this data yet, note the injected 'token' and 'arr'--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment