Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Products_New in columns


Guest

Recommended Posts

I'm stuck working on a solution for displaying the catalog/products_new.php in columns.

 

I can't get the correct price to show, it does not show the correct prices for specials.

Can someone please lead me in the correct direction?

I have tried several solutions, but my head says stop :)

 

Take a look here:

http://lillev.butikknett.com/products_new.php

 

The shop is quite modified but I hope we can make this a contribution when finished.

 

This is my code for now:

<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td colspan="6" class="pageheaderNavigation">  <?php echo $breadcrumb->trail(' - '); ?><hr align="center" width="100%" size="2" color="#3f9c35" noshade></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?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, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_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'))) {
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="smallText"><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></td>
		<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }
?>
  <tr align="center">
	<td colspan="3"><img src="./images/sd-design/full_pages/header_white.jpg"></td>
  </tr>
  <tr>
	<td><table align="center" border="0" width="770" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">

	  <tr>
<?php
// BOF Separate Price Per Customer

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

$no_of_products_new = tep_db_num_rows($products_new_query);
// get all product prices from the table products_groups in one query
// traverse products_new_query for products_id's, store the query result in a numbered array
  while ($_products_new = tep_db_fetch_array($products_new_query)) {
$products_new[] = $_products_new;
$list_of_prdct_ids[] = $_products_new['products_id'];
  } // end while ($_products_new = tep_db_fetch_array($products_new_query))
// a line needed for the selection of the products_id's
 $pg_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_products_new > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $pg_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";  
  }
}
// now get all the customers_group_price's
$pg_query = tep_db_query("select products_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where (".$pg_list_of_prdct_ids.") and customers_group_id =  '" . $customer_group_id . "'");
// put all the info in an array called new_prices
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['customers_group_price']);
}
// we already got the results from the query and put them into an array, can't use while now
//	while ($products_new = tep_db_fetch_array($products_new_query)) {
for ($x = 0; $x < $no_of_products_new; $x++) {	
  $row++;
// replace products prices with those from customers_group table	  
	if(!empty($new_prices)) {
	for ($i = 0; $i < count($new_prices); $i++) {
		if( $products_new[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
		$products_new[$x]['products_price'] = $new_prices[$i]['products_price'];
		}
	}
} // end if(!empty($new_prices)

  echo '			<td align="center" width="33%" class="smallText"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new[$x]['products_image'], $products_new[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new[$x]['products_id']) . '">' . $products_new[$x]['products_name'] . '</a><br>' . $currencies->display_price($products_new[$x]['products_price'], tep_get_tax_rate($products_new[$x]['products_tax_class_id'])) . '<br><br></td>' . "\n";
// EOF Separate Price per Customer, products_new code
  if ((($row / 3) == floor($row / 3))) {
?>
	  </tr>
	  <tr>
<?php
  }
}
?>
	  </tr>
	</table></td>
  </tr>
  <tr align="center">
	<td colspan="3"><img src="./images/sd-design/full_pages/footer_white.jpg"></td>
  </tr>
  <tr>
	<td height="10"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
</table></td>
<!-- body_text_eof //-->

 </tr>
</table>
<!-- body_eof //-->

 

Thanks !

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...