Post by ballouta » Thu Jul 15, 2010 4:44 pm

Hello everyone
I am able to view the weight of the product corrrectly without any problems, but i can't view the weight unit.
I read a post about showing weight but it is too long and i got lost. ::)
I thought since i am able to show the weight, it will be more easier to edit the code andd add the unit to it with your help PLZ
Thank You so much

New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by ballouta » Fri Jul 16, 2010 1:27 pm

hello

Kindly anyone can help me with showing the weight unit steps?
Thank You

New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by cevarief » Fri Jul 16, 2010 2:34 pm

Hi, i ever posted how to display weight unit, but in Indonesian language. You could use google translate : http://forum.opencart.com/viewtopic.php ... 716#p82181

Scroll bottom to the post that contain image attachment.

Hope it can help.

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by ballouta » Fri Jul 16, 2010 2:43 pm

Thank You cevarief, i will translate it and get back to you with the result
best,

New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by ballouta » Fri Jul 16, 2010 3:27 pm

hey cevarief
it is working, many thanks, i am very happy.
what If i want to translate Gram to another language. any simple and easy steps like those you advised?
usually when i translate any title I do the following:
1) catalog\language\english\product\product.php

Code: Select all

$_['text_weight']         = 'Weight';
2) catalog\language\arabic\product\product.php i add the translation:

Code: Select all

$_['text_weight']         = ' XXX ';
I did the same thing for the weight unit but still in english.
i added this

Code: Select all

$_['text_weight_title']   = 'Gram';
and this

Code: Select all

$_['text_weight_title']   = 'XXX';
where's teh problem?
appreciate it

New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by cevarief » Sat Jul 17, 2010 9:10 am

Please don't hard code something that's multilanguage. To edit the weight unit text (gram, kg etc) you should edit in the backed. Go to setting->localisation->weight class.

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by ballouta » Sat Jul 17, 2010 11:30 am

i see, but this is the way the Opencart is translated to my language and as i downloaded from this website.
when I go to localisation, i can only add the language code, flag and few options, but this does NOT affect the weight unit translation and other titles like: Model, SKU ...
they are translated as i mentioned above.
So does this mean that this translation for the opencart is not a good way or doesnt have a good performance?
in fact, i am able to change the unit weight (gram) title in my database to the language i want, but i thought it is good to follow the same prodcedure used in the translated cart.
thansk for helping

New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by ballouta » Tue Jul 20, 2010 2:21 pm

hello
it is really bothering me that i am NOT able (dont know) how to translate the weigh unit (gram) in my store
i was able to translate successfuly the titles but this didnt work
thanks in advance

New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by cevarief » Tue Jul 20, 2010 4:51 pm

Hi Ballouta,

You mean you want to show weight unit instead of weight title? if so you could easily follow how the weight title code works.

1. Go to model/catalog/product.php
In public function getProduct, add weight unit field selection in the query.
From "...ss.name AS stock, w.title FROM..."...becomes ss.name AS stock, w.title, w.unit FROM..."
2. Go to controller/product/product.php, you should add this code after weight title code (in line 2 below)

Code: Select all

$this->data['weight_title'] = $product_info['title'];
$this->data['weight_unit'] = $product_info['unit'];
3. In your product.tpl you could just echo $weight_unit to show the weight unit. Combined with height title you can get something like "1.50 Kilogram (kg)" Instead of "1.50 Kilogram".

Cheers!
Cevarief

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by ballouta » Wed Jul 21, 2010 2:38 am

Thanks cevarief, your post is important, yeah i think i need to make this modification! didnt think about it before BUT
what i am asking for is that:
in the fornt page of the products, the weight of product is now showing, the (weight) word is translated successfuly while the weight (title/unit) still in english.
i usually edit the two languages files as i mentioned before but didnt work
attached the word i want to translate
Many thanks

Attachments

Untitled.jpg

Untitled.jpg (19.58 KiB) Viewed 8310 times


New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by cevarief » Wed Jul 21, 2010 6:40 am

I have 2 language here, English and Indonesia. It works normal on my 1.4.8. If you don't mind you can zip and send your arabic language folder and let see if i can help you to check it.

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by ballouta » Wed Jul 21, 2010 8:42 am

yes sure here are the two folders, but dont u think we need smthg else rather than those two language files?
if you edit any of the files kindly write a comment next to the line so i can view it (write ur name)

many thanks

New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by cevarief » Wed Jul 21, 2010 12:08 pm

I want to check the language, if it has no problem with my oc, then the problem might be in your controller or your template :D

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by cevarief » Wed Jul 21, 2010 2:11 pm

Hi Ballouta,

It seems there's a missing code in the product model query, if it has multi language it will display unit from the first record of result. So it will show uncorrect unit weight. To fix it go to /catalog/model/catalog/product.php. In the query of public function getProduct($product_id), add this at the end of the line :

From

Code: Select all

....' AND p.date_available <= NOW() AND p.status = '1'");
Becomes

Code: Select all

' AND p.date_available <= NOW() AND p.status = '1'  AND w.language_id = '" . (int) $this->config->get('config_language_id') . "'");
Note the addition where clause w.language_id, this makes sure the data that will be read only based on active language.

As ilustrasion, if you have 2 languages
record id | language | weight unit
1 | english | kg
2 | arabic | ahlan

Before it will always read first record whatever the language. Now after adding w.language_id clausa, it will choose the matching record based on active language.

Hope this will solve your problem.

Cheers!
Cevarief.

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by ballouta » Wed Jul 21, 2010 2:21 pm

Dear Cevarief
I appreciate your help
I just replaced the selected code but nothing changed.
i am not a PHP Genius but i feel that the arabic version of the open cart looks somehow strange, this is what i noticed after reading many posts here. I might be wrong sorry.
additional note if it helps, i cant find the weight units in the database in two languages, it is only one language. but all units are repeated twice in the table, and i dont know what;s the reason,
what i know is that I add the title in the english language and translate it on the other language.
what you think?
Many Thanks

New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by cevarief » Wed Jul 21, 2010 2:26 pm

yes the record will be repeated as much as the language you install. If the arabic version is strange, then in mybox that would be strange too. The thing is i got the same language file with yours.

Now check in your database. Go to table weight_class_Description. for the same product with repeated record, look at the language_id column. Is that different right? For arabic, the column value should be 2 if you install as second language :D
Next check if unit column filled with right value. This is what will be displayed in your product page.

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by ballouta » Wed Jul 21, 2010 2:45 pm

you are right, attached the description_class table snap shot
AND the products hold number 2 as the weight_class_id
so the database entries look fine, only smthg wrong somewhere! :(

please check those two lines
in catalog/language/english/product/product.php

Code: Select all

$_['text_weight_title']   = 'Gram';
 
and in

in catalog/language/arabic/product/product.php

Code: Select all

$_['text_weight_title']   = 'غرام';
 
is there smthg else should be done when you translate (any title)?

Many thanks, I appreciate your time & efforts

Attachments

class.jpg

class.jpg (50.78 KiB) Viewed 8301 times


New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by cevarief » Wed Jul 21, 2010 2:59 pm

It's oke with your language, it has nothing to do with your problem anyway, it's just text not the unit you want to display. Based on your picture, you can see record 1 (weight class id = 1) is the same as line 5 right? but it has different language id. Now try to change the unit and title of line 5 to your arabic. This should be edited in backend admin tho, but just to find out, change it direclty in your database, from Gram to غرا. Remember only for line 5 (the arabic language id = 2). Based on my revision code above, that should change your display to your arabic.

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by ballouta » Wed Jul 21, 2010 3:08 pm

oh my God!
that is super weired!
I changed teh fifth row to arabic language but did NOT show up in the front page, so i changed the second row too and it worked fine!!
i will leave it as is now, ok?
my store is only arabic anyway
10x

New member

Posts

Joined
Sat Jul 10, 2010 2:36 pm
Location - california

Post by mohit11 » Wed Nov 24, 2010 4:52 pm

Hi could you lease guide as to how to show the weight unit for version 1.4.9.1

can display the weight but not the unit with the above codes

New member

Posts

Joined
Thu Nov 18, 2010 5:01 pm
Who is online

Users browsing this forum: No registered users and 121 guests