-
Notifications
You must be signed in to change notification settings - Fork 2
/
script_asset.js
36 lines (28 loc) · 985 Bytes
/
script_asset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$(function() {
//console.log('ready');
// update selector to corresponding cart menu
$('.cart-count').on('mouseenter', function() {
$.getJSON('/cart.js', function(data) {
// run template view
var template = $("#minicart-template").html();
var tmpl = _.template(template);
// populate cart data
$("#mini-cart").html(tmpl({cart:data}));
// format all prices
$('.price', '#mini-cart').each(function() {
$(this).html( Shopify.formatMoney($(this).text()) );
});
// format image to small
$('img', '#mini-cart').each(function() {
var src = $(this).attr('src');
src = src.replace('.jpg', '_50x50.jpg'); // if using jpg
src = src.replace('.jpeg', '_50x50.jpeg'); // if using jpeg
$(this).attr('src', src);
});
$('#mini-cart').show();
});
});
$('#mini-cart').on('mouseleave', function() {
$(this).hide();
});
});