Post by IFFMP » Sat Jun 04, 2011 4:20 pm

How can I do that? I have just downloaded opencart and It is amazing, but I need to disable the ajax add to cart function.

Newbie

Posts

Joined
Sat Jun 04, 2011 4:18 pm

Post by SXGuy » Sat Jun 04, 2011 9:00 pm

extensions - > modules - > cart

disable ajax add to cart

That will force it to go straight to cart.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by Xsecrets » Sat Jun 04, 2011 10:13 pm

that part is gone in 1.5.x

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by dony_b » Wed Jun 08, 2011 12:04 am

So how do we disable it in v1.5 ?

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by oleg » Thu Jul 14, 2011 5:40 am

today I've spent an hour or so to find a solution on how to redirect a client to the cart page when pressed "add to cart".

I'm using 1.5.0.5v, there is no way to do it from the admin panel like in earlier versions.

I have seen different php based solutions that haven't worked for me, so I came with my own javascript based solution.

The idea is very simple. You just have to append a redirect command to onclick event.

instead of

Code: Select all

<a class="button" onclick="addToCart('73');">
use

Code: Select all

<a class="button" onclick="addToCart('73');window.location='index.php?route=checkout/cart';">
or (not tested yet) if there are no onclick event, just add one with the redirect, or just add the redirect at the end of the addToCart function

Working on hebrew rtl opencart 1.5.0.5v http://automoto.co.il


Newbie

Posts

Joined
Thu Jul 14, 2011 4:50 am
Location - Israel

Post by oleg » Thu Jul 14, 2011 9:57 pm

There is a little problem with this method. Sometimes the redirect works faster than the ajax add to cart code, it does adds a product to cart, but when you get to the carts page you don't see the product until you refresh. To solve this you can use setTimeout().

add to common.js function

Code: Select all

function RedirectToCart(){
	window.location='index.php?route=checkout/cart';
}
and instead of

Code: Select all

<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button">
use

Code: Select all

<a onclick="addToCart('<?php echo $product['product_id']; ?>');setTimeout('RedirectToCart()',2000);" class="button">

Working on hebrew rtl opencart 1.5.0.5v http://automoto.co.il


Newbie

Posts

Joined
Thu Jul 14, 2011 4:50 am
Location - Israel

Post by dony_b » Sat Jul 16, 2011 12:16 am

Quite a bit of work to do this huh ? thanks a lot for figuring this out...I will give it a try and see how it works

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by dony_b » Sat Jul 16, 2011 12:26 am

where is the

Code: Select all

<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button">
located ?

is this in product.tpl ??

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by oleg » Sun Jul 17, 2011 6:53 pm

I did it for testing only at home page in featured - module/featured.tpl

If you want to use it in all places there are about 5 or more files including product.tpl, you'll just have to look for..

If I gonna use it in my site everywhere, I will post the list of files.

Working on hebrew rtl opencart 1.5.0.5v http://automoto.co.il


Newbie

Posts

Joined
Thu Jul 14, 2011 4:50 am
Location - Israel

Post by dvenrao » Sat Aug 06, 2011 8:10 am

List of files


./catalog/view/theme/default/template/module/featured.tpl:
./catalog/view/theme/default/template/module/special.tpl:
./catalog/view/theme/default/template/module/bestseller.tpl:
./catalog/view/theme/default/template/module/latest.tpl:
./catalog/view/theme/default/template/product/product.tpl:
./catalog/view/theme/default/template/product/manufacturer_info.tpl:
./catalog/view/theme/default/template/product/special.tpl:
./catalog/view/theme/default/template/product/compare.tpl:
./catalog/view/theme/default/template/product/search.tpl:
./catalog/view/theme/default/template/product/category.tpl:
./catalog/view/theme/default/template/account/wishlist.tpl:
./catalog/view/javascript/common.js:

Newbie

Posts

Joined
Sat Aug 06, 2011 8:02 am

Post by amdev » Sat Aug 06, 2011 9:30 am

Hi, an easy case edit function addTocart()//in common.js

find

Code: Select all

			if (json['success']) {
				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
				
				$('.success').fadeIn('slow');
				
				$('#cart_total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
				 window.location.href = 'index.php?route=checkout/cart';//i'm put this line and work perfect!!
			}	
add

Code: Select all

window.location.href = 'index.php?route=checkout/cart';
after

Code: Select all

$('html, body').animate({ scrollTop: 0 }, 'slow'); 
and product.tpl

Code: Select all

			if (json['success']) {
				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
					
				$('.success').fadeIn('slow');
					
				$('#cart_total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
				window.location.href = 'index.php?route=checkout/cart';

			}	

there r 2 file to edit. ;) ;) ;)

ร้านค้าออนไลน์
OpenCart Thailand Support Forum
How to Upgrade oc1.5 to 2.0.1.1
Upgrading OpenCart From v.1.4 or v.1.5 to V.2.2 Step by step


User avatar
Active Member

Posts

Joined
Fri Nov 27, 2009 3:40 pm
Location - Bangkok - Thailand

Post by dony_b » Sat Aug 06, 2011 10:30 pm

wow great it works but the only thing is that it still shows the AJAX effect when you add to cart.

Is there a way to fully eliminate the ajax movement ?

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by oolongtea » Wed Oct 05, 2011 8:12 am

I also don't want the ajax effect of "add to cart" because there is only one product we are going to sell.
Does anybody has solution on this?

thanks!

Newbie

Posts

Joined
Thu Dec 09, 2010 6:28 am

Post by tarkanlar » Sat Oct 22, 2011 1:29 am

oolongtea wrote:I also don't want the ajax effect of "add to cart" because there is only one product we are going to sell.
Does anybody has solution on this?

thanks!
i found this solution in common.js
change this

Code: Select all

	if (json['success']) {
				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
				
				$('.success').fadeIn('slow');
				
				$('#cart_total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}	
to this

Code: Select all

if (json['success']) {
				$('#cart_total').html(json['total']);
				window.location.href = 'index.php?route=checkout/checkout';
			}	

New member

Posts

Joined
Sun Nov 22, 2009 8:17 am

Post by tickledpink » Sun Jul 01, 2012 5:52 am

If you remove

Code: Select all

.animate({ scrollTop: 0 }, 'fast')
the ajax movement is gone

Newbie

Posts

Joined
Thu Jul 21, 2011 4:34 am

Post by tickledpink » Sun Jul 01, 2012 5:55 am

And if you want to remove the ajax from "add to wishlist" too it's basically the same thing except the new code would be

Code: Select all

window.location.href = 'index.php?route=account/wishlist';

Newbie

Posts

Joined
Thu Jul 21, 2011 4:34 am

Post by lacasamia » Fri Apr 17, 2015 6:27 pm

Hi my problem is slightly different but I think its in the same vain
The item selected only appears in the in the cart when you mouse over the cart items at the top of the page. It also throws out the following error in the error log
PHP Notice: Use of undefined constant php - assumed 'php' in /websites/123reg/LinuxPackage22/la/ca/sa/lacasamia.co.uk/public_html/catalog/view/theme/theme306/template/product/product.tpl on line 450

The site url is
http://www.lacasamia.co.uk

many thanks

Newbie

Posts

Joined
Wed Oct 08, 2014 3:59 pm
Who is online

Users browsing this forum: No registered users and 2 guests