Created
November 26, 2021 19:09
-
-
Save iamcanadian1973/77b1015bbc4efe85a8be180d4ba06933 to your computer and use it in GitHub Desktop.
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
$.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