Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

help with printable price list


Guest

Recommended Posts

I have added the following file to create a printable price list. The problem is each product displays 3 prices in each language making the price list really long. I would like to know how to make this list display only english and only usd

<?php

define('TITLE_PRICE', 'Price List'); 
//define('TITLE_PRICE', 'Price List');

require('includes/application_top.php');
// the following cPath references come from application_top.php
$category_depth = 'top';
if (isset($cPath) && tep_not_null($cPath)) {
	$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
	$cateqories_products = tep_db_fetch_array($categories_products_query);
	if ($cateqories_products['total'] > 0) {
		$category_depth = 'products'; // display products
	} else {
		$category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
		$category_parent = tep_db_fetch_array($category_parent_query);
		if ($category_parent['total'] > 0) {
			$category_depth = 'nested'; // navigate through the categories
		} else {
			$category_depth = 'products'; // category has no products, but display the 'no products' message
		}
	}
}
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);
$breadcrumb->add(TITLE_PRICE, tep_href_link("price.php", '', 'SSL')); 
?>

<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
	<?php require(DIR_WS_INCLUDES . 'header.php');?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
<tr>
	<td width="<?php echo BOX_WIDTH; ?>" valign="top">
		<table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
			<!-- left_navigation //-->
				<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
			<!-- left_navigation_eof //-->
		</table>
	</td>
	<!-- body_text //-->
	<td valign="top">
		<table border="0" cellspacing="0" cellpadding="2">
			 <tr>
				<td class="pageHeading"><? echo TITLE_PRICE ?></td>
			  </tr>
			  <tr>
				<td>
<?
// åñòü ó ãðóïïû ïðîäóêòû?
// groups have products?
function check_products($id_group){
$products_price_query = tep_db_query("select products_to_categories.products_id FROM products_to_categories where products_to_categories.categories_id = ".$id_group." LIMIT 0,1");
if($products_price = tep_db_fetch_array($products_price_query)){
	return true;	
}
return false;
}

// âûâîäèì ñïèñîê ïðîäóêòîâ îïðåäåëåííîé ãðóïïû $id_group
// list products determined group
function get_products($id_group){
$currencies = new currencies();
$products_price_query = tep_db_query("select products_description.products_name, products.products_price, products_to_categories.products_id, products_to_categories.categories_id FROM products, products_description, products_to_categories where products.products_id = products_description.products_id and products.products_id = products_to_categories.products_id and products_to_categories.categories_id = ".$id_group);
$x=0;
while ($products_price = tep_db_fetch_array($products_price_query)){
	$cell = tep_get_products_special_price($products_price['products_id']);
	if($cell == 0)
		$cell = $products_price['products_price'];
	if($x==1) {
		$col = "#F8F8F9";
		$x = 0;	
	}else{
		$col = "#FFFFFF";
		$x++;
	}
	print "<tr bgcolor=\"".$col."\"><td class=\"productListing-data\">        <a href=\"" . tep_href_link(FILENAME_PRODUCT_INFO, "products_id=" . $products_price['products_id']) . "\"<a>".$products_price['products_name']."</td><td align=\"right\" class=\"productListing-data\">".$currencies->display_price($cell,1)."</td></tr>";
}
}

// ðåêóðñèâíàÿ ôóíêöèÿ, ïîëó÷àåò ãðóïïû ïî ïîðÿäêó
// get all groups
function get_group($id_parent,$position){
$groups_price_query = tep_db_query("select categories.categories_id, categories_description.categories_name from categories, categories_description where categories.categories_id = categories_description.categories_id and categories.parent_id = ".$id_parent);
while ($groups_price = tep_db_fetch_array($groups_price_query)){
	$str = "";
	for($i = 0; $i < $position; $i++){
		$str = $str . "        ";
	}
	$class = "productListing-heading";
	if($position == 0) {
		$class = "headerNavigation";
		print "<tr><td colspan=\"2\" width=\"1000\" class=\"productListing-data\"> </td></tr>"; // ïóñòàÿ ñòðîêà
	}
	if(check_products($groups_price['categories_id']) || $position == 0){
		print "<tr><td colspan=\"2\" width=\"1000\" class=\"".$class."\"><strong><font color=\"#FFFFFF\">".$str.$groups_price['categories_name']."</font></strong></td></tr>";
		get_products($groups_price['categories_id']);
	}
	get_group($groups_price['categories_id'],$position+1); // ñëåäóþùàÿ ãðóïïà
}
}
?>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<?
 get_group(0,0);
?>
</table>
				</td>
			  </tr>
		</table>
	</td>
	<!-- body_text_eof //-->
	<td width="<?php echo BOX_WIDTH; ?>" valign="top">
		<table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
		<!-- right_navigation //-->
			<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
		<!-- right_navigation_eof //-->
		</table>
	</td>
</tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

you need to restrict on product description language_id must also be your selected language in the sql

 

$products_price_query

 

For more info on selects see www.w3schools.com

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites

you need to restrict on product description language_id must also be your selected language in the sql

 

$products_price_query

 

For more info on selects see www.w3schools.com

 

So are all the changes in the sql or is there something in this file I need to change too (above in the orig. post)

Link to comment
Share on other sites

Search for

 

$products_price_query

 

in the above post and all might become clear.

 

G

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites

Search for

 

$products_price_query

 

in the above post and all might become clear.

 

G

Thanks for responding but I still am unsure on how to change it. Sorry. I am sure I dont need to say this (you have prob figured it out) but I am not a pro with php

Link to comment
Share on other sites

Ok here is my new version of the code making it printable but still the same prob....It lists every product in every language and currrency. I only want english and us dollars to appear. Does any one know how to change the code so only english and usd is included in the price list???

 

<?php

// Begin configuration

define('TITLE_PRICE_LIST', 'Price List'); // This is the title for your price page
define('DATE_PRICE_LIST', '- M jS, Y'); // date format (empty - none, M - month, jS - day of month, Y - year; see www.php.net/date)
define('PRINT_VIEW', 'Printable Version'); // text for link to printable view 
define('FULL_VIEW', 'Normal Version'); // text for link to normal view
define('TAX_INCREASE', 0); // 0 - No increase, 1 - Add 1%, 5 - Add 5%, Any number - add number%
define('NO_PRICE', 'Call'); // show when product has no price or zero price (blank -   , or e.g. Call for Price)
define('SHOW_QUANTITY',false); // true - show, false - hide quantity
define('QUANTITY_TEXT', 'Qty.'); // This is the heading for quantity column
define('SHOW_MARKED_OUT_STOCK',true); // show marked out of stock (true - show, false - hide)
define('SHOW_MODEL',false); // true - show model, false - hide model
define('WIDTH_PRICE_LIST', '750'); // width of price list in pixels (0 - tight, 1000 - loose)
define('INDENT_PRICE_LIST', '30'); // width of identation subcategories in pixels (0 - none, 30 - wide)
define('INDENT_PRICE_LIST_COLOR', 'b6b7cb'); // colour of the indentation 

// End configuration

require('includes/application_top.php');
// the following cPath references come from application_top.php
$category_depth = 'top';
if (isset($cPath) && tep_not_null($cPath)) {
	$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
	$cateqories_products = tep_db_fetch_array($categories_products_query);
	if ($cateqories_products['total'] > 0) {
		$category_depth = 'products'; // display products
	} else {
		$category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
		$category_parent = tep_db_fetch_array($category_parent_query);
		if ($category_parent['total'] > 0) {
			$category_depth = 'nested'; // navigate through the categories
		} else {
			$category_depth = 'products'; // category has no products, but display the 'no products' message
		}
	}
}

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);
$breadcrumb->add(TITLE_PRICE_LIST, tep_href_link("price_list.php", '', 'SSL')); 
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<style type="text/css">
<!--
td.priceListWidth{
 width:<?php echo WIDTH_PRICE_LIST; ?>px;
} 
td.priceListIndent {
 background-color:<?php echo INDENT_PRICE_LIST_COLOR; ?>;
 width:<?php echo INDENT_PRICE_LIST; ?>;
} 
--></style>

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
<?php  // print function and edit remove by willross
if ($print=="yes"){?>
<!-- column_left disabled for print //-->
<?php } else {?>
	<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<?php }?>
	<!-- body_text //-->


<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td valign="top">			<table border="0" cellspacing="0" cellpadding="2">
			 <tr>
				<td class="pageHeading"><?php echo TITLE_PRICE_LIST ?> <?php echo date(DATE_PRICE_LIST); ?><sup>
<?php  // print function and edit remove by willross
if ($print=="yes"){?>
<font style="font-size:10px"><a href="price_list.php">[<?php echo FULL_VIEW ?>]</a></font>
<?php } else {?>
<font style="font-size:10px"><a href="price_list.php?print=yes">[<?php echo PRINT_VIEW ?>]</a></font>
<?php }?></sup>
			   </td>
			  </tr>
			  <tr>
				<td>
<?
// groups have products?
function check_products($id_group){
$products_price_query = tep_db_query("select products_to_categories.products_id FROM products_to_categories where products_to_categories.categories_id = ".$id_group." LIMIT 0,1");
if($products_price = tep_db_fetch_array($products_price_query)){
	return true;	
}
return false;
}

// list products determined group 
function get_products($id_group){
global $currencies;
	$query = "";
if(!SHOW_MARKED_OUT_STOCK){
	$query = " and products.products_status = 1";
}
$products_price_query = tep_db_query("select products_description.products_name, products.products_quantity, products.products_price, products.products_model, products_to_categories.products_id, products_to_categories.categories_id FROM products, products_description, products_to_categories where products.products_id = products_description.products_id and products.products_quantity <> 0".$query." and products.products_id = products_to_categories.products_id and products_to_categories.categories_id = ".$id_group." ORDER BY products_description.products_name");
	$x=0;
while ($products_price = tep_db_fetch_array($products_price_query)){
	$cell = tep_get_products_special_price($products_price['products_id']);
	if($cell == 0)
		$cell = $products_price['products_price'];
	if($x==1) {
		$col = "#F8F8F9";
		$x = 0;	
	}else{
		$col = "#FFFFFF";
		$x++;
	}
	$quantity = "";
	$model = "";
	if(SHOW_QUANTITY) 
		$quantity = "<td  align=\"right\" class=\"productListing-data\"> (".$products_price['products_quantity'].")</td>";
	if(SHOW_MODEL)
		$model = "<td align=\"LEFT\" class=\"productListing-data\">".$products_price['products_model']."</td>";
	print "<tr bgcolor=\"".$col."\"><td class=\"productListing-data\"><table align=\"LEFT\" cellpadding=\"1\" cellspacing=\"0\" ><tr><td  class=\"priceListIndent\" ></td><td class=\"productListing-data\" > </td></tr></table></td>".$model."<td class=\"productListing-data\" ><a href=" . tep_href_link( FILENAME_PRODUCT_INFO, "products_id=" . $products_price['products_id']) . "> ".$products_price['products_name']."</td><td align=\"right\" class=\"productListing-data\"> " . (($products_price['products_price'] > 0) ? $currencies->display_price($cell,TAX_INCREASE) : NO_PRICE ) ."</td>".$quantity."</tr>";
}
}

// get all groups
function get_group($id_parent,$position){
	$qty_text = "";
if(SHOW_QUANTITY) {
	$qty_text = "".QUANTITY_TEXT."";
}else{
	$qty_text = " ";
}
$groups_price_query = tep_db_query("select categories.categories_id, categories_description.categories_name from categories, categories_description where categories.categories_id = categories_description.categories_id and categories.parent_id = ".$id_parent." ORDER BY categories_description.categories_name");
while ($groups_price = tep_db_fetch_array($groups_price_query)){
	$str = "";
	for($i = 0; $i < $position; $i++){
		$str = $str . "<table align=\"LEFT\" cellpadding=\"0\" cellspacing=\"0\" ><tr><td  class=\"priceListIndent\" ></td><td class=\"productListing-heading\" > </td></tr></table>";
	}
	$class = "productListing-heading";
	if($position == 0) {
		$class = "headerNavigation";
		print "<tr><td colspan=\"5\" class=\"priceListWidth\"><table align=\"right\" cellpadding=\"0\" cellspacing=\"0\" ><tr><td class=\"productListing-data\">".$qty_text."</td></tr></table></td></tr>"; // dónnr? nndîer
	}
	if(check_products($groups_price['categories_id']) || $position == 0){
		print "<tr><td colspan=\"5\" class=\"".$class."\"><strong><font color=\"#FFFFFF\">".$str.$groups_price['categories_name']."</font></strong></td></tr>";
		get_products($groups_price['categories_id']);
	}
	get_group($groups_price['categories_id'],$position+1); // nëläótur? adóddr
}
}
?>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<?
 get_group(0,0);
?>
<tr>
<?php  // print function and edit remove by willross
if ($print=="yes"){?>
<!-- column_right disabled for print //-->
<?php } else {?>
		<td colspan="5"><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
		</tr>

</table>					</td>
			  </tr>
		</table></td>
	<!-- body_text //-->
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
 </tr>

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

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->

<?php }?>
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

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...