Weight Decimal Places

  • Posts: 135
  • Thank you received: 5
1 year 10 months ago #342215

-- 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.

  • Posts: 81504
  • Thank you received: 13062
  • MODERATOR
1 year 10 months ago #342221

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.

  • Posts: 135
  • Thank you received: 5
1 year 10 months ago #342233

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.

  • Posts: 135
  • Thank you received: 5
1 year 10 months ago #342234

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

Attachments:

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

  • Posts: 81504
  • Thank you received: 13062
  • MODERATOR
1 year 10 months ago #342236

Hi,

In the view file show_block_dimensions (you can edit it via the menu Display>Views), you have this line:

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.

  • Posts: 135
  • Thank you received: 5
1 year 10 months ago #342270

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.062 seconds
Powered by Kunena Forum