Jump to content

Refresh ajax cart while closing Fancybox product quick view


Rimesta7

Recommended Posts

Hello,

I'm using Presta 1.5.4.1, i made a fancybox in product list, to have a quick view of selected product.

I use Link_product&content_only=1 .

My problem is while click add to cart, the product is added but when i close the fancybox the ajax cart doesnt refresh automatically, until i refresh the whole page.

 

I cant wait for suggestions..

Link to comment
Share on other sites

  • 1 year later...
  • 3 months later...
  • 3 months later...

+1

 

Using Presta 1.6.1.  I would love a solution to this. Has anyone has any success with?

 

I am using the Quick View fancybox as an alternative to be able to "Add to Cart" items with attributes.

 

Ideally, I would prefer that the fancybox closes after clicking "Add to Cart" from the quickview, and then calls a refresh on the AJAX blockcart on the parent page.

 

Any guidance or a 'point in the right direction' would be most appreciated. Thanks in advance.

Link to comment
Share on other sites

So I've made a good start and got this in my product.tpl

 

$("#product.content_only #add_to_cart button").click(function(){
  setTimeout("parent.$.fancybox.close()", 1000);
  parent.$.ajaxCart.updateCart();  /* - TypeError: parent.$.ajaxCart is undefined */
});

 

The quickview closes nicely but I don't know how to call a refresh on the BlockCart. Surely this should be easy enough, but I'm a bit novice. Thank you kindly

Link to comment
Share on other sites

  • 7 months later...
  • 4 months later...

So within the ajax-cart.js file (it should be either within the theme folder in js/modules/blockcart or the general modules/blockcart folder), there's an event around line 50 like this:

$('#add_to_cart').unbind('click').click(function () {
     ...
     ajaxCart.add($('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
     ...
})

I changed it to:

$('#add_to_cart').unbind('click').click(function () {
  ...
  if (!selectedCombination.unavailable) {
     var productpage = $(this.closest('#product'));
     if (productpage.hasClass('content_only')) {
          parent.ajaxCart.add($('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
          parent.$.fancybox.close();
     } else {
          ajaxCart.add($('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
     }
  }
  ...
});

And it works like a charm!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...