Skip to main content

Weight Decimal Places

More
4 years 4 months ago #342215 by markfell
-- HikaShop version -- : 4.5.1
-- Joomla version -- : 4.1.4
-- PHP version -- : 7.4.28
-- Browser(s) name and version -- : Brave Version 1.35.103 Chromium: 98.0.4758.102 (Official Build) (64-bit)

Hi,

Can I change the decimal place in weights input display in the product restrictions and dimensions.
I products weight very little, but need to be displayed at 0.0018Kgs as per the actual product description from the manufacturers.

If I enter that value 0.0018kgs the system rounds it to 0.002kg

Regards,
MSG

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago #342221 by nicolas
Replied by nicolas on topic Weight Decimal Places
Hi,

In your PHPMyAdmin, you need to open the table hikashop_product's structure and edit the product_weight column.
There, you need to change the type which is decimal(12,3) to for example decimal(14,5)
And that will allow you two more decimals in weights.
Another solution would be to use grams instead of Kgs. That way you could just enter 1.8 grams as the weight and it would work fine.
The following user(s) said Thank You: markfell

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago #342233 by markfell
Replied by markfell on topic Weight Decimal Places
Hi Nicolas,

In the perfect world, grams would be great, but all the supply is in KGS.
So I am snookered on that front.

But I will do the fix, thank you so much.

Regards,
MSF

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago #342234 by markfell
Replied by markfell on topic Weight Decimal Places
Hi Nicolas,

Have changed the database structure and now stores perfectly.
Only issue on the product page it only display weights that are <=3 decimals.
Anything that has a >=4 decimal place eg. 0.0002 doesnt get shown.

Is there something I need to do in a display setting somewhere?

First product weight is 0.00025, second product is 0.009


Regards,
MSF

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago #342236 by nicolas
Replied by nicolas on topic Weight Decimal Places
Hi,

In the view file show_block_dimensions (you can edit it via the menu Display>Views), you have this line:
Code:
if(isset($this->element->product_weight) && bccomp($this->element->product_weight,0,3)){ ?>
it checks that the weight is greater than 0 to display it on the product page. The "3" in there tells the system to check up to three decimals. So you want to change that to 5.
The following user(s) said Thank You: markfell

Please Log in or Create an account to join the conversation.

More
4 years 4 months ago #342270 by markfell
Replied by markfell on topic Weight Decimal Places
Thank Nicolas,

Your coding knowledge of this system is second to none.
We would be lost without you :)

Regards,
MSF
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.194 seconds
Powered by Kunena Forum