Guest Posted July 3, 2007 Posted July 3, 2007 Hi, The site I'm working on has categories, subcategories and sub-subcategories. What I'm trying to do is get the "continue shopping" button on the cart contents page to take the customer back to the "mother category" that the product they've just added belongs to. Eg: Customer arrives at site, goes to the "widgets" category, then the "red widgets" sub category, then the "shiny red widgets" subsubcategory. They add an item to their cart from the "shiny red widgets" subsubcategory. What I'd like to happen is for that customer then to be taken back to the main "widgets" category. Not got a clue where to begin :'( Most appreciated if someone could point me in the right direction! Thanks, Ali.
dynamoeffects Posted July 3, 2007 Posted July 3, 2007 Not simply, no. One way would be to add PHP to shopping_cart.php to loop through the $navigation object to see where you came from, parse out the product_id if you came from a product_info.php page, search the database for the category_id, and then write the URL of the "Continue Shopping" link with the category_id. Actually, it might be more reliable to include it in the "add_product" section of includes/application_top.php so that it only rewrites the link if the user just added an item to their cart. Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail.
dynamoeffects Posted July 3, 2007 Posted July 3, 2007 Actually I overstated the complexity. I just took a look and the existing code already does all the hard work. In /shopping_cart.php, try changing these lines: <?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 } ?> to this: <?php $back = sizeof($navigation->path)-2; if (isset($navigation->path[$back])) { if ($navigation->path[$back]['get']['products_id'] > 0) { $cat_query = tep_db_query("SELECT categories_id as id FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id = " . (int)$navigation->path[$back]['get']['products_id'] . " LIMIT 1"); if (tep_db_num_rows($cat_query)) { $cat = tep_db_fetch_array($cat_query); $navigation->path[$back]['page'] = 'index.php'; $navigation->path[$back]['get'] = array('cPath' => $cat['id']); } } ?> <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 } ?> Please use the forums for support! I am happy to help you here, but I am unable to offer free technical support over instant messenger or e-mail.
Guest Posted July 13, 2007 Posted July 13, 2007 Actually I overstated the complexity. I just took a look and the existing code already does all the hard work. In /shopping_cart.php, try changing these lines: Thanks for that :) Doesn't quite work though. What's happening is ... Customer goes to category - index.php/cPath/147 They then go to a subcategory of that - index.php/cPath/147_148_149 They then go to the cart - shopping_cart.php/cPath/147_148_149/sort/2a On clicking the continue shopping button they are being taken back to index.php/cPath/147_148_149 What I really want is for them to be taken to index.php/cPath/147 instead Is there an easyish way of doing that? Thanks, Ali.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.