[Skip to main content](#vessel-content)

#   Conditional required field at checkout

##

- **[ildiwhite](/forum/user/40526-ildiwhite "View ildiwhite's Profile")**
- [![ildiwhite's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/40526-ildiwhite "View ildiwhite's Profile") Topic Author
- [ Offline](/forum/user/40526-ildiwhite)

Less More

- Posts: 16
- Thank you received: 0
-
-

6 years 5 months ago [\#321199](#321199) by [ildiwhite](/forum/user/40526-ildiwhite "View ildiwhite's Profile")  *[Conditional required field at checkout](/forum/27-checkout/900258-conditional-required-field-at-checkout#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&#95;company field (that is not mandatory) has a value, then the address&#95;tax&#95;number field should be mandatory. If the address&#95;company field is empty, the address&#95;tax&#95;number field is not mandatory. Is it possible? Thank you, Ildikó")* was created by *[ildiwhite](/forum/user/40526-ildiwhite "View ildiwhite's Profile")*

-- 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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwMDI1OC1jb25kaXRpb25hbC1yZXF1aXJlZC1maWVsZC1hdC1jaGVja291dD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Philip](/forum/user/34318-philip "View Philip's Profile")**
- [![Philip's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34318-philip "View Philip's Profile")
- [ Offline](/forum/user/34318-philip)

Less More

- Posts: 4820
- Thank you received: 652
-
-

6 years 5 months ago -  6 years 5 months ago [\#321215](#321215) by [Philip](/forum/user/34318-philip "View Philip's Profile")  Replied by *[Philip](/forum/user/34318-philip "View Philip's Profile")* on topic *[Conditional required field at checkout](/forum/27-checkout/900258-conditional-required-field-at-checkout#321215 "-- 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&#95;company field (that is not mandatory) has a value, then the address&#95;tax&#95;number field should be mandatory. If the address&#95;company field is empty, the address&#95;tax&#95;number field is not mandatory. Is it possible? Thank you, Ildikó")*

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 :
[ ![alt](https://i.imgur.com/do2Gil2.png) ](https://i.imgur.com/do2Gil2.png "alt")

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)
[ ![alt](https://i.imgur.com/IVHexNN.png) ](https://i.imgur.com/IVHexNN.png "alt")

Hope this will fit your needs.
Regards

Last edit: 6 years 5 months ago by [Philip](/forum/user/34318-philip "View Philip's Profile").

The following user(s) said Thank You: [ildiwhite](/forum/user/40526-ildiwhite "View ildiwhite's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwMDI1OC1jb25kaXRpb25hbC1yZXF1aXJlZC1maWVsZC1hdC1jaGVja291dD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ildiwhite](/forum/user/40526-ildiwhite "View ildiwhite's Profile")**
- [![ildiwhite's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/40526-ildiwhite "View ildiwhite's Profile") Topic Author
- [ Offline](/forum/user/40526-ildiwhite)

Less More

- Posts: 16
- Thank you received: 0
-
-

6 years 5 months ago -  6 years 5 months ago [\#321323](#321323) by [ildiwhite](/forum/user/40526-ildiwhite "View ildiwhite's Profile")  Replied by *[ildiwhite](/forum/user/40526-ildiwhite "View ildiwhite's Profile")* on topic *[Conditional required field at checkout](/forum/27-checkout/900258-conditional-required-field-at-checkout#321323 "-- 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&#95;company field (that is not mandatory) has a value, then the address&#95;tax&#95;number field should be mandatory. If the address&#95;company field is empty, the address&#95;tax&#95;number field is not mandatory. Is it possible? Thank you, Ildikó")*

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)?

- [ ![hikashop.png](/forum/attachment/49889) ](/forum/attachment/49889 "hikashop.png") [ ](/forum/attachment/49889?download=1 "hikashop.png")

Last edit: 6 years 5 months ago by [ildiwhite](/forum/user/40526-ildiwhite "View ildiwhite's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwMDI1OC1jb25kaXRpb25hbC1yZXF1aXJlZC1maWVsZC1hdC1jaGVja291dD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

6 years 5 months ago [\#321337](#321337) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Conditional required field at checkout](/forum/27-checkout/900258-conditional-required-field-at-checkout#321337 "-- 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&#95;company field (that is not mandatory) has a value, then the address&#95;tax&#95;number field should be mandatory. If the address&#95;company field is empty, the address&#95;tax&#95;number field is not mandatory. Is it possible? Thank you, Ildikó")*

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: Code:

$this-&gt;parent-&gt;messages[$this-&gt;prefix.$field-&gt;field_namekey] = array($message, 'error');

to:
Code:

$this-&gt;parent-&gt;messages[$this-&gt;prefix.$field-&gt;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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwMDI1OC1jb25kaXRpb25hbC1yZXF1aXJlZC1maWVsZC1hdC1jaGVja291dD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.066 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
