Conditional required field at checkout

  • Posts: 10
  • Thank you received: 0
  • Hikashop Business
4 years 5 months ago #321199

-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.19
-- PHP version -- : 7.0

Hi,

I would like to achieve the following at checkout:
If the address_company field (that is not mandatory) has a value, then the address_tax_number field should be mandatory. If the address_company field is empty, the address_tax_number field is not mandatory.
Is it possible?
Thank you,
Ildikó

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

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
4 years 5 months ago #321215

Hello,

Yes, it's possible but with a little difference, follow me step by step to understand my idea :
1. Create a custom field like this screenshot :



The point here, is to know if you have a person OR a company
2. Then if you have a company, the Address field will be displayed AND mandatory (and not displayed if previous custom field value is "No"), and then idea is to have 2 "address_tax_number" custom field, first is mandatory (required) associated with "Cie" value and the second one, not required and associatiated with Ind (individual)


Hope this will fit your needs.
Regards

Last edit: 4 years 5 months ago by Philip.
The following user(s) said Thank You: ildiwhite

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

  • Posts: 10
  • Thank you received: 0
  • Hikashop Business
4 years 4 months ago #321323

Hi Philip,
Many thanks for the quick solution, it works. I haven't notice this feature yet.
So does it mean that we have two columns in a table with the same name?
I still have a minor question:
What should I override to get rid of the word "error" in the custom error message (see attachement)?

Attachments:
Last edit: 4 years 4 months ago by ildiwhite.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 4 months ago #321337

Hi,

I'm not sure what you mean by "we have two columns in a table with the same name". Why do you think you have two columns with the same name in the same table (which is impossible in MySQL) ?

Regarding the "error" word, it's a bug. Change the line:

$this->parent->messages[$this->prefix.$field->field_namekey] = array($message, 'error');
to:
$this->parent->messages[$this->prefix.$field->field_namekey] = array($message);
in the file administrator/components/com_hikashop/classes/field.php and that will fix the problem. We'll add the patch on our end too.

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

Time to create page: 0.061 seconds
Powered by Kunena Forum