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

#   Disable underage to place any orders

##

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

Less More

- Posts: 23
- Thank you received: 1
-
-

12 years 6 months ago [\#156842](#156842) by [Genusskanzlei](/forum/user/30057-genusskanzlei "View Genusskanzlei's Profile")  *[Disable underage to place any orders](/forum/33-customers/868392-disable-underage-to-place-any-orders#156842 "-- url of the page with the problem -- :   www.genusskanzlei.at/shop  -- HikaShop version -- : 2.3.0 -- Joomla version -- : 3.2.3 -- PHP version -- : 5.4.24 -- Browser(s) name and version -- : XXXXX x.x.x -- Error-message(debug-mod must be tuned on) -- : none  For the table &quot;address&quot; I have added a &quot;Custom Field&quot; named: &quot;Birth date&quot;, which is a requirement. The reason is that we need to unable person under 18 years to place any order on the shop, since we also offer alcoholic beverage.  How could achieved this?  Or should we just not allow anybody under 18 year to register at all? How?  I think this should help me get the age:  I will appreciate all the help!  Thanks in advance for the help!")* was created by *[Genusskanzlei](/forum/user/30057-genusskanzlei "View Genusskanzlei's Profile")*

-- url of the page with the problem -- : [ www.genusskanzlei.at/shop](http://www.genusskanzlei.at/shop)
-- HikaShop version -- : 2.3.0
-- Joomla version -- : 3.2.3
-- PHP version -- : 5.4.24
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- : none

For the table "address" I have added a "Custom Field" named: "Birth date", which is a requirement. The reason is that we need to unable person under 18 years to place any order on the shop, since we also offer alcoholic beverage.

How could achieved this?

Or should we just not allow anybody under 18 year to register at all? How?

I think this should help me get the age:
Code:

function birthday($birthday) { $age = date_create($birthday)-&gt;diff(date_create('today'))-&gt;y; return $age; } If $age &lt; 18 { echo JText::_('You_must_be_18_to_order'); return „home“?? }

I will appreciate all the help!

Thanks in advance for the help!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMzLWN1c3RvbWVycy84NjgzOTItZGlzYWJsZS11bmRlcmFnZS10by1wbGFjZS1hbnktb3JkZXJzP3RtcGw9bWFya2Rvd24=) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86586
- Thank you received: 14325
-
-

12 years 6 months ago [\#156865](#156865) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Disable underage to place any orders](/forum/33-customers/868392-disable-underage-to-place-any-orders#156865 "-- url of the page with the problem -- :   www.genusskanzlei.at/shop  -- HikaShop version -- : 2.3.0 -- Joomla version -- : 3.2.3 -- PHP version -- : 5.4.24 -- Browser(s) name and version -- : XXXXX x.x.x -- Error-message(debug-mod must be tuned on) -- : none  For the table &quot;address&quot; I have added a &quot;Custom Field&quot; named: &quot;Birth date&quot;, which is a requirement. The reason is that we need to unable person under 18 years to place any order on the shop, since we also offer alcoholic beverage.  How could achieved this?  Or should we just not allow anybody under 18 year to register at all? How?  I think this should help me get the age:  I will appreciate all the help!  Thanks in advance for the help!")*

Hi,

A simple solution would be to use a custom field of the type datepicker (available since the 2.3.1 version of HikaShop). It has advanced restriction settings which will allow you to restrict the selectable dates to only the days before the last 18 years and thus preventing underage users to register (unless the enter a fake birthday of course...)

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

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

Less More

- Posts: 23
- Thank you received: 1
-
-

12 years 6 months ago [\#157087](#157087) by [Genusskanzlei](/forum/user/30057-genusskanzlei "View Genusskanzlei's Profile")  Replied by *[Genusskanzlei](/forum/user/30057-genusskanzlei "View Genusskanzlei's Profile")* on topic *[Disable underage to place any orders](/forum/33-customers/868392-disable-underage-to-place-any-orders#157087 "-- url of the page with the problem -- :   www.genusskanzlei.at/shop  -- HikaShop version -- : 2.3.0 -- Joomla version -- : 3.2.3 -- PHP version -- : 5.4.24 -- Browser(s) name and version -- : XXXXX x.x.x -- Error-message(debug-mod must be tuned on) -- : none  For the table &quot;address&quot; I have added a &quot;Custom Field&quot; named: &quot;Birth date&quot;, which is a requirement. The reason is that we need to unable person under 18 years to place any order on the shop, since we also offer alcoholic beverage.  How could achieved this?  Or should we just not allow anybody under 18 year to register at all? How?  I think this should help me get the age:  I will appreciate all the help!  Thanks in advance for the help!")*

Hi!

I actually have the custom field of type datepicker. I don't see which is the "advanced restriction settings", but I gave unto "Default Value" a date and then set "Allow" to "Only past dates", as you can see in the picture. Then I've got next to date entry for "Default Value" Code:

disableFunc: function(date) { var today=new Date(); today.setHours(23);today.setMinutes(59);today.setSeconds(59);today.setMilliseconds(99); if(date &gt; today) { return true; } return false; }, // :

After that, I tried to save it and close and I've got the following error and everything was gone ![:-(](/media/kunena/emoticons/22.png ":-(")
Code:

0 DateTime::__construct(): Failed to parse time string (23.05.1996&amp;quot;,disableFunc: function(date) { var today=new Date(); today.setHours(23);today.setMinutes(59);today.setSeconds(59);today.setMilliseconds(99); if(date &amp;gt; today) { return true; } return false; }, //) at position 10 (&amp;): Unexpected character

I have to remove the Custom fields and create a new one. However, every time I save the new one I get an error saying
Error
Please complete the Birthday field

I think this is not working right ![:-(](/media/kunena/emoticons/22.png ":-(")

Any suggestions?

- [ ![hd8b2b8d.jpg](/forum/attachment/17432) ](/forum/attachment/17432 "hd8b2b8d.jpg") [ ](/forum/attachment/17432?download=1 "hd8b2b8d.jpg")
- [ ![h1f5d7b8.jpg](/forum/attachment/17433) ](/forum/attachment/17433 "h1f5d7b8.jpg") [ ](/forum/attachment/17433?download=1 "h1f5d7b8.jpg")

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

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

12 years 6 months ago [\#157101](#157101) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Disable underage to place any orders](/forum/33-customers/868392-disable-underage-to-place-any-orders#157101 "-- url of the page with the problem -- :   www.genusskanzlei.at/shop  -- HikaShop version -- : 2.3.0 -- Joomla version -- : 3.2.3 -- PHP version -- : 5.4.24 -- Browser(s) name and version -- : XXXXX x.x.x -- Error-message(debug-mod must be tuned on) -- : none  For the table &quot;address&quot; I have added a &quot;Custom Field&quot; named: &quot;Birth date&quot;, which is a requirement. The reason is that we need to unable person under 18 years to place any order on the shop, since we also offer alcoholic beverage.  How could achieved this?  Or should we just not allow anybody under 18 year to register at all? How?  I think this should help me get the age:  I will appreciate all the help!  Thanks in advance for the help!")*

Hi,

In all cases, you can't add javascript directly in the input field.
I'm not sure that this custom field handle the check for a minimum age. You will potentially have to create a plugin based on the function "onBeforeAddressCreate()", or "onBeforeAddressUpdate()" and make a check on the current date, the date set in the custom field to allow the registration or not.

So PHP knowledge are required.

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

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

Less More

- Posts: 23
- Thank you received: 1
-
-

12 years 6 months ago [\#157153](#157153) by [Genusskanzlei](/forum/user/30057-genusskanzlei "View Genusskanzlei's Profile")  Replied by *[Genusskanzlei](/forum/user/30057-genusskanzlei "View Genusskanzlei's Profile")* on topic *[Disable underage to place any orders](/forum/33-customers/868392-disable-underage-to-place-any-orders#157153 "-- url of the page with the problem -- :   www.genusskanzlei.at/shop  -- HikaShop version -- : 2.3.0 -- Joomla version -- : 3.2.3 -- PHP version -- : 5.4.24 -- Browser(s) name and version -- : XXXXX x.x.x -- Error-message(debug-mod must be tuned on) -- : none  For the table &quot;address&quot; I have added a &quot;Custom Field&quot; named: &quot;Birth date&quot;, which is a requirement. The reason is that we need to unable person under 18 years to place any order on the shop, since we also offer alcoholic beverage.  How could achieved this?  Or should we just not allow anybody under 18 year to register at all? How?  I think this should help me get the age:  I will appreciate all the help!  Thanks in advance for the help!")*

I didn't add the javascript.
After I input the date In the field and clicked save, this script showed up and there was no way to remove it. You can try recreate what I explain and see for yourself.

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26402
- Thank you received: 4081
-
- [](http://obsi.dev)
-

12 years 6 months ago [\#157389](#157389) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Disable underage to place any orders](/forum/33-customers/868392-disable-underage-to-place-any-orders#157389 "-- url of the page with the problem -- :   www.genusskanzlei.at/shop  -- HikaShop version -- : 2.3.0 -- Joomla version -- : 3.2.3 -- PHP version -- : 5.4.24 -- Browser(s) name and version -- : XXXXX x.x.x -- Error-message(debug-mod must be tuned on) -- : none  For the table &quot;address&quot; I have added a &quot;Custom Field&quot; named: &quot;Birth date&quot;, which is a requirement. The reason is that we need to unable person under 18 years to place any order on the shop, since we also offer alcoholic beverage.  How could achieved this?  Or should we just not allow anybody under 18 year to register at all? How?  I think this should help me get the age:  I will appreciate all the help!  Thanks in advance for the help!")*

Hi,

With latest versions of Joomla 3.2 and Joomla 3.3, the date system of Joomla has changed and it breaks the compatibility (without any warning to the community)
So it is no longer possible to use date restriction with the simple date picker.
You have to use the dynamic date picker with HikaShop 2.3.1 or do not put the date restrictions.
The feature still work with Joomla 1.5, 2.5, 3.0 and 3.1 ; that's why we can't remove the option for the simple date picker.

Regards,

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMzLWN1c3RvbWVycy84NjgzOTItZGlzYWJsZS11bmRlcmFnZS10by1wbGFjZS1hbnktb3JkZXJzP3RtcGw9bWFya2Rvd24=) 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.088 seconds

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