Page 1 of 2

Products Measures/Dimensions

Posted: Tue Feb 22, 2022 4:05 pm
by Kofod95
With the help of @Omar_one, I've made an add-on to allow adding the measures of products. With it comes a pi-module that will show that data (if any) along with the weight (if one is added).
It supports Imperial and Metric scale (you can choose which scale you use for entering in the module) and you have the option to select which unit you use for weight (kg / g or pounds / ounces). If you visit the site in English, it will show the Imperial scale (recalculated if you have inserted as metric) and vice versa if you visit the site in any other language.
I'm not too familiar with Imperial-scale, so please let me know if I've made errors or illogical choices regarding that! I would love to add a button for the customer to change which scale to show and I've made some preparations for it, but I've not been able to get it fully right yet.
So please, let me know how this could be improved, if it is of any use for any of you!
For <=1.0.8..4
productMeassures_V1.zip
For >=1.0.8.5
productMeassures_V1.1.zip
//Daniel

Re: Products Meassures/Dimmensions

Posted: Tue Feb 22, 2022 5:23 pm
by 14Steve14
I would forget the imperial scale. Most couriers I have used in the UK use metric. I dont think anyone in the UK now understands imperial measurements.

I will have to download this and give it a try.

Re: Products Measures/Dimensions

Posted: Tue Feb 22, 2022 6:46 pm
by ecartz
The US still uses Imperial unfortunately.

Re: Products Measures/Dimensions

Posted: Tue Feb 22, 2022 7:57 pm
by Kofod95
International shops in Denmark tend to offer both scales, but it could make sense to make it optional whether to convert or not. Let me know if you would want me to!
To disable switching and only show in the scale used to insert, delete line 40 in the module-file or remove

Code: Select all

$meassure_inputs ??
from line 41

//Daniel

Re: Products Measures/Dimensions

Posted: Tue Feb 22, 2022 11:05 pm
by burt
Never link things to language if you can avoid it.

UK uses metric (and some imperial) - speaks english
US uses imperial - speaks english
Australia uses metric (and some imperial) - speaks english
etc

You will alienate a subsection of english speakers whatever you do...

It's a similar problem to flags. Jukka wrote this getting on for 25 years ago; https://www.irt.org/articles/js173/

Re: Products Measures/Dimensions

Posted: Wed Feb 23, 2022 10:01 am
by Kofod95
I did have a read about where imperial where used and saw that it, beside the US, mostly was split between imperial and metric.
Thank you for the article - still very relevant and makes me consider whether we should change the core handling of language-switching to avoid using flags there.
I will do my best to come up with a better solution. I guess I could echo both metric and imperial with php and let javascript hide/show. I'll see what I can do!

//Daniel

Re: Products Measures/Dimensions

Posted: Wed Feb 23, 2022 12:56 pm
by ecartz
Overall, I think that most have moved the other direction. Instead of removing flags, they've changed to make the flags determine the locale. Then the locale determines the language. Or the flag determines the country and the country determines the locale choices that are available.

I would also point out that while the UK and US nominally speak the same language, in practice, there are a number of differences. For example, a number of words are spelled differently.

Basing on locale rather than language also helps with things like currency. Because the US, UK, Canada, and Australia use four different currencies. Or (for example) a Dane might browse a website in English but expect prices to be in Euros, not pounds or dollars. Same thing for residents of other EU countries. And Indians or Swiss might prefer rupees or francs. And of course beyond that, the underlying laws may differ between the US, EU, and other countries. So even if all English speaking, they may expect different statements in different countries.

To get back to the subject of this thread, I think that in the US, people will expect to have measurements in Imperial. To a lesser extent, also true of Canada (because many Canadians buy goods manufactured for the US market). So in an en_US locale (or es_US or rarer locales like zh_US, fr_US, etc.), Imperial should be at least supported.

I'm not entirely averse to switching Phoenix to use locales rather than languages. I would eventually like to do it. I would somewhat prefer to see it start somewhere else than in core.

Re: Products Measures/Dimensions

Posted: Wed Feb 23, 2022 3:06 pm
by Kofod95
Thank you for the inputs! If noone is opposed it, I will try to play with the locale on this add-on and use that to set a default which would then be switchable by the customer

//Daniel

Re: Products Measures/Dimensions

Posted: Tue Jun 14, 2022 12:16 pm
by Kofod95
Studies happened so it took some time to do as I said I would..

However, here is an updated package that bases the default scale to show on the visitors browser locale (if I understood that part correctly...)
Besides that, it has a button that allows the visitor to switch the scale to the other of the two.

The zip is a "Zipur bundler" package, so you can install via that. Otherwise just ignore the file "update.php" and run this sql:

Code: Select all

ALTER TABLE `products` ADD `products_meassures` VARCHAR(255) NULL DEFAULT NULL;
If anyone wants to test the switching between imperial and metric as default scale, you can open includes/modules/pi/product_info/pi_meassures.php and find the variable $imperial_march on line 40. Add or delete your locale in the array (I have commented out 'da-DK', which is my locale). Alternatively, change your browsers locale.

//Daniel

Re: Products Measures/Dimensions

Posted: Sun Jun 26, 2022 11:44 am
by Omar_one
Kofod95 wrote: Tue Jun 14, 2022 12:16 pm Studies happened so it took some time to do as I said I would..

However, here is an updated package that bases the default scale to show on the visitors browser locale (if I understood that part correctly...)
Besides that, it has a button that allows the visitor to switch the scale to the other of the two.

The zip is a "Zipur bundler" package, so you can install via that. Otherwise just ignore the file "update.php" and run this sql:

Code: Select all

ALTER TABLE `products` ADD `products_meassures` VARCHAR(255) NULL DEFAULT NULL;
If anyone wants to test the switching between imperial and metric as default scale, you can open includes/modules/pi/product_info/pi_meassures.php and find the variable $imperial_march on line 40. Add or delete your locale in the array (I have commented out 'da-DK', which is my locale). Alternatively, change your browsers locale.

//Daniel
the zip file missing the hook (includes\hooks\admin\catalog\productMeassures) and the hook language file

Br
Omar