Skip to content

Instantly share code, notes, and snippets.

@tomblanchard
Last active March 6, 2018 12:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomblanchard/8812002 to your computer and use it in GitHub Desktop.
Save tomblanchard/8812002 to your computer and use it in GitHub Desktop.
BigCartel Feed.
$.getJSON('http://api.bigcartel.com/USERNAME/products.json?limit=5&callback=?', function(data) {
$.each(data, function(i, obj) {
$('\
<a href="http://USERNAME.bigcartel.com' + obj.url + '">' +
obj.name +
'$' + parseFloat(obj.price, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,').toString() +
'<img width="100" src="' + obj.images[0].url + '" alt="">' +
'</a>'
).appendTo('.products');
});
});
<?php
$products = json_decode(file_get_contents('http://api.bigcartel.com/USERNAME/products.json?limit=5'));
foreach($products as $product) {
printf(
'
<a href="%s">
%s
%s
<img src="%s" alt="" width="100">
</a>
',
'http://USERNAME.bigcartel.com' . $product->url,
$product->name,
'$' . number_format($product->price, 2, '.', ','),
$product->images[0]->url
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment