Page 1 of 1
Do NOT redirect to cart from product page?
Posted: Tue May 24, 2011 6:12 am
by tjonnyc
I don't want to redirect to cart every time "Add To Cart" is clicked.
I have the cart installed in header ( "Cart: 2 items | Checkout" ), and it shows (with animation) that product has been added.
I've found a recommendation to replace $this->redirect(HTTPS_SERVER . 'index.php?route=checkout/cart'); with $this->redirect(html_entity_decode($_SERVER['HTTP_REFERER'])); in catalog/controller/checkout/cart.php - but it made no difference.
Cart is DISABLED in admin, AJAX is ENABLED (required for the animation).
Any ideas on how I can force the product page to stay on product page when "Add To Cart" is clicked?
Re: Do NOT redirect to cart from product page?
Posted: Tue May 24, 2011 1:48 pm
by ciprianrpp
just put // in front of
Code: Select all
$this->redirect(HTTPS_SERVER . 'index.php?route=checkout/cart');
to comment out
You have 2(TWO) lines of
Code: Select all
$this->redirect(HTTPS_SERVER . 'index.php?route=checkout/cart');
for the POST/GET methods
you have to comment them both
just add // for the 2 lines and that's it
this is for cart.php
Do the following mod if the above mode doesn't solve the problem
then go in product.php and comment with // the following line:
Code: Select all
$this->data['action'] = HTTP_SERVER . 'index.php?route=checkout/cart';
cheers!
Re: Do NOT redirect to cart from product page?
Posted: Wed May 25, 2011 6:48 pm
by Jacob
Hello
I followed the advice for product.php - now I get the message page can not be found when I click on the add to cart button?
Running v1.4.9.1
Cheers
Re: Do NOT redirect to cart from product page?
Posted: Wed May 25, 2011 11:11 pm
by qahar
try to add code bellow on product.tpl
Code: Select all
$('#add_to_cart').removeAttr('onclick');
Re: Do NOT redirect to cart from product page?
Posted: Thu May 26, 2011 2:23 am
by Jacob
Like so:
Code: Select all
<a onclick="$('#add_to_cart').removeAttr('onclick');" id="add_to_cart"><span><img src="/image/add.png"/></span></a>
Or do you have a line number?
I did the above but now it does neither function.
Re: Do NOT redirect to cart from product page?
Posted: Thu May 26, 2011 5:30 am
by qahar
This just assumption since I don't know code you use.
1. First Solution
Add
Code: Select all
$('#add_to_cart').removeAttr('onclick');
after
2. Second Solution
Remove manually "on click" from the add to cart.
Code: Select all
<a id="add_to_cart"><span><img src="/image/add.png"/></span></a>
If you have a link to your site it will help.
Re: Do NOT redirect to cart from product page?
Posted: Thu May 26, 2011 5:02 pm
by Jacob
The 1st solution rendered the 'add to cart' link inactive.
2nd, I already tried manually removing the code
but that also renders inactive.
Thanks for your help
londontshirt dot com
Re: Do NOT redirect to cart from product page?
Posted: Fri May 27, 2011 3:03 pm
by ciprianrpp
upgrade to 1.4.9.5 than we will advice further (what i've posted above applies for 1.4.9.5 since you didn't specify in your 1st post wich version you are using, I've assumed the latest)
Re: Do NOT redirect to cart from product page?
Posted: Fri May 27, 2011 5:54 pm
by Jacob
I think you are mistaking me for Tjonnyc, I did mention the version:
Running v1.4.9.1
Having to upgrade is a pain, I am using the
Accordion categories menu v1.1, it is not compatible for 1.4.9.5?
Re: Do NOT redirect to cart from product page?
Posted: Fri May 27, 2011 6:23 pm
by ciprianrpp
yes it IS:
"accordion_categories_menu_v1.1 v1.4.8, v1.4.8b, v1.4.9, v1.4.9.1, v1.4.9.2, v1.4.9.3, v1.4.9.4"
If you paied for it you should receive free updates.
and yes i've mistaking you.
anyway If you want help make your own topic, this is the best solution.
Re: Do NOT redirect to cart from product page?
Posted: Fri May 27, 2011 6:27 pm
by Jacob
I did pay for it.
That list only goes up to v1.4.9.4?
Re: Do NOT redirect to cart from product page?
Posted: Fri May 27, 2011 6:37 pm
by ciprianrpp
and the 1.4.9.4 should work for 1.4.9.5 ALSO!
please look at release CHANGE LOG!
http://www.opencart.com/index.php?route ... d/download
Re: Do NOT redirect to cart from product page?
Posted: Fri May 27, 2011 7:35 pm
by Jacob
Ok thanks.
I have never upgraded before. I read the upgrade steps guide, what happens to all the changes I have made to the catalog directory files on my current version? Do I have to re-due all the work I have done?
Thanks
Re: Do NOT redirect to cart from product page?
Posted: Fri May 27, 2011 9:59 pm
by ciprianrpp
backup your website.
backup your database from phpmyadmin> EXPORT
upgrade and see what happens. if it's not OK after upgrade than import your backuped database, import your backup files, delete cache and that;s it.

Re: Do NOT redirect to cart from product page?
Posted: Sat May 28, 2011 12:18 am
by Jacob
I trust in that process as I will have made back-ups, but I don't understand how it works ...

Re: Do NOT redirect to cart from product page?
Posted: Sat May 28, 2011 2:24 am
by Jacob
The upgrade went OK and did not produce any errors. But I have lost my design modifications?
Code: Select all
import your backup files, delete cache and that;s it.
Do you mean I should upload the backup files, what purpose does this have?
Cheers
Re: Do NOT redirect to cart from product page?
Posted: Tue May 31, 2011 9:46 pm
by Jacob
Great, I re-done the upgrade following the Opencart Faq & Tutorials, thanks! it seems to have gone without error
I am still not able to stop the page redirecting to the cart page though? I followed all the suggestions.
londontshirt dot com
Thanks
Re: Do NOT redirect to cart from product page?
Posted: Thu Jun 02, 2011 4:48 am
by Jacob
In Admin/Extensions/Modules/Cart I enabled the Ajax add to cart. Now items get added to the cart without re-directing.
Good but I do not want the animation. Got stuck again.
I decided to look at catalog/view/javascript/jquery/jquery-1.3.2.min.js and see if I could stop the animation by changing something in the code.
I did this by changing display 'visible' in two places to display 'none' .
So now I have it working how I wanted, but I am sure there must be a better way of doing it
Any suggestions please
