Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Info page back button


jhande

Recommended Posts

All this time I thought I already fixed this problem... nope.

 

I've Googled and Googled, searched the forum and contributions but keep coming up short of a usable fix. sad.gif

 

Somewhere around here there must be a back button that works! ohmy.gif

 

I've tried the javascript version and that's not totally friendly.

 

Found and tried a couple from the contributions section.

One seemed to work fine, until you add a product to your cart then you get stuck refreshing the product info page instead of going back.

 

Can someone be so kind to point me in the correct direction?

 

I remember seeing this topic discussed hundreds of times, but I'll be damned if I can find any with a solution. blush.gif

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

All this time I thought I already fixed this problem... nope.

 

I've Googled and Googled, searched the forum and contributions but keep coming up short of a usable fix. sad.gif

 

Somewhere around here there must be a back button that works! ohmy.gif

 

I've tried the javascript version and that's not totally friendly.

 

Found and tried a couple from the contributions section.

One seemed to work fine, until you add a product to your cart then you get stuck refreshing the product info page instead of going back.

 

Can someone be so kind to point me in the correct direction?

 

I remember seeing this topic discussed hundreds of times, but I'll be damned if I can find any with a solution. blush.gif

This code worked for me:

 

<?php
   $back = sizeof($navigation->path)-2;
   if (isset($navigation->path[$back])) {
?>
               <td class="main"><?php echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']) . '">' . tep_image_button('button_continue_shopping.gif', IMAGE_BUTTON_CONTINUE_SHOPPING) . '</a>'; ?></td>
<?php
   }
?>

However I opted to use the "Continue Shopping" approach.

:thumbsup:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Thanks Jim

 

But that has the same effect as my original.

 

If your on say page five of the product listings, click an item, click the back button, it goes back to the first page of product listings not the fifth.

 

 

Any way to remedy that?

 

sad.gif

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Thanks Jim

 

But that has the same effect as my original.

 

If your on say page five of the product listings, click an item, click the back button, it goes back to the first page of product listings not the fifth.

 

 

Any way to remedy that?

 

sad.gif

Oh.... You wanted the "super deluxe" version...

:thumbsup:

 

Well, there is probably a better way, but this is how I did it.

 

In the /catalog/index.php after this line:

 

  require('includes/application_top.php');

I added this code:

 

  if ( isset($HTTP_GET_VARS['sort']) ) {
   $isort = $HTTP_GET_VARS['sort'];
   if ( ! tep_session_is_registered('isort') ) {
     tep_session_register('isort');
   }
 }

 if ( isset($HTTP_GET_VARS['page']) ) {
   $ipage = $HTTP_GET_VARS['page'];
   if ( ! tep_session_is_registered('ipage') ) {
     tep_session_register('ipage');
   }
 }

Then the code on the product info page becomes:

 

<?php
   $back = sizeof($navigation->path)-2;
   $others = '';
   if (isset($navigation->path[$back])) {
     if ( ($isort!='') || ($ipage!='') ) {
       if ( $isort != '') 
         $others .= '&sort=' . $isort;
       if ( $ipage != '') 
         $others .= '&page=' . $ipage;
     }
?>
               <td class="main" align="center"><?php echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')) . $others, $navigation->path[$back]['mode']) . '">' . tep_image_button('button_continue_shopping.gif', IMAGE_BUTTON_CONTINUE_SHOPPING) . '</a>'; ?></td>
<?php
   }
?>

Maybe all the info is in the $navigation array somewhere (and maybe it isn't) but I was never able to find it.

:blush:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

i had the same problem so i used another contribution.

 

 

<td class="main">
                <?php $referer = $_SERVER['HTTP_REFERER'];
   if (!$referer == '') {
      echo '<a href="' . $referer . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>';
   } else {
       echo '<a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_path($current_category_id = '')) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; }
    ?></td>

 

i can't remember which contribution it was so there is the code. this will send you back to the page you came from.  if you were on page 5 and clicked on a product, then clicked back. you would be sent to page 5.  however, if you got to the product from somewhere else, like a search engine, then it takes you back to the first page.  i don't know if you like this or not. it doesn't matter to me if it sends them back to the first page if they came from a search engine because they have not seen the products on the first pages anyway.

 

if this works for you, great. if not, good luck.

Link to comment
Share on other sites

Thanks Adam wink.gif

 

That's the contribution I tried and it worked until you clicked the add to cart button. Then it gets stuck refreshing the product info page.

 

Well at least as a guest.

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Oh.... You wanted the "super deluxe" version...

thumbsup.gif

 

Awesome Jim!!!

 

Thank you so much for sharing your "super deluxe" version.

 

Works like a charm thumbsup.gif

 

Thanks, I really appreciate it.

 

Hope you have/had a Happy New Year

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...