Products Measures / Dimensions

Extension to the addon - Products Measures / Dimensions

Extension to the addon

by PandV » Thu Dec 29, 2022 4:25 am

I've attached modified files (only the files that are moded - rest of the files for the addon unchanged). I needed more field flexibility so I can use this for more aspects of the product - more like a very flexible product specification.

1. Adds admin control of the usage of the "weight" field - allows it to be turned off as historically the product weight field could be used in different ways and did not necessarily represent the actual weight. e.g. was sometimes used as the total shipping weight for input to shipping modules.

2. Because of above can now add Weight as a field and kg and lbs are available as units.

3. Can now have a "Text" type field which allows a lot of flexibility in adding item-specific fields.This necessitates changing the dimensions_value field type in the database from FLOAT to TEXT. - everything keeps working as it should with the change.

4. Now have admin control of whether to use "Euro" style decimal separator (comma) or decimal point (dot). Current version has it linked to metric values but this is not a metric feature - it is a country/language feature and metric values outside of most EU countries use the dot for the decimal separator. Should be straight forward now to link to language in the future if anyone wants to take it that far.

5. I found that the Button to toggle metric/imperial was appearing on products that had no dimensions set - (may be a side affect of the change at 4?). Fixed by changing "if (!empty($dimensions_query))" to "if (mysqli_num_rows($dimensions_query))" in pi_dimensions.php.

6. Changed the button text to be "Toggle imperial/metric" which I believe is more easily recognized in my market.
Attachments
Product Measures Revisions.zip
(30.66 KiB) Downloaded 39 times
PandV
VIP Member
VIP Member
Posts: 13
Joined: Sat Sep 04, 2021 5:32 am
Contact:

Re: Extension to the addon

by Kofod95 » Thu Dec 29, 2022 6:36 am

Thank you very much for the work you are sharing as well as the comments! If you want, I can add you as co-author to the add-ons, which would allow you to upload your improvements as a revision, and allow both of us to offer our support/updates?
PandV wrote: from FLOAT to TEXT[/b].
Is TEXT necessary for what you need, or could it be VARCHAR(255)? I think that would be preferable, if possible.
PandV wrote: 4. Now have admin control of whether to use "Euro" style decimal separator (comma) or decimal point (dot). Current version has it linked to metric values but this is not a metric feature - it is a country/language feature and metric values outside of most EU countries use the dot for the decimal separator. Should be straight forward now to link to language in the future if anyone wants to take it that far.
I did consider doing something more flexible with the separators, so thank you for doing it! At some point, it probably should read the value from the main language-file and just use that, so that would be the next thing I pursue.
Regarding metrics/imperial I'm very happy that someone who knows something corrects my mistakes!

//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
VIP Member
VIP Member
Posts: 613
Joined: Sat Feb 06, 2021 7:38 pm
Contact:

Re: Extension to the addon

by PandV » Thu Dec 29, 2022 9:26 am

Kofod95 wrote:If you want, I can add you as co-author to the add-ons, which would allow you to upload your improvements as a revision, and allow both of us to offer our support/updates?
Yes, that would be fine - would put the pressure on me to clean it all up!
Kofod95 wrote:Is TEXT necessary for what you need, or could it be VARCHAR(255)? I think that would be preferable, if possible.
Yes I agree, VARCHAR is a better option than TEXT.
PandV
VIP Member
VIP Member
Posts: 13
Joined: Sat Sep 04, 2021 5:32 am
Contact:

Re: Extension to the addon

by Kofod95 » Mon Jan 02, 2023 8:19 am

I've have added you as co-author, so you should be able to upload a revision now - thank you again for your contribution!

I noticed also that I made a mistake in the "convert to" field, so if you want, it would be a great help if you added a null-value to the beginning of that array (something like ['id' => '', 'text' => TEXT_NONE]] (and then a constant in the language-files defining TEXT_NONE) :)

//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
VIP Member
VIP Member
Posts: 613
Joined: Sat Feb 06, 2021 7:38 pm
Contact: