Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

X-Sell modifications


Guest

Recommended Posts

Hello,

 

I have successfully installed the X-Sell contribution & everything works just fine. I am customizing the look of the x-sell cross selling box. I have a OsCommerce catalog for testing purposes set up on our testing servers which you can find here: http://www.hostwithgold.com/osc/product_in...;products_id=28 . You will see the X-Sell products box.

 

I have test items in the catalog & have some on sale for testing purposes. Notice the first item listed for the cross selling:

 

Nelson Anarchy Chaos Paint Blue Shell Yellow Fill

Manufacturer: Nelson Paintballs

MSRP: $64.00

Was: $59.99

Sale: $50.99

Save: 21% this week only!

 

I customized this part to show the MSRP, Our regular price which listed as Was & our Sale price. Then it will display you save 21% on this item. This works just fine for any items on sale. Notice the other two items in the cross sell box...the percentage saved isn't calculating correctly. I used the same code as I did above on the first item. The x-sell script uses a simple if/then statement to show a certain way if the cross sold item is on sale & if not then it will display another way.

 

I have copied the code for this file below. Why it is not displaying the percentage saved for the items not on sale?

 

includes\modules\xsell_products.php

<?php
$xsell_array = array();

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

$xsell_split = new splitPageResults($xsell_query_raw, MAX_DISPLAY_PRODUCTS_NEW);
if ($xsell_split->number_of_rows > 0) {;?>
<table width="100%" cellspacing="0" cellpadding="0">
<tr><td class="main" width="100%"><i><br>Listed below are additional items that will increase your enjoyment of the above product. To add products from this list, select the <b>add checkbox</b> and press the <b>add to cart button</b>.  (Note: When you click add to cart, the above product will be added to your cart by default.)
  <br><br> </i></td></tr>
</table>

 <table class="productListing" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<td colspan="2" align="center" class="productListing-heading" style="padding: 5px;">Add
  </td>
<td width="100%" class="productListing-heading" align="center">
	These Items are Recommended with the Product Above   
</td>
 </tr>
<?php
  $xsell_query = tep_db_query($xsell_split->sql_query);
  while ($xsell = tep_db_fetch_array($xsell_query)) {
  $tnpb_new_price = tep_get_products_special_price($xsell['products_id']);
if ($xsell_price = tep_get_products_special_price($xsell['products_id'])) {
$products_price = 'MSRP: <s>' . $currencies->display_price($xsell['products_msrp'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</s><br>Was: <s>' . $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</s><br> <span class="productSpecialPrice">Sale: ' . $currencies->display_price($xsell_price, tep_get_tax_rate($xsell['products_tax_class_id'])) . '</span><br>Save: ' . ceil((($xsell['products_msrp'] -  $tnpb_new_price) / $xsell['products_msrp']) * 100) . '% this week only! ';
} else {
 $products_price = 'MSRP: <s>' . $currencies->display_price($xsell['products_msrp'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '</s><br>Our Price: ' . $currencies->display_price($xsell['products_price'], tep_get_tax_rate($xsell['products_tax_class_id'])) . '<br>Save: ' . ceil((($xsell['products_msrp'] -  $tnpb_new_price) / $xsell['products_msrp']) * 100) . '% this week only! . ';
  }
  //$tnpb_new_price = tep_get_products_special_price($xsell['products_id']);
  //$tnpb_sale_price = ' ' . ceil((($xsell['products_msrp'] -  $tnpb_new_price) / $xsell['products_msrp']) * 100) . ' ';
?>
 <tr>
 <td class="main" align="center">
 <?php  
  echo tep_draw_checkbox_field('add_recommended[]',$xsell['products_id']); 
  ?>
 </td> 
 <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" align="center" valign="top" class="main"><?php echo '<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="middle" class="smallText"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $xsell['products_id']) . '"><b><u>' . $xsell['products_name'] . '</u></b></a><br> 
Manufacturer: <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $xsell['manufacturers_id']) . '" target="_blank">' . $xsell['manufacturers_name'] . '</a><br>' . $products_price; ?><br /></td>
</tr>

<tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<?php
}
 } else {
?>
 <table>
<tr>
  <td>
  <?php echo tep_draw_separator('pixel_trans.gif', '100%', '10');?>
  </td>
</tr>
<?php 
 }
?>
 </tr>
</table>

Link to comment
Share on other sites

I'm not much of an expert in writing php, but I can find my way around. I think what is happening is that you are asking it to:

 

MSRP - Sale Price / MSRP * 100

 

If there is no Sale price, it will always come up with 100% because MSRP/MSRP = 1 * 100 = 100

Link to comment
Share on other sites

I'm not much of an expert in writing php, but I can find my way around. I think what is happening is that you are asking it to:

 

MSRP - Sale Price / MSRP * 100

 

If there is no Sale price, it will always come up with 100% because MSRP/MSRP = 1 * 100 = 100

Thanks!! I feel like an idiot... :D

 

I didn't even notice that. I am glad I had you look at this.

Link to comment
Share on other sites

I fixed the error this thread was started for, but now I notice another problem related to x-sell. I get this error below ONLY when I add an item to my shopping cart that has Products Attributes attached to the item.

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '{4}8 AND px.xsell_id = p.products_id AND px.xsell_id = pd.products_id AND p.prod' at line 1

SELECT p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id FROM products AS p, products_description AS pd, products_xsell AS px WHERE px.products_id = 30{4}8 AND px.xsell_id = p.products_id AND px.xsell_id = pd.products_id AND p.products_status = '1' AND pd.language_id = '1' ORDER BY p.products_ordered DESC

 

If I remove the Products Attributes I do not have this error. It must be something dealing with x-sell not supporting the Products Attributes. Has anyone had this problem?

 

You can see this with a test catalog on our testing servers: http://www.hostwithgold.com/osc/product_in...?products_id=30.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...