Jump to content
Sign in to follow this  
shpy

Pricelist (HTML) not work with muti languages .

Recommended Posts

I have install the Pricelist (HTML) http://addons.oscommerce.com/info/1705 .

If i have 2 languages at my shop, it will show 2 times the number of product , 2 times the number of categories ... Becouse it show all languages in page. So, i change a litle in code to show only 1 languages, around line 80:

 

$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." [b]and products_description.language_id = '4'[/b] order by products_description.products_name asc");

 

Where "4" is the main languages_id of my shop. But it only show 1 language althougt which langguage the customer chose (every thing else like header, footer, colum... show the right languege had been chosen) .

I want to made the priceslist show the right language where it stand !

 

Fot test, i can put

<?php echo $languages_id; ?>

somewhere out of the function get_products($id_group) and it return the right id language. But if i replace "4" by $languages_id, it not show any product!!

 

Please help me !

 

here the code of pricelist.php

<?php

define('NAVBAR_TITLE', 'Bảng giá'); // This is TITLE Ur price-page
define('TAX_INCREASE', 0); // 0 - No increase, 1 - Add 1%, 5 - Add 5%, Any number - add number%

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("pricelist.php", '', 'SSL')); 
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<META http-equiv=Page-exit content=blendTrans(Duration=0.3)>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<?php require(DIR_WS_INCLUDES . 'meta_tags.php'); ?>
<title><?php echo META_TAG_TITLE; ?></title>
<meta name="description" content="<?php echo META_TAG_DESCRIPTION; ?>" />
<meta name="keywords" content="<?php echo META_TAG_KEYWORDS; ?>" />
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<!--

-->
</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 //--><?php echo "$languages_id" ?>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">
 <!--DWLayoutTable-->
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top">
<table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>

  <td height="51" valign="top">
		<table border="0" cellspacing="0" cellpadding="2">
			 <tr>
				<td class="pageHeading"><?php echo NAVBAR_TITLE ?></td>
			  </tr>
			  <tr>
				<td>
<?php
// 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;
$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." and products_description.language_id = '". (int)$HTTP_GET_VARS['languages_id'] ."' order by products_description.products_name asc");
$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']) . ">".$products_price['products_name']."</td><td align=\"right\" class=\"productListing-data\">".$currencies->display_price($cell,TAX_INCREASE)."</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." and categories_description.language_id = '4'  order by categories_description.categories_id asc");
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>"; // dó®®²? nnd
	}
	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); // n묤󴵲? ad󤤲
}
}
?>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<?php
 get_group(0,0);
?>
</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="0">
<!-- 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'); ?>


Paint for VietNamese :

Share this post


Link to post
Share on other sites

Hi Le Quoc Hung,

 

 

in // list products determined group

change $products_price_query to

 

$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_description.language_id = '".idJazyk($_SESSION["language"])."' and products.products_id = products_description.products_id and products.products_quantity <> 100000".$query." and products.products_id = products_to_categories.products_id and products_to_categories.categories_id = ".$id_group." order by products_description.products_name");

 

 

after // get all groups

add

 

function idJazyk($dir) {

$najdi = tep_db_query("select languages_id from languages where directory='".$dir."' or name='".$dir."' or code='".$dir."'");

$nalezeno = tep_db_fetch_array($najdi);

return $nalezeno["languages_id"];

 

and change $groups_price_query to

$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." and categories_description.language_id = '".idJazyk($_SESSION["language"])."' order by categories_description.categories_name");

Edited by cooldo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×