VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: d0ublezer0 on May 28, 2019, 12:45:35 PM

Title: Custom field with "0" value impossible?
Post by: d0ublezer0 on May 28, 2019, 12:45:35 PM
I need to store zero integer value (0) in custom field, but i see empty field after saving it.
Any ideas, how to avoid this?
vm3.2.14

String value 0 - it's not empty, it zero value
Title: Re: Custom field with "0" value impossible?
Post by: d0ublezer0 on June 04, 2019, 14:27:01 PM
Anybody?
Title: Re: Custom field with "0" value impossible?
Post by: d0ublezer0 on June 04, 2019, 14:39:05 PM
Try to pass this algorithm:

Create custom field of type string.
Add it to some product.

Enter the "0" digit in custom field:
(https://image.prntscr.com/image/DVckRGoSQeCdopjN262cCg.png)

Click save (don't close product page).

You'll see an empty field:
(https://image.prntscr.com/image/QGugKll6TYm51xzoyYbQGQ.png)


If we take a look (at this time) into the site database, we will see zero value in database field:
(https://image.prntscr.com/image/vNXuocMwRNqOJgDTvPPIWQ.png)

Click Save product, again.
Empty field stays on its place, like before.

But, if we look at the database now:
(https://image.prntscr.com/image/lsAJro5aSH22lIV2rAjs1w.png)
Zero value is gone.

Hungry Virtuemart eats my zero values )
And yours too, of course.

But unfortunately, this is not funny. Definitely not.
Title: Re: Custom field with "0" value impossible?
Post by: d0ublezer0 on June 04, 2019, 15:08:26 PM
Oops,
http://forum.virtuemart.net/index.php?topic=142152.0
Title: Re: Custom field with "0" value impossible?
Post by: d0ublezer0 on July 03, 2019, 09:51:04 AM
Request for VM developers: please, fix this issue. This is great problem in my case. We actively use zero-values in custom fields, but cannot work correctly with them.
Title: Re: Custom field with "0" value impossible?
Post by: jjk on July 03, 2019, 12:11:01 PM
Does it work if you enter a 0 plus a space character or a space character plus 0? (Adds two characters into the database)
Title: Re: Custom field with "0" value impossible?
Post by: d0ublezer0 on July 17, 2019, 07:59:51 AM
Quote from: jjk on July 03, 2019, 12:11:01 PM
Does it work if you enter a 0 plus a space character or a space character plus 0? (Adds two characters into the database)
yes, "0 " was saved normally.
but this value not equals "0"
Title: Re: Custom field with "0" value impossible?
Post by: Studio 42 on July 17, 2019, 11:08:30 AM
Why you need "0" ?
I know this should work, but a day to simplify the code, the devs decided to check for all empty values and 0 is an empty value in PHP
Title: Re: Custom field with "0" value impossible?
Post by: d0ublezer0 on July 17, 2019, 13:17:35 PM
Quote from: Studio 42 on July 17, 2019, 11:08:30 AM
Why you need "0" ?
I know this should work, but a day to simplify the code, the devs decided to check for all empty values and 0 is an empty value in PHP
Because we selling off-road wheel disks.

https://en.m.wikipedia.org/wiki/Wheel_sizing
QuoteThe offset is the distance from the hub-mounting surface to the wheel's true centerline. It is measured in mm and can be either positive or negative. A positive offset means the hub-mounting surface is closer to the outside edge of the wheel, while a negative offset means the hub-mounting surface is closer to the inside edge of the wheel.

Our disks has offset from -73 to +35, through the zero ("0") value.
So, we cannot save this value.
Title: Re: Custom field with "0" value impossible?
Post by: balai on July 17, 2019, 13:46:59 PM
It's a bug.
VM custom field value cannot store "0" as it regards it empty
Title: Re: Custom field with "0" value impossible?
Post by: Studio 42 on July 17, 2019, 14:09:57 PM
You can create a customfield plugin to use "0", you can check the core "text input" customfield plugin and modify it for your need.
Because all is saved as parameters, it's not a problem.
The only problem is if you need to use it as a search field.
Title: Re: Custom field with "0" value impossible?
Post by: d0ublezer0 on July 17, 2019, 15:30:22 PM
Quote from: Studio 42 on July 17, 2019, 14:09:57 PM
You can create a customfield plugin to use "0", you can check the core "text input" customfield plugin and modify it for your need.
Because all is saved as parameters, it's not a problem.
The only problem is if you need to use it as a search field.
We use custom fields filter by Breakdesigns.
I do not think it will work with a new type of fields.
Title: Re: Custom field with "0" value impossible?
Post by: Studio 42 on July 17, 2019, 22:59:55 PM
Can you not use a joomla Key ?
Eg. ZERO
And you declare as key
KEY : ZERO
value : 0
this display then in front end : 0