Redirect Continue Shopping link to previous page

Please post your issues and questions about One Page Checkout for Virtuemart 2 to this forum.

Redirect Continue Shopping link to previous page

Postby pdhlambert@.....com » Sun Sep 30, 2012 12:08 am

Hi All,

I am want to change the Continue Shopping link to redirect the user to the last page he was viewing, not the category page.
I looked at the following forum reply which is sort of along the same lines but this doesn't give the information I need:

viewtopic.php?f=2&t=35

Can anyone point me in the right direction?
I have been working on this problem and so far no luck.
Thanks
Paul
pdhlambert@.....com
 
Posts: 3
Joined: Sun Sep 30, 2012 12:01 am

Re: Redirect Continue Shopping link to previous page

Postby admin » Tue Oct 02, 2012 12:31 pm

Hello, the continue link is generated in loader.php file which sets it to the last visited category of virtuemart as VM default behavior. We will add more functionality to this, but it is not possible to use REFERER url.

You can have a look onto: /components/com_onepage/helpers/loader.php
function getContinueLink(&$ref) ...

If you change this function, it will be much harder for you to update to the later versions of OPC - therefore you may want to change us the updated code and we may implement it into the standard installer.

Best Regards,
Stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Redirect Continue Shopping link to previous page

Postby pdhlambert@.....com » Tue Oct 02, 2012 8:27 pm

Hello Stan,

Thanks for your reply and information.
I would like to try and modify the loader.php and see what happens, it doesn't matter as I backup the site and copy any files I modify!
But I am not a PHP expert, so have searched for more info and came up with this article:

http://www.dreamincode.net/forums/topic ... ious-page/

In here Greg suggests putting the following code in the document header:

Code: Select all
// SET REFERRER
         
   function strleft($s1, $s2) {
      return substr($s1, 0, strpos($s1, $s2));
   }   
          
   function selfURL() {
      if(!isset($_SERVER['REQUEST_URI'])) {
         $serverrequri = $_SERVER['PHP_SELF'];
      }
      else {
         $serverrequri = $_SERVER['REQUEST_URI'];
      }
      $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
      $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
      $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
      $_SESSION['ref'] = $protocol."://".$_SERVER['SERVER_NAME'].$port.$serverrequri;
   }            
            
selfURL();



And I think putting the following in the loader.php file:

Code: Select all
header("Location: " . $_SESSION['ref']);



My question is, which document does the first code go in (basket.html.php) and where and where does the second code go...?

My other question is, if I don't know how to do this myself should I go away and learn PHP and come back later...!!!
Totally understand if I'm asking too much now as this is PHP problem. :D

Best
Paul
pdhlambert@.....com
 
Posts: 3
Joined: Sun Sep 30, 2012 12:01 am

Re: Redirect Continue Shopping link to previous page

Postby admin » Tue Oct 16, 2012 10:43 pm

Hello,
I am afraid that your code would not work. What i can do for you is to add this as an option to OPC - the plugin would find out the last visited product and save it to the session and the OPC would generate the link from this variable.

what would be your ideal continue link url?
- product page
- category
- joomla article
(?)

in general it is not recommended to use direct $_SESSION as i've already seen many issues with this (ajax session corruption). Also you can't rely trust the request_uri as it can be a post of /index.php

best regards,
stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 2