I want to add add to cart button without reloading the page.
For this I found this Excellence extension. But I have a problem when I add the product in cart, my minicart from top page is not updating. I found this in the code:
success: function(data){
jQuery('#ajax_loader').hide();
//alert(data.status + ": " + data.message);
if(jQuery('.block-cart')){
jQuery('.block-cart').replaceWith(data.sidebar);
}
if(jQuery('.header .links')){
jQuery('.header .links').replaceWith(data.toplink);
}
}
and my HTML output is look like this:
<div class="top-cart-contain">
<div class="mini-cart">
<div class="basket dropdown-toggle" data-toggle="dropdown" data-hover="dropdown">
<a href="http://example.com/checkout/cart/">
<div class="cart-box">
<span class="title">
<i class="glyphicon glyphicon-shopping-cart"></i>
My Cart:
<span>1 prekės</span>
Price:
<span class="price">13,74 €</span>
<i class="glyphicon glyphicon-triangle-bottom"></i>
</span>
</div>
</a>
</div>
</div>
</div>
Is there any way to make this extension to update my top cart?
1 Answer 1
The jQuery does not find your cart block because the class .block-cart is not the right one in your case. I suggest you replace:
if(jQuery('.block-cart')){
jQuery('.block-cart').replaceWith(data.sidebar);
}
With:
if(jQuery('.mini-cart')){
jQuery('.mini-cart').replaceWith(data.sidebar);
}
-
thank you so much, but if I change this in my top cart is blank nowRobert– Robert2016年09月15日 14:37:28 +00:00Commented Sep 15, 2016 at 14:37
-
@RobertD check what's the content of
data.sidebar?Raphael at Digital Pianism– Raphael at Digital Pianism2016年09月15日 14:38:20 +00:00Commented Sep 15, 2016 at 14:38 -
I talk about minicart from top, that minicart, and in controller of this extension I have this: $toplink = $this->getLayout()->getBlock('top.links')->toHtml(); $sidebar_block = $this->getLayout()->getBlock('cart_sidebar');Robert– Robert2016年09月15日 14:39:25 +00:00Commented Sep 15, 2016 at 14:39
-
@RobertD yeah what do you get in the
dataresponse ?Raphael at Digital Pianism– Raphael at Digital Pianism2016年09月15日 14:41:18 +00:00Commented Sep 15, 2016 at 14:41 -
what I need to do to see this data response?Robert– Robert2016年09月15日 14:43:22 +00:00Commented Sep 15, 2016 at 14:43
Explore related questions
See similar questions with these tags.