Item custom field validation

  • Posts: 9
  • Thank you received: 0
  • Hikashop Business
9 years 11 months ago #204248

-- HikaShop version -- : 4.2
-- Joomla version -- : 3.4

I have a custom field in the item table (text field) assigned to a product. Customers can enter an existing serial number on the product page. I would like to check that the serial number is valid, via a database query, before the product is added to the cart, or display an error if invalid. Can you advise suitable approach? Thanks

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

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 11 months ago #204257

From what I have seen, the only validation that you can currently do is whether it is required or not. I earlier recommended that they add in the ability to do a Regex validation on a custom filed. To do a database validation would be more involved, but you could request that feature be added.

I have customers that need to supply a serial number in order to purchase a software upgrade. I made a custom field for the applicable products and made it required, but the customer can enter whatever they want. We have to validate that serial number when we get the order. If they do add that feature, I would be interested in it. If they at least added a Regex validation, the customers couldn't just enter any old value.

Last edit: 9 years 11 months ago by gpraceman.

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

  • Posts: 83827
  • Thank you received: 13571
  • MODERATOR
9 years 11 months ago #204280

Hi,

A regex validation for the custom fields has already been added to the latest version of HikaShop.
But if you want to validate against a database of valid values, as gpraceman said, it will require something more involved.
HikaShop has a lot of triggers which are listed on our developer documentation:
www.hikashop.com/support/support/documen...r-documentation.html
There, you'll find the triggers for the custom fields.
They allow you to create new types of custom fields via the development of a HikaShop plugin.
So you could create a new type of custom field, basing it on the standard text field type and overriding the check function to do your own check the way you want.
If you want a complete example, you can look at the advanced date picker plugin which is available in the folder plugins/hikashop/datepickerfield of your website.

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

  • Posts: 106
  • Thank you received: 5
  • Hikaserial Standard Hikashop Business
9 years 11 months ago #204303

nicolas wrote: A regex validation for the custom fields has already been added to the latest version of HikaShop.

Two weeks ago, you indicated that you would look at adding such a feature. If that feature has already been added, where is it available? When I edit a custom field, I don't see any Regex option.

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

  • Posts: 9
  • Thank you received: 0
  • Hikashop Business
9 years 11 months ago #204331

Nicolas thanks, creating a new custom field looks the way forward. I will have a look through the Datepickerfield example. It would be nice if there were some comments in these code suggestions.

gpraceman, it seems we are tying to solve the same requirement.

Last edit: 9 years 11 months ago by designbuilder.

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

  • Posts: 26234
  • Thank you received: 4036
  • MODERATOR
9 years 11 months ago #204404

Hi,

Two weeks ago, you indicated that you would look at adding such a feature. If that feature has already been added, where is it available? When I edit a custom field, I don't see any Regex option.

That's right. Two weeks ago as said that we would look into it, and we did.
We released the latest version yesterday and you can see that new feature mentioned on the change log of that new version:
www.hikashop.com/support/support/documen...ashop-changelog.html

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.073 seconds
Powered by Kunena Forum