Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

BACK button in the product_info in 2.3.3 to return to category root


westernfirebrand

Recommended Posts

Can I add a back button to my product info page (in 2.3.3) to return the user to the category root not the index page? What I am getting is a loop, add an item to the basket, press continue shopping and you return to that item, press back and you return to the basket. What I would like is a 'continue shopping' button in the basket and a 'back' button in the product info page that return you to the category root. Is this possible?

Regards, Graham

Link to comment
Share on other sites

Let's use this part of the forum for its intended purpose -- find this code in shopping-cart.php:

 

   $any_out_of_stock = 0;
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {

 

and replace it with this:

 

   $last_product = 0;
   $any_out_of_stock = 0;
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
       // Find the last product that was added to use in the Continue Shopping button
  $last_product = (int)$products[$i]['id'];

 

Now we can use that product info in a button. Decide where you want your continue shopping button to be and add this code there:

 

<?php
   $continue_category = '';
   if( $last_product > 0 ) {
  $cPath_new = tep_get_product_path($last_product);
  $continue_category = 'cPath=' . $cPath_new;
   }

?>
  <div class="back_button">
<?php echo tep_draw_button( IMAGE_BUTTON_CONTINUE_SHOPPING, 'triangle-1-w', tep_href_link( FILENAME_DEFAULT, $continue_category, 'NONSSL' ) ); ?>
  </div>

 

The continue shopping button will now go to the category containing the last product to be added to the cart, or to the index page if there is no product found.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Many thanks for that Jim, it works perfectly. Is it possible to use it, or a variant, on the product_info.php page. I have a continue shopping button on it but it takes the user back to the index.php not the category root of the product shown?

Regards, Graham.

Link to comment
Share on other sites

It's a lot easier on a product page:

 

         <div class="back_button">
<?php echo tep_draw_button( IMAGE_BUTTON_CONTINUE_SHOPPING, 'triangle-1-w', tep_href_link( FILENAME_DEFAULT, $cPath, 'NONSSL' ) ); ?>
         </div>

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

It's a lot easier on a product page:

 

<div class="back_button">
<?php echo tep_draw_button( IMAGE_BUTTON_CONTINUE_SHOPPING, 'triangle-1-w', tep_href_link( FILENAME_DEFAULT, $cPath, 'NONSSL' ) ); ?>
</div>

 

Regards

Jim

 

Thanks for this Jim, but I am not sure just where to place this code. Can you help?

I am at a loss as to why this is not part of the basic oscommerce setup.

Regards, Graham

Link to comment
Share on other sites

Put it where you want your button to appear. Experiment as needed until it suits you. I've used a variety of locations on different sites, but usually somewhere near the bottom seems to look the best.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Put it where you want your button to appear. Experiment as needed until it suits you. I've used a variety of locations on different sites, but usually somewhere near the bottom seems to look the best.

 

Regards

Jim

Hi Jim, I have tried this but it still returns to the index page. When I hover over the continue shopping button, the path indicated is .../shop/index.php?26. I must still be doing something wrong. Any ideas? Regards, Graham

Link to comment
Share on other sites

The code is wrong.

 

Use this:

 

<?php echo tep_draw_button( IMAGE_BUTTON_CONTINUE_SHOPPING, 'triangle-1-w', tep_href_link( FILENAME_DEFAULT, 'cPath=' . $cPath, 'NONSSL' ) ); ?>

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

The code is wrong.

 

Use this:

 

<?php echo tep_draw_button( IMAGE_BUTTON_CONTINUE_SHOPPING, 'triangle-1-w', tep_href_link( FILENAME_DEFAULT, 'cPath=' . $cPath, 'NONSSL' ) ); ?>

Many thanks, worked a treat.

Regards, Graham

Link to comment
Share on other sites

  • 7 months later...

@@kymation Tried your code on a 2.3.3.4 install and it does not display a button on the shopping cart page.

 

Replaced the 1st bit of code and added the 2nd as follows:

<div class="contentContainer">
 <div class="contentText">
   <?php echo TEXT_CART_EMPTY; ?>
   <p align="right"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?></p>
 </div>
 <?php
$continue_category = '';
if( $last_product > 0 ) {
  $cPath_new = tep_get_product_path($last_product);
  $continue_category = 'cPath=' . $cPath_new;
}
?>
  <div class="back_button">
<?php echo tep_draw_button( IMAGE_BUTTON_CONTINUE_SHOPPING, 'triangle-1-w', tep_href_link( FILENAME_DEFAULT, $continue_category, 'NONSSL' ) ); ?>
  </div>
</div>
<?php
 }
 require(DIR_WS_INCLUDES . 'template_bottom.php');

 

Have I missed something here?

 

@@burt Tried the code from your link - but it takes me back to the product I added to the cart not the category.

 

Many Thanks

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

Tried the code from your link - but it takes me back to the product I added to the cart not the category.

 

Goes 2 steps back in the navigation...which could be the product page, could be the category page, could be some other page..

Link to comment
Share on other sites

  • 2 months later...

I know I'm late to the party but this placed in catalog/product_info.php should work:

 

<?php echo tep_draw_button( IMAGE_BUTTON_BACK, 'triangle-1-w', tep_href_link( FILENAME_DEFAULT, 'cPath=' . $cPath, 'NONSSL' ) ); ?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...