Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How can i show a product ONLY in one language and not in the other?


g_p_java

Recommended Posts

Posted

Hello,

 

i have a question related to products and languages.

I would like to show a product only in one language and not in the other,

can this be done by using oscommerce??

 

thanks, in advance

Posted

Yes, you can limit the website to just one language by simply deleting all other languages from the admin>localization>languages section.

 

 

 

Chris

Posted

thanks for replying,

 

but i would like to have two languages in my site,

sometimes some products are only available in one language

and not in the other.

that means that these products shall appear only

in the one language and not in the other,

but the system by default shows both entries

in customers pages,

 

so i would like to have radio buttons and choose if

the product shall appear only in first language, only in second

language or in both(this is supported by default from the oscommerce)

Posted

well, there is a way to hack your code to support this, but there is no ready made code that you can use.

 

I would do it the following way ...

 

1) no radio buttons, the marker would be for me the products name ... no name entered in admin means do not show in catalog

2) then on all products pages (and modules) alter the queries to include the products name - some queries already have it included, in some cases the products name is called by a function later on

3) alter then all these queries to exclude products where the products name is not filled (empty string)

4) to make sure noone comes to the product info page by a direct link and the forbidden language in the session, you'd need to alter the product info page to set an error message similar to the product not found message it already - again by checking whether there is a product name or not.

 

you are aware though that people can change the language up until the moment they are doing the final order confirmation? even on the checkout pages, the language can be changed by manipulating the url ...

 

so I would probably add

5) when checking out, double check if the cart holds items that are not allowed to be checked out in a certain language, and if they are, send the user back to the cart to remove it. it may be more efficient to do this by ship-to-country, hmmmmm?

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

  • 2 weeks later...
Posted

thank you very much for replying, i'm working on that and i use as marker the products name.

but i have some questions to make:

 

to make sure noone comes to the product info page by a direct link and the forbidden language in the session, you'd need to alter the product info page to set an error message similar to the product not found message it already - again by checking whether there is a product name or not

 

In product_info.php in line 17, there is a query which selects the amount of products from products and products_description tables.

I altered this query and i added: and pd.products_name!=''

select count(*) as total from... where p.products_status = '1' and pd.products_name!='' ... etc

then in line 49 there is an if/else condition.

if ($product_check['total'] < 1) {
... TEXT_PRODUCT_NOT_FOUND ... 
}

1. Is it necessary to add a new error message in products_info.php?

cause i think(i may be wrong) that this message works if someone tries to access a product in a different language where this product does not exist.

What is your opinion??

 

2.

noone comes to the product info page by a direct link and the forbidden language in the session

Hm..let's say i have that product which is only available in english language.

The link for the product is: http://localhost/shop/catalog/product_info.php?cPath=22&products_id=34

If sm does http://localhost/shop/catalog/product_info.php?cPath=22&products_id=34&language=de ,he is going to be directed

to a page where the error appears.

Is there any way to access a direct link and the forbidden language in the session than the one above??where we add at the end of the link the &language=de

 

3.

you are aware though that people can change the language up until the moment they are doing the final order confirmation? even on the checkout pages, the language can be changed by manipulating the url ...

How can sm manipulate the url in check out pages??let's say that i was in page

http://localhost/shop/catalog/checkout_shipping.php i added at the end of the link &language=de,it didn't work and i couldn't change the language,

How sm can do that??

 

4.

when checking out, double check if the cart holds items that are not allowed to be checked out in a certain language, and if they are, send the user back to the cart to remove it. it may be more efficient to do this by ship-to-country, hmmmmm?

 

When you say by ship-to-country,what exactly do you mean??

 

 

thanks, in advance

Posted

thanks for replying,

 

but i would like to have two languages in my site,

sometimes some products are only available in one language

and not in the other.

that means that these products shall appear only

in the one language and not in the other,

but the system by default shows both entries

in customers pages,

 

so i would like to have radio buttons and choose if

the product shall appear only in first language, only in second

language or in both(this is supported by default from the oscommerce)

 

Hello,

 

I would like also to have some products only available in one language. Do you succeed to do this? Can you help me please?

Posted

Hello,

 

I would like also to have some products only available in one language. Do you succeed to do this? Can you help me please?

 

Hello, i’m actually working on that, haven't finished it yet and still making many tests to be sure that is works.

In many files I have altered the queries and I try to exclude products whose name is empty(has not been filled by the administrator)

The products_name field is in products_description table in the database.

In php files this table is defined as TABLE_PRODUCTS_DESCRIPTION.

If products_name field is empty(is not filled) we don’t show the product.

 

For example, let’s say that we have just added a new product in admin pages and we have filled the products name in one language and not in the other.

In the catalog(layout) this product is going to appear in both languages and in many places,

such as specials,what’s new box,upcoming products,product info pages,shopping cart etc.

e.g. in catalog/products_info.php file I have altered two queries

 

old query in line 17:

 

$product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

New query:

 

 $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and pd.products_name!='' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

Old query in line 72

$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

New query:

 

$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and pd.products_name!='' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

 

You shall notice that these queries already include TABLE_PRODUCTS_DESCRIPTION and I just added pd.products_name!=''.

 

In other queries in other files, TABLE_PRODUCTS_DESCRIPTION is not included in the query and you shall add it in order to have the desirable result.

 

Be careful to alter the right queries in the right files and sometimes use mysql command client or mysql query browser in order to see the results of the queries in the database before you alter the queries in the files and check if you get the right results.

 

I have also altered these files:

catalog/products_reviews.php

catalog/product_reviews_info.php

catalog/products_reviews_write.php

catalog/products_new.php

catalog/specials.php

catalog/advanced_search_result.php

catalog/includes/boxes/best_sellers.php

catalog/includes/boxes/specials.php

catalog/includes/boxes/whats_new.php

catalog/includes/boxes/categories.php(there is a reference to a function which returns the amount of products in a category, this function is called tep_count_products_in_category($counter); ,it is in line 48 and it is located in file includes/functions/general.php)

 

I altered that function in file includes/functions/general.php to:

 

function tep_count_products_in_category($category_id, $include_inactive = false) {
   $products_count = 0;

   /* NEW */
   global $languages_id;
   /* NEW */

if ($include_inactive == true) {
             $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c 
             where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "'");
       } else {
             /*$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . 
        TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' 
        and p2c.categories_id = '" . (int)$category_id . "'");*/

              /* NEW */
	$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . 
	TABLE_PRODUCTS_DESCRIPTION . " pd, "  . 
	TABLE_PRODUCTS_TO_CATEGORIES . " p2c 
	where p.products_id = p2c.products_id and p2c.products_id = pd.products_id and p.products_status = '1' 
	and pd.products_name!='' and pd.language_id = '" . (int)$languages_id . "' 
	and p2c.categories_id = '" . (int)$category_id . "'");
	/* NEW */
}

}

 

Generally, i’m working on that too and I have to alter many files too e.g. shopping cart,orders etc

I’m testing the modified files cause I have to be sure that I have made the right alterations and the shop works fine.

Cause many changes have to happen

You shall read Monica’s in Germany post which helped me vey very much and

read her advices cause they are really really helpful("when checking out, double check if the cart holds items that are not allowed to be checked out in a certain language, and if they are, send the user back to the cart to remove it...")

 

Hope i helped you :)

Posted

Thank you for your help.

 

In catalog/includes/boxes/whats_new.php How do you change this line?

 

  if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {

 

is it good if I put these:

  if ($random_product = tep_random_select("select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and pd.products_name!='' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC limit " . MAX_RANDOM_SELECT_NEW)) {

 

and do you suceed to do that: ("when checking out, double check if the cart holds items that are not allowed to be checked out in a certain language, and if they are, send the user back to the cart to remove it...")?

Posted

Hello, in includes/boxes/whats_new.php i have altered the query in this way

 

if ($random_product = tep_random_select("select p.products_id, p.products_image, p.products_tax_class_id, p.products_price from " . 
 TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' 
 and p.products_id = pd.products_id and pd.products_name!='' and pd.language_id = '" . (int)$languages_id . "'
 order by p.products_date_added desc limit " . MAX_RANDOM_SELECT_NEW))

 

 

You have made this:

 

if ($random_product = tep_random_select("select p.products_id, pd.products_name, p.products_image, 
p.products_price, p.products_tax_class_id, p.products_date_added from " . TABLE_PRODUCTS . " p, " . 
TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and pd.products_name!='' 
and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC limit " . MAX_RANDOM_SELECT_NEW)) {

 

As i can see we have made the same modifications in the file.

In select query you choose to select six fields(products_id,products_image,price,tax_class_id,products_name and products date added)

You have added two more fields in select that's the only difference with my query.

 

"when checking out, double check if the cart holds items that are not allowed to be checked out in a certain language, and if they are, send the user back to the cart to remove it..."

 

I'm working on that and i haven't made any modifications yet cause i study the tables in the database in order

to see in which files i shall make the alterations.

Posted

Thank you very much,

 

And how do you change the index.php or the product_listing.php?

 

Hello,

 

i have modified index.php file in lines

 

175,178,184,187,237,239 i have altered these queries and i have added pd.products_name!=''

 

In file products_listing.php, i haven't made any modifications there,

i don't know if i make any changes,

What is your opinion??

Posted

Hello;

 

So for example you change this line:

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";

 

In this way:

 

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and pd.products_name!='' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";

 

In fact I hesitated to altered index.php or product_listing.php. So I try to change product_listing.php by adding if ($listing['products_name']!='') { juste before

for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {

$lc_align = '';

switch ($column_list[$col]) {

case 'PRODUCT_LIST_MODEL':

$lc_align = '';

$lc_text = ' ' . $listing['products_model'] . ' ';

break;

case 'PRODUCT_LIST_NAME':

$lc_align = '';

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';

} else {

$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';

}

break;

case 'PRODUCT_LIST_MANUFACTURER':

$lc_align = '';

$lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> ';

break;

case 'PRODUCT_LIST_PRICE':

$lc_align = 'right';

if (tep_not_null($listing['specials_new_products_price'])) {

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

} else {

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

}

break;

case 'PRODUCT_LIST_QUANTITY':

$lc_align = 'right';

$lc_text = ' ' . $listing['products_quantity'] . ' ';

break;

case 'PRODUCT_LIST_WEIGHT':

$lc_align = 'right';

$lc_text = ' ' . $listing['products_weight'] . ' ';

break;

case 'PRODUCT_LIST_IMAGE':

$lc_align = 'center';

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';

} else {

$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';

}

break;

case 'PRODUCT_LIST_BUY_NOW':

$lc_align = 'center';

$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

break;

}

$list_box_contents[$cur_row][] = array('align' => $lc_align,

'params' => 'class="productListing-data"',

'text' => $lc_text);

}

 

With this modification the products whose name is empty do not post any more. but I have a problem with :

Displaying 1 to 3 (of 3 products)

 

I think your way is better.

Posted

Well as i saw you have altered the query in the same way i did,

as far as products_listing is concerned i haven't studied that well

and i don't know if i 'll change that..

Posted

Thank you,

 

How do you change the line 239?

$filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name";

Because if I put and pd.products_name!='' in it, it doesn't work and I have a error message.

Maybe I have to insert this to : TABLE_PRODUCTS_DESCRIPTION . " pd, " But it's strange because in line 237 there is no TABLE_PRODUCTS_DESCRIPTION . " pd, " and when I insert and pd.products_name!='' it's work !!

Posted

Well i have altered the line 239 in catalog/index.php in this way

 

$filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and pd.products_name!='' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p.products_id = pd.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name";

 

Well, in the queries in lines 237,239 in catalog/index.php, TABLE_PRODUCTS_DESCRIPTION is not included in the queries.

So i added that, i don't know if it is correct of course...

Archived

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

×
×
  • Create New...