Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

how to make Contribution - X-Sell v2-MS2 - Cross Sell for MS2 create cross products for shopping cart


Recommended Posts

Hi everyone,


I downloaded this contribution in the hope to be able to add cross products in the shopping cart. but quickly noticed that its designed to be places in the product info page. so I decided to test that for fun. And changed the code so that it matches my site and the rest of my infoboxes. But in the end of the day thats not what I wanted it for. I wanted to for example add a product to my shopping cart and below have it display " Recommended for you" box below that will show 6 cross products that I selected for that product. As I mentioned above when I tested the infobox in the product info page, it worked and the cross products appeared. But when I moved that infobox to my shopping cart nothing came up. How can I make it work?


Here is the code:


$Id: xsell_products.php, v1  2002/09/11
// adapted for Separate Pricing Per Customer v4 2005/02/24

osCommerce, Open Source E-Commerce Solutions

Copyright (c) 2002 osCommerce

Released under the GNU General Public License
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_XSELL_PRODUCTS);

$xsell_query = tep_db_query("select distinct p.products_id, p.products_image, pd.products_name, p.products_tax_class_id, products_price, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price
from " . TABLE_PRODUCTS_XSELL . " xp left join " . TABLE_PRODUCTS . " p on xp.xsell_id = p.products_id
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'
left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id 
where xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "'
and p.products_status = '1'
order by sort_order asc limit " . MAX_DISPLAY_XSELL);

if (tep_db_num_rows($xsell_query)>= MIN_SIMILAR_PRODUCTS) {
<!-- xsell_products //-->

    $info_box_contents = array();
    $info_box_contents[] = array('align' => 'left', 'text' => TEXT_XSELL_PRODUCTS);
    new contentBoxHeading($info_box_contents);
<? tep_draw_heading_top_3();?>	

    $row = 0;
    $col = 0;
    $info_box_contents = array();
    while ($xsell = tep_db_fetch_array($xsell_query)) {
		if (tep_not_null($xsell['specials_new_products_price'])) {
    $xsell_price =  '<s>' . $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</s><br>';
      	$xsell_price .= '<span class="productSpecialPrice">' . $currencies->display_price($xsell['specials_new_products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</span>';
		} else {
			$xsell_price = '<span class="productSpecialPrice">' .  $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</span>';

$xsell['products_name'] = tep_get_products_name($xsell['products_id']);

 $p_name = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . $xsell['products_name']. '</a>';

$p_buynow ='<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&product_to_buy_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>';

  $xsell_reviews_query = tep_db_query("select r.reviews_rating from " . TABLE_REVIEWS . " r, " . TABLE_PRODUCTS . " p where r.products_id = " . (int)$xsell['products_id'] . "");
         $xsell_reviews = tep_db_fetch_array($xsell_reviews_query);
         $xsell_reviews_rating = (($xsell_reviews['reviews_rating'] >= '1') ? tep_image(DIR_WS_IMAGES . 'stars_' . $xsell_reviews['reviews_rating'] . '.gif' , sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $xsell_reviews['reviews_rating'])) : tep_image(DIR_WS_IMAGES . 'stars_0.gif' , sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, '0')));

       $info_box_contents[$row][$col] = array('align' => 'center',
                                              'params' => '',
                                              'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $xsell['products_image'], $xsell['products_name'], TINY_IMAGE_WIDTH, TINY_IMAGE_HEIGHT) . '<br>' . $xsell['products_name'] . '<br>' . $xsell_reviews_rating . '<br>' . $xsell_price. '<br>'.$p_buynow.'</a>');

   $col ++;
      if ($col >= 1) {
        $col = 0;
        $row ++;
new contentBox($info_box_contents);
<? tep_draw_heading_bottom_3();?>
<!-- xsell_products_eof //-->


Someone when I read around used a weird code that I tried but got an error. the code above doens't generate any errors but doesn't generate any products.

If someone can help, please let me know.


P.S I have asked questions before on this forum and some people seem to be on their period (don't want to mention names), but they seem to be rude and try to be smarter than they really are. So if you are kind enough to keep it nice and kind that would be great. I rather get no help, then someone give me a rude and non sense answer. Sorry but I don't like rude people


Thanks in advance for whoever can help.

Thank you in advance,


Link to comment
Share on other sites



It maybe advisable to keep some of your comments to yourself (period), remember that it is not always easy to understand what an individual wants to create in osc. Advice is given for free many on herespend a lot of time trying to help people because they are good at what they do and want to help.


If I get this correctly you would like to display in catalog/shopping_cart.php the products that you want to cross sell with the item thats in the shopping cart, rather than have them displayed elsewhere on the site.


So you need a way of calling them to the shopping cart page. Hope someone can help as I wouldnt mnd doing this myself.

Getting better with mods but no programmer am I.

Link to comment
Share on other sites


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

  • Create New...