Jump to content
thirty bees forum
  • 0

How can i force the add to cart button in fancy modal product popup use ajax instead of redirecting to product item page?


d3s1gn3r

Question

Hi to everyone. This is my first post here. Earlier today i downloaded and installed the Thirty bees platform and i have to confess that i m very satisfied so i started to build my own custom theme based on the "Default community theme". What i need is to make the "ADD TO CART" button of the fancy popup product behave exactly as in the product page. For example when i view a product in the product page the "ADD TO CART" button has an ajax event that add this product in the cart using ajax. But when i click the "ADD TO CART" button when i view a product inside the fancy popup window then it redirects to the product page.

I found the ajax code that is responsible for the ajaxified add to cart event but i dont know how can i apply it to the fancy modal. The weird is that the "ADD TO CART " button inside the fancy modal window and the one in the product page are exactly the same but it call the ajax event only in the product page !!

Here is the code in the file themes/community-theme-default/js/modules/blockcart/ajax-cart.js
 

if ($('.cart_block').length) {

$(document).off('click', '#add_to_cart button').on('click', '#add_to_cart button', function(e) {

e.preventDefault();

ajaxCart.add($('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);

});

}


I am struggling to find a solution for the last 5 hours so any help from the community would be very much appreciated.

 

UPDATE 1: I see that if i remove the first and the last line of code it works the way i want to. So the code will be:

 

$(document).off('click', '#add_to_cart button').on('click', '#add_to_cart button', function(e) {

e.preventDefault();

ajaxCart.add($('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);

});

I can see that the code search if there is the text "cart_block" inside the class and apply the ajax event only in this case. My question is now if is safe to comment the line i mentioned above or it would be better to add a new condition with a new class. I think that the second is better but i dont know exactly where to add that class as there is oonly one "ADD TO CART BUTTON" for both fancy modal product and product page. If i am not wrong i think that fancy modal is just an iframe which contains the product page itself. Right?

 

Edited by d3s1gn3r
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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...