Skip to content

Instantly share code, notes, and snippets.

@iamcanadian1973
Created November 26, 2021 19:09
Show Gist options
  • Save iamcanadian1973/77b1015bbc4efe85a8be180d4ba06933 to your computer and use it in GitHub Desktop.
Save iamcanadian1973/77b1015bbc4efe85a8be180d4ba06933 to your computer and use it in GitHub Desktop.
$.ajax( {
type: 'GET',
url: 'https://pacific-dream-seafoods.myshopify.com/cart.json?callback=?',
dataType: 'jsonp',
crossDomain: true,
success: function(data) {
var item_count = data['item_count'];
console.log(data);
//If there are items in cart.
if( item_count > 0 ) {
$( '.cart > a' ).append( '<span class="cart_count" style="background-color: #000; display: inline-block; font-size: 13px; font-weight: 600; color: #FFF; border-radius: 50%; width: 20px; height: 20px; text-align: center; position: absolute; top: -10px; right: -50%;">'+ item_count +'</span>' );
}
},
error: function(data){
console.log(data);
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment