Page 1 of 1
Make all add to cart buttons ajax add
Posted: Mon Jan 17, 2011 3:59 pm
by Nooblet
Hey Guys,
I know there is a lot of information on this topic but i was wondering whether it was possible to make a modification so that all of the add to cart buttons do an Ajax add. Not just those on the products page. This would include the little plus buttons for all products.
Thanks for any help you can give
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 5:21 am
by kedgetech
There is a commercial contribution that allows you to do that. May be you can give this a try and see if this fits.
http://www.opencart.com/index.php?route ... ion_id=619
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 5:27 am
by Xsecrets
it is possible, but if you do it opens up the possibility for people to scam your cart. That is why they were not made ajax in the first place.
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 6:03 am
by marc_cole
Xsecrets wrote:if you do it opens up the possibility for people to scam your cart.
How so?
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 6:10 am
by Chones
I think the problem is that a user can be in the checkout section, and add more products via AJAX from the sidebars such as Specials etc. without leaving the checkout page - price won't update but products ordered will update.
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 6:18 am
by kedgetech
@Chones - We have released a "Free Gift" module that uses some ajax functionality when user adds the product that has free gift via ajax system adds the free gift product with discount and we tested that price is represented right.
I might be wrong but if there is something that we need to fix in our module (if any) would be helpful.
Demo :
http://www.opencartaustralia.com/module/freegift/
Try click on the "MacBook Air" from home page.
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 6:28 am
by Chones
I think you're okay - the problem only exists if you can add to cart via AJAX from the sidebar modules while in Checkout, and you're not using AJAX for the sidebar modules.
However, when I add to cart from the sidebar I don't get a free gift. If I was a customer I'd want my free gift if I'm buying legitimately!

You may want to do something about that.
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 6:34 am
by kedgetech
I guess ideally the template builder can point the user to product page or use api to implement the functionality in the other modules.
I would like to test that scenario you mentioned with ajax. Thanks.

Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 6:38 am
by kedgetech
If i have not already hijacked the post looks like there might be issues in using ajax all over which need to be tested. Approach with caution would be a context.
Hope that helps.
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 7:33 am
by Nooblet
Ok thanks guys. The comercial plugin looks good, but it does allow you to add products to the cart during the checkout screen so maybe i can disable that module when it is on the checkout screen to avoid problems?
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 7:41 am
by Xsecrets
The problem with making all the add to cart buttons ajax is specifically with the ones in the modules that are always displaying on the side. If you are on the confirmation page you can add things to the cart, then click submit. They will not get added into the value sent to the payment processor, however they will be in the order when it's completed on return. So people can essentially add anything that is in a sidebox to their order for free.
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 7:43 am
by Chones
It's a good idea to disable the modules on the checkout pages if you want to do this.
Also, it's been shown to increase conversion rates if you don't distract your customer with more products once they are in the checkout process - so removing sidebars from the checkout pages is a good idea all round.
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 9:02 am
by marc_cole
Xsecrets wrote:So people can essentially add anything that is in a sidebox to their order for free.
If that's true, it sounds like a PHP problem rather than an AJAX problem. How can client side code bypass the PHP code and add something to the cart for free? Isn't there something built-in to the code that would prevent that from happening?
Re: Make all add to cart buttons ajax add
Posted: Tue Jan 18, 2011 11:01 am
by Xsecrets
marc_cole wrote:Xsecrets wrote:So people can essentially add anything that is in a sidebox to their order for free.
If that's true, it sounds like a PHP problem rather than an AJAX problem. How can client side code bypass the PHP code and add something to the cart for free? Isn't there something built-in to the code that would prevent that from happening?
no because the AJAX wasn't designed to be used on the confirmation page because there weren't even add to cart buttons on any of the sideboxes at the time, and when they got added they were simply made to not be AJAX to keep from having to go back and rework the way all that code was designed.