stewishaw Posted January 23, 2013 Posted January 23, 2013 Hello, I am setting up a store and have a problem. We need to simply list on the product_info page the other products that are in that sub-category. This can be simple links so does anybody know of any solutions to this, I have searched the forum for answers and tried quite a few different modules but none of them do what we need. It would also be good if it simply displayed the products in the menu? I will also give you a little bit of background on why we need this. The shop uses price breaks for the products but there are also different varieties of each product that have different price breaks...... So the only solution that I could come up with was to use a price break add-on and then just create a different product for each variety so that each product can have the different price breaks. I would then like to list the different varieties on the product page so that the user can select a different size or variety if they would like. Thanks for any help.
npn2531 Posted January 23, 2013 Posted January 23, 2013 This would be nice addition to shops with limited numbers of products within a category like mine. I have not seen such an add-on, but perhaps I am missing something here as well. Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120
burt Posted January 23, 2013 Posted January 23, 2013 It would not be much work I think to code it up. Might make a good blog post tutorial.
npn2531 Posted January 23, 2013 Posted January 23, 2013 A blog post tutorial on http://www.clubosc.com would be really nice! I'd put a link to that on my site for what that's worth. Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120
burt Posted January 23, 2013 Posted January 23, 2013 I'll try to find time tomorrow. I guarantee that writing the post will take longer than creating the module lol I guesstimate; 5 minutes for the module, 20 minutes for the blog post.
npn2531 Posted January 23, 2013 Posted January 23, 2013 I'll keep an eye out for it. Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120
stewishaw Posted January 23, 2013 Author Posted January 23, 2013 Thanks guys any help would be hugely appreciated :)
Bob Terveuren Posted January 23, 2013 Posted January 23, 2013 Hi Here's a start in my best slash and burn style (most folks use cut and paste but I tend to break more stuff than paste can fix) Using 2.3.3 but 2.2 or MS2.2 would follow a similar line. 1) Grab a lump of existing code that does pretty much what you want already - so we want a display of products on the product page? Right - there's a candidate right there in includes/modules/also_purchased_products.php - open that and save it as includes/modules/also_in_this_cat_products.php 2) Edit the code as shown below 3) Go to product_info.php and add in a call to the new file- line 215 in vanilla code shown <?php if ((USE_CACHE == 'true') && empty($SID)) { echo tep_cache_also_purchased(3600); } else { include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS); } //added BobTerveuren include(DIR_WS_MODULES . 'also_in_this_cat_products.php'); ?> n.b this is quick and dirty and does not make use of the osC file naming convention So this'll give you a start - there's just an image and a name in there and the box still carries the title for 'Customers who bought this product also bought:' but you can change that and if you want price/buy now button then have a look around in the other files to see what you need <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2010 osCommerce Released under the GNU General Public License */ if (isset($HTTP_GET_VARS['products_id'])) { //comment out original sql query //$orders_query = tep_db_query("select p.products_id, p.products_image from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p where opa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['products_id'] . "' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED); //add in a new one //if you do not want to use MAX_DISPLAY_ALSO_PURCHASED then change that to something else //Right get the parent category for this product if(tep_not_null($cPath)){ //check that cPath variable exists $cat_array = explode("_", $cPath); //split it out into an array $current_cat= end($cat_array); //grab the cat_id for this product //make a little SQL query $orders_query = tep_db_query(" select p.products_id, p.products_image from " . TABLE_PRODUCTS . " p, " .TABLE_PRODUCTS_TO_CATEGORIES. " p2c where p.products_id <> '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_status = '1' and p.products_id=p2c.products_id and p2c.categories_id='".(int)$current_cat."' group by p.products_id "); $num_products_ordered = tep_db_num_rows($orders_query); if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED) { $counter = 0; $col = 0; $also_pur_prods_content = '<table border="0" width="100%" cellspacing="0" cellpadding="2" class="ui-widget-content ui-corner-bottom">'; while ($orders = tep_db_fetch_array($orders_query)) { $counter++; $orders['products_name'] = tep_get_products_name($orders['products_id']); if ($col === 0) { $also_pur_prods_content .= '<tr>'; } $also_pur_prods_content .= '<td width="33%" valign="top" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $orders['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $orders['products_image'], $orders['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $orders['products_id']) . '">' . $orders['products_name'] . '</a></td>'; $col ++; if (($col > 2) || ($counter == $num_products_ordered)) { $also_pur_prods_content .= '</tr>'; $col = 0; } } $also_pur_prods_content .= '</table>'; ?> <br /> <div class="ui-widget infoBoxContainer"> <div class="ui-widget-header ui-corner-top infoBoxHeading"> <span><?php echo TEXT_ALSO_PURCHASED_PRODUCTS; ?></span> </div> <?php echo $also_pur_prods_content; ?> </div> <?php } } }//end tep_not_null($cPath) ?>
stewishaw Posted January 24, 2013 Author Posted January 24, 2013 Hi Bob that's fantastic so thanks so much. I have it working, displaying just a standard text link for each product, but am wondering is it also possible to add the price as well? So it would display like: Product Link - £Price Or even better displaying the price breaks, although I assume that would be very difficult? I am using the Simple Price Break Contribution (http://addons.oscommerce.com/info/4658). Thanks again.
burt Posted January 24, 2013 Posted January 24, 2013 Another option, github'd; https://github.com/gburton/oscommerce2/commit/c0256b9c4db36ae1c7cf84f3a6290422540f7f22
Recommended Posts
Archived
This topic is now archived and is closed to further replies.