Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Cross Sell (X-Sell) Admin


dreamscape

Recommended Posts

  • 4 weeks later...

Is there a way to add the "related products" box underneath the shopping cart basket as the customer is checking out? I really dont want it under each product because its usualy a distraction. So if its only in the checkout process, they might add something before the leave. I know its probably complicated programming, but anyone know if its at least possible?

Link to comment
Share on other sites

I had to remove the images because I have 1300 products and the page load was incredibly long...I think adding thumbs to that page is a bad idea for most users. A split_page_results would be great. Anyone want to add this?

 

I have MS1 and it took me about an hour to get it working the way I want it too.

Link to comment
Share on other sites

I had to remove the images because I have 1300 products and the page load was incredibly long...I think adding thumbs to that page is a bad idea for most users. A split_page_results would be great. Anyone want to add this?

 

I have MS1 and it took me about an hour to get it working the way I want it too.

Yea...I started it..... didnt finish it....kicked my butt.... the original code is kinda...uh.... well... the latest release added search capabilities which was good enough for me so I don't have to load all the pictures...I have over 3,000 now in my catalog so the original code was not an option either :blink:

Link to comment
Share on other sites

Is there a way to add the "related products" box underneath the shopping cart basket as the customer is checking out? I really dont want it under each product because its usualy a distraction. So if its only in the checkout process, they might add something before the leave. I know its probably complicated programming, but anyone know if its at least possible?

It's quite possible. You should just be able to paste bits out of product_info.php into the basket page. Shouldn't take too long.

Link to comment
Share on other sites

I've been messing with having the cross-sell items display as in products_new.php. I can get the new products to display, but not the xsell ones. I'm having trouble converting this query:

 

$products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added,

IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name" . $new_fields . "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_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 p.products_status = '1' and products_date_added > now() - interval 30 day order by p.products_date_added DESC, pd.products_name";

 

I can get it to work in myphpadmin doing:

SELECT DISTINCT p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added

FROM products_xsell xp, products p, products_description pd

WHERE xp.products_id = '10673' AND xp.xsell_id = p.products_id AND p.products_id = pd.products_id AND p.products_status = '1';

 

which displays the correct results, however I get a sql error when I try to do this in the module.

 

Any help would be appreciated. Thanks

Link to comment
Share on other sites

I changed my /catalog/includes/modules/xsell_products.php to:

 

 

<?php

$products_new_array = array();

 

$products_new_query_raw = "SELECT p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, xp.xsell_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_XSELL . " xp left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where p.products_status = '1' AND p.products_id = xp.xsell_id AND xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "' ORDER BY p.products_date_added DESC, pd.products_name";

 

$products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 

if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {

?>

 

<?php

}

?>

 

<table width="100%" cellspacing="0" cellpadding="2">

<tr><td> </td></tr>

<tr>

<td height="14" class="infoBoxHeading"><img src="images/infobox/corner_right_left.gif" border="0" alt="" width="11" height="14"></td>

<td width="100%" height="14" class="infoBoxHeading">Suggested Products</td>

<td width="100%" height="14" class="infoBoxHeading"></td>

</tr>

 

<?php

if ($products_new_split->number_of_rows > 0) {

$products_new_query = tep_db_query($products_new_split->sql_query);

while ($products_new = tep_db_fetch_array($products_new_query)) {

if ($new_price = tep_get_products_special_price($products_new['products_id'])) {

$products_price = '<s>' . $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($products_new['products_tax_class_id'])) . '</span>';

} else {

$products_price = $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id']));

}

?>

<tr>

<td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>

<td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '"><b><u>' . $products_new['products_name'] . '</u></b></a><br>Manufacturer: ' . $products_new['manufacturers_name'] . '<br>Price: ' . $products_price; ?></td>

 

<td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>

</tr>

<tr>

<td colsp?an="3">

<?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?>

</td>

</tr>

<?php

}

}

?>

</tr>

</table>

 

The only problem. If you click on 'Add to Cart' on one of the suggested products, and then click continue shopping, it doesn't bring me back to the original product, it brings me to the product that I just put in my cart. Does anyone have a solution for this problem?

 

Thanks

Link to comment
Share on other sites

After a little more thinking.... this works better:

 

<?php

$products_new_array = array();

 

$products_new_query_raw = "SELECT p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, xp.xsell_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_XSELL . " xp left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where p.products_status = '1' AND p.products_id = xp.xsell_id AND xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "' ORDER BY p.products_date_added DESC, pd.products_name";

 

$products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 

if ($products_new_split->number_of_rows > 0) { ;?>

<table class="productListing" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td height="14" class="productListing-heading"><img src="images/infobox/corner_right_left.gif" border="0" alt="" width="11" height="14"></td>

<td width="100%" height="14" class="infoBoxHeading">Suggested Products</td>

<td width="100%" height="14" class="infoBoxHeading"></td>

</tr>

 

<?php

$products_new_query = tep_db_query($products_new_split->sql_query);

while ($products_new = tep_db_fetch_array($products_new_query)) {

if ($new_price = tep_get_products_special_price($products_new['products_id'])) {

$products_price = '<s>' . $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($products_new['products_tax_class_id'])) . '</span>';

} else {

$products_price = $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id']));

}

?>

<tr>

<td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>

<td valign="top" class="smallText"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '"><b><u>' . $products_new['products_name'] . '</u></b></a><br>Manufacturer: ' . $products_new['manufacturers_name'] . '<br>Price: ' . $products_price; ?></td>

 

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

 

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

 

<?php

}

}

?>

</tr>

</table>

Link to comment
Share on other sites

  • 5 weeks later...

Hello all,

 

I have tried to modify my xsell_products.php by removing the (annoying) arrays because of the insufficient use of tables.

 

Problem is that the code gives no error at all and it doesnt view anything either, but be aware that i have added 'xsell' products to the following product im viewing.

 

This is how it looks like [catalog/modules/xsell_products.php]:

 

<?php

/*

$Id: xsell_products.php, v1 2002/09/11

 

osCommerce, Open Source E-Commerce Solutions

<http://www.oscommerce.com>

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

if ($HTTP_GET_VARS['products_id']) {

$products_to_products_query = tep_db_query("select distinct p.products_id, p.products_image, pd.products_name from " . TABLE_PRODUCTS_XSELL . " xp, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and xp.xsell_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_status = '1' and pd.products_name > '' order by xp.products_id asc limit " . MAX_DISPLAY_ALSO_PURCHASED);

$products_to_products_count_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_XSELL . " pa where pa.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pa.xsell_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and pd.products_name > '' and p.products_status = '1'");

$products_count = tep_db_fetch_array($products_to_products_count_query);

}

?>

<!-- xsell_products //-->

<?php

 

if ($products_count['count'] > 0) {

echo '<table> ';

 

 

while ($xsell = tep_db_fetch_array($xsell_query)) {

 

$rows++;

$products_to_products_list = '

<tr><td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $xsell['products_image'], $xsell['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td><td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . $xsell['products_name'] .'</a></td><td valign="top">' . $xsell_price. '</td><td valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a></td></tr>

';

 

 

$boxContent = $products_to_products_list;

 

 

echo $boxContent;

 

}

echo '</table>';

}

?>

//Maz

Link to comment
Share on other sites

Hello everyone

 

I've modified the front end module to actually add the related product directly to the shopping cart without leaving the main product information page.

 

I've also added a quantity box just before the BUY NOW button and a simple pop-up window to tell them that it's been added to the cart successfully.

 

If anyone's interested I'll post the code. :)

 

Regards

 

Neil

Link to comment
Share on other sites

Ok, there's no point picking through exactly what I did so here's the whole module. Just copy and paste this code into a file, name it what you want (mine's called xsell_products_buynow.php and place it in your modules folder.

 

You simply call this module from the product_info page. I use:

 

<?php include("includes/modules/xsell_products_buynow.php");?> to do this.

 

Ok here's my version of the module:

 

<table class="box" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center"><BR><B>Related items & accessories for this product:</B><BR><BR>
<script type="text/javascript">
<!--
function acknowledge()
{	var agree = confirm("This item will be added to your cart");
if (agree)
{	return true;
}
else
{	return false;
}
}
//-->
</script>
<?php
/* 
$Id: xsell_products.php, v1  2002/09/11

osCommerce, Open Source E-Commerce Solutions 
<http://www.oscommerce.com> 

Copyright (c) 2002 osCommerce 

Released under the GNU General Public License 
*/ 

if ($HTTP_GET_VARS['products_id']) { 
$xsell_query = tep_db_query("select distinct p.products_id, p.products_image, pd.products_name, p.products_tax_class_id, products_price from " . TABLE_PRODUCTS_XSELL . " xp, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where xp.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and xp.xsell_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_status = '1' order by xp.products_id asc limit " . MAX_DISPLAY_ALSO_PURCHASED); 
$num_products_xsell = tep_db_num_rows($xsell_query); 
if ($num_products_xsell >= MIN_DISPLAY_XSELL) { 
?> 
<!-- xsell_products //-->
<?php
     $info_box_contents = array();
     $info_box_contents[] = array('align' => 'left', 'text' => '');
     new contentBoxHeading($info_box_contents);

     $row = 0;
     $col = 0;
     $info_box_contents = array();
     while ($xsell = tep_db_fetch_array($xsell_query)) {
       $xsell['specials_new_products_price'] = tep_get_products_special_price($xsell['products_id']); 

if ($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 =  $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])); 
   } 
       $info_box_contents[$row][$col] = array('align' => 'center',
                                              'params' => 'class="smallText" width="33%" valign="top"',
                                             // 'text' => tep_image(DIR_WS_IMAGES . $xsell['products_image'], $xsell['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . $xsell['products_name'] .'</a><br>' . $xsell_price. '<br>
             //<a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');
       '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'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '">' . $xsell['products_name'] .'</a><br><b>' . $xsell_price. '</b><br><BR>
 <form onsubmit="javascript:return acknowledge();" name="cart" method="post" action="'.tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL').'">Qty <input type="text" name="cart_quantity" value="1" maxlength="2" size="2" onfocus="javascript:this.value=\'\';" style="background-color:99a6b8;border-color:#001c42;color:#001c42;border-style:solid;border-width:1px;font:11px arial;font-weight:normal;width:20px">
                 <input type="hidden" name="products_id" value="'.$xsell['products_id'].'">
                 <input type="submit" name="Submit" value="BUY NOW" style="background-color:#cccccc;color:#001C42;border-color:#001C42;border-style:solid;border-width:1px;font:11px arial;font-weight:normal;width:70px"><BR><BR>
                  </form>');
       $col ++;
       if ($col > 2) {
         $col = 0;
         $row ++;
       }
     }
     new contentBox($info_box_contents);
?>
<!-- xsell_products_eof //-->




<?php
   }
 }
 if ($row ==0)
{	echo('Sorry, there are no selected accessories or related items for this product');
}
?>
</td></tr></table><BR>

 

It simply lists the xsell products and places a buy now button and quantity box just below each product.

 

PLEASE NOTE YOUR OSCOMMERCE MUST BE SET TO NOT SHOW THE SHOPPING CART AFTER ADDING A PRODUCT.

 

If this is setup ok your user will stay on the main product information page but be able to add any number of your cross sell products to the shopping cart from there.

 

i'm not an expert, in fact a real amatuer, but I do think this works.

Link to comment
Share on other sites

Great solution for the "buy it now" buttons without it leaving the product as it did on link buttons.

 

I have combined the code with my "no stock, no purchase" system, quite simple thing if anyone is interested i can paste the code here for use! :-)

//Maz

Link to comment
Share on other sites

Can someone help me?

I've seen a lot of different contributions made for the x-sell mod but the one I have doesn't work. I have installed: X-SELL Update - http://www.oscommerce.com/community/contributions,1773

 

What can I do to make it work?

When I go to the "admin" > "Cross Sell Products" I have no way of adding items

Also when I view an item in the catalog in admin and click on the "X-Sell - EDIT" button, all I get is a delete button, and a text box with the word "Suchen" above it

 

 

 

As for all the contributions, are the following all the same?

Which ones are working?

 

----------------------------------------------------------------

Cross Sell (X-Sell) Admin

Last update: 04/01/2003

http://www.oscommerce.com/community/contributions,1005

 

Cross Sell Module v.09

Last update: 04/10/2003

http://www.oscommerce.com/community/contributions,334/page,3

 

X-Sell v2-MS2 - Cross Sell for MS2

Last update: 11/17/2003

http://www.oscommerce.com/community/contributions,1415

 

X-SELL Update

Last update: 01/12/2004

http://www.oscommerce.com/community/contributions,1773

 

XSELL - Updated Product Listing

Last update: 02/20/2004

http://www.oscommerce.com/community/contributions,1808

----------------------------------------------------------------

Link to comment
Share on other sites

osCommerce has to set a few admins to clean the contribution section, cause its a mixed up crazy place.

 

I could not get one of these contribution to work without changing the code COMPLETELY.

 

I have no clue and or dont have any patience to install something nonworking.

//Maz

Link to comment
Share on other sites

Can someone help me with this....all of a sudden in the admin section, when I click on Cross Sell Products i get the following error:

 

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 129 bytes) in /path/to/admin/xsell_products.php on line 110

 

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 137 bytes) in Unknown on line 0

 

Warning: Unknown(): A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0

 

 

What is causing this and how can I fix it???

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...