Condition issue?

  • Posts: 615
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
2 days 9 hours ago #368907

-- HikaShop version -- : 6.1.0
-- Joomla version -- : 5.3.4
-- PHP version -- : 8.3

Hi HikaShop team,

I’m experiencing an issue with a price calculation condition using decimal values.

Here’s the condition I’m trying to use:

{shape}>0.3 && {afwerking_zelfklevend_alu}>0

When {shape} has a value like 0.4, the condition does not work.
However, when I change the value from the shape into (for example 2), the condition works correctly.

So it looks like decimal numbers (with a dot) are not being parsed or compared properly inside conditions, while integers are.

But also, why will these conditions don't work?
{shape}=0.4 

{shape}="0.4"


Thanks in advance for your help!

Best regards,
Lumiga


Kind regards,
Lumiga
Attachments:
Last edit: 2 days 8 hours ago by Lumiga.

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

  • Posts: 84497
  • Thank you received: 13739
  • MODERATOR
2 days 4 hours ago #368908

Hi,

Ideally, I would recommend avoiding decimals as much as possible with PHP. That will avoid issues.
You could multiply everything by 100 here. That way, you would have the values 3 and 40 and in the condition, you would have {shape}>30 and it would be mathematically the same, but without any decimals. And if you need to use {shape} in the formula, you can always divide it by 100 in the formula.

However, your custom field can have both strings and numbers: 0.4 and 0.03 are numbers but overig is a string.
And then you're using > in the condition. But "overid > 0.3" doesn't make sense since you can't mathematically compare a word and a number.
That might actually be a bigger problem here.

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

Time to create page: 0.058 seconds
Powered by Kunena Forum