Conditional required field at checkout

  • Posts: 2
  • Thank you received: 0
  • Hikashop Business
3 weeks 14 hours 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: 2591
  • Thank you received: 341
  • MODERATOR
3 weeks 1 minute 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: 3 weeks 57 minutes ago by Philip.
The following user(s) said Thank You: ildiwhite

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

  • Posts: 2
  • Thank you received: 0
  • Hikashop Business
2 weeks 5 days 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: 2 weeks 5 days ago by ildiwhite.

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

  • Posts: 70022
  • Thank you received: 10487
  • MODERATOR
2 weeks 4 days 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.050 seconds
Powered by Kunena Forum