Skip to content

Commit

Permalink
No add to cart confirmation when already looking at cart & fix cart s…
Browse files Browse the repository at this point in the history
…croll behavior
  • Loading branch information
divmazie committed Jul 21, 2016
1 parent 1c22378 commit 51753d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions js/store.js
Expand Up @@ -106,7 +106,9 @@ ko.applyBindings(myViewModel);
function make_store_visible() {
myViewModel.knockout_loaded(true);
$('#content').resize();
window.scrollTo(0,$('#'+scrollto).offset().top);
if (scrollto) {
window.scrollTo(0, $('#' + scrollto).offset().top);
}
}
setTimeout('make_store_visible()',50);

Expand Down Expand Up @@ -147,9 +149,11 @@ function addToCart(product_id,product_name,price,variants,variant_id,allow_multi
myViewModel.cart.push(product);
}
$('#product_modal_'+product_id).modal('hide');
$('#cart_confirm_product_name').html(product_name);
$('#cart_confirm_modal').modal('show');
setTimeout("$('#cart_confirm_modal').modal('hide')",3000);
if (!$('#cart_modal').hasClass('in')) {
$('#cart_confirm_product_name').html(product_name);
$('#cart_confirm_modal').modal('show');
}
setTimeout("$('#cart_confirm_modal').modal('hide')", 3000);
}

function find_variant(variants,variant_id) {
Expand Down
3 changes: 2 additions & 1 deletion views/page-store.twig
Expand Up @@ -219,7 +219,8 @@
<button class="option centered" onclick="$('#cart_confirm_modal').modal('hide')">Keep shopping</button>
</div>
<div class="col-xs-6">
<button class="option centered" onclick="$('#cart_confirm_modal').modal('hide'); $('#cart_modal').modal('show');">Checkout</button>
<!-- The setTimeout function prevents weird scrolling behavior from Bootstrap -->
<button class="option centered" onclick="$('#cart_confirm_modal').modal('hide'); setTimeout('$(\'#cart_modal\').modal(\'show\')',400);">Checkout</button>
</div>
<div class="clearfix"></div>
</div>
Expand Down

0 comments on commit 51753d2

Please sign in to comment.