Last active
March 6, 2018 12:29
-
-
Save tomblanchard/8812002 to your computer and use it in GitHub Desktop.
BigCartel Feed.
This file contains 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
$.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'); | |
}); | |
}); |
This file contains 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
<?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