Reputation: 8385
In my cart I have it so when you add a product you get taken to the shopping cart and the client wishes the user to click continue shopping and be taken back to the added items category for further shopping. How could I do this?
The category URI segment is 1 after the domain.
Upvotes: 2
Views: 961
Reputation: 694
In addition to Jay Gilfords answer above - I have just tried this and found another instance of
$this->data['continue'] = $this->url->link('common/home');
about line 258. I also needed to put the code after that or the redirect only worked if the basket was empty.
Upvotes: 1
Reputation: 15151
Open catalog/controller/product/category.php
Find if ($category_info) {
on approx line 75
On a new line after it put
$tmp = $this->request->get;
unset($tmp['route']);
$this->session->data['continue_redirect'] = $this->url->link('product/category', http_build_query($tmp));
That code basically sets the url to the current page url if the category is a valid category into a session variable
Open catalog/controller/checkout/cart.php
Find $this->data['continue'] = $this->url->link('common/home');
around line 285
After that line, put
if(!empty($this->session->data['continue_redirect'])) {
$this->data['continue'] = $this->session->data['continue_redirect'];
unset($this->session->data['continue_redirect']);
}
This checks for the continue_redirect session variable we set in the category controller, and if it's set assigns it to the continue URL, then unsets it so that it doesn't retain that category information. If you want it to, delete the line
unset($this->session->data['continue_redirect']);
Please note that this has not been tested, but should work in theory, as I don't have a 1.3.x installation
Upvotes: 3
Reputation: 372
I think the simplest way to do this would be to just add a GET parameter to the "Add to Cart" link which contains the path to the item's category. Something like example.com/shopping_cart.php?item=bunny_slippers&item_category=/categories/footwear/
would do. I'm not sure what your application structure is like, but you could either do this by setting a $category
variable for each category page and then inserting that variable into the GET parameter, or you could grab the path info using PHP's SERVER superglobal.
Then, on the shopping cart page, you can simply insert the $_GET['item_category']
variable into your "Continue Shopping" link. Of course you'd have to do so basic sanitation on the parameter first to make sure it didn't have any malicious code in it.
Upvotes: 1
Reputation: 25205
you could set a cookie on the client that listed their last browsing category before adding to the cart, or you could set it in their user session.
Upvotes: 0