Skip to content

Instantly share code, notes, and snippets.

@j7u7l7s
Last active April 20, 2018 12:50
Show Gist options
  • Save j7u7l7s/20917068cc8ae086d7baca0da40b1ce6 to your computer and use it in GitHub Desktop.
Save j7u7l7s/20917068cc8ae086d7baca0da40b1ce6 to your computer and use it in GitHub Desktop.
Get all products in collection via ajax.js
$.ajax({
url:'https://michele-mclaughlin-music.myshopify.com/collections/sheet-music?view=ajax',
type:'GET',
success: function(data){
var dataDump =JSON.parse(data);
console.log(dataDump);}
});
{% layout none %}
{%- paginate collection.products by 1000 -%}
[
{%- for a in collection.products -%}
{
"productData{{- forloop.index -}}": {
"featuredImage":{{ a.featured_image | img_url: '600x' | json }},
"songTitle":{{ a.metafields.song_title.key | json}},
"albumKey":{{ a.metafields.album.key | json }},
"keySig":{{ a.metafields.key-sig.key | json}},
"difficulty":{{ a.metafields.difficulty.key | json }},
"variantPrice":{{ a.selected_or_first_available_variant.price | money | json }},
"variantId":{{ a.selected_or_first_available_variant.id | json}}
}
}
{%- unless forloop.last -%},{%- endunless -%}
{%- endfor -%}
]
{%- endpaginate -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment