Products Measures/Dimensions

Open to all! Ask other shopowners for help.
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Products Measures/Dimensions

Post 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
You do not have the required permissions to view the files attached to this post.
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide


Join The Code Co-op to get access to your library in the Code Co-op Forum
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Products Meassures/Dimmensions

Post 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.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Products Measures/Dimensions

Post by ecartz »

The US still uses Imperial unfortunately.
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Products Measures/Dimensions

Post 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
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Products Measures/Dimensions

Post 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/
I am not here to build for you.
I am here to build with you. Let's help each other.
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Products Measures/Dimensions

Post 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
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Products Measures/Dimensions

Post 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.
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Products Measures/Dimensions

Post 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
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Products Measures/Dimensions

Post 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
You do not have the required permissions to view the files attached to this post.
Last edited by Kofod95 on Thu Jul 07, 2022 6:20 pm, edited 2 times in total.
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
Omar_one
Senior Contributor
Posts: 679
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: Products Measures/Dimensions

Post 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


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply