Conditional fields

  • Posts: 268
  • Thank you received: 7
  • Hikamarket Frontedition Hikamarket Multivendor Hikaserial Standard Hikashop Business
1 year 1 month ago #356623

-- url of the page with the problem -- : eop-inc.com
-- HikaShop version -- : 5.0.0
-- Joomla version -- : 3.10.12
-- PHP version -- : 7.4.33

I've got an optional product setup for personalization of various articles of clothing which adds a drop down to the item when ordering. This is working fine. But how can I get custom fields to display based whether or not that optional item has been chosen to display?

For example. We offer a sweatshirt that can be customized with someone's name. We want the field where someone can enter their name in to display only if that option is available. Is this possible? Without having to enter every product individually in the parameters for the custom field?

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

  • Posts: 83007
  • Thank you received: 13399
  • MODERATOR
1 year 1 month ago #356624

Hi,

You have 2 options:

- There is no setting to restrict a custom field being displayed or not based on an option. However, it's possible to hide/display the custom field when the option is changed by adding some custom javascript to the product page.
In your javascript ( which you can add via a view override), you can implement the hkContentChanged event: www.hikashop.com/support/documentation/6...tml#hkContentChanged
And in it, a bit of javascript : www.tutorialspoint.com/How-to-hide-HTML-element-with-JavaScript
So if you're a developer, this is possible. However, you can't turn on the "required" setting of the field. Otherwise, it will forbid the add to cart when the custom field is not displayed by the javascript and thus empty. So if you need the field to be filled, you would need to add a check in your javascript too.

- A cleaner solution would be to not use an option and a custom field, but two custom fields. That way, you can rely on the "display limited to" setting of the second custom field to display it only when the first one is in a specific value. That way, no custom code to do.
The limitation here is that you can't add extra fees to the product based on what is selected in a custom field. I suppose that's what you want to use the option for. However, you can use this plugin ( www.hikashop.com/marketplace/product/148...ce-calculations.html ) to do it.

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

Time to create page: 0.060 seconds
Powered by Kunena Forum