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

#   Add conditions to custom fields

##

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

Less More

- Posts: 85
- Thank you received: 9
-
-

6 years 4 months ago -  6 years 2 hours ago [\#320494](#320494) by [pagemaster](/forum/user/50033-pagemaster "View pagemaster's Profile")  *[Add conditions to custom fields](/forum/4-how-to/900117-add-conditions-to-custom-fields#320494 "-- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.2.26  Hello,  I created a custom field where there is a Dropdown menu (see in attach) where it&#96;s possible to select the delivery hours, but I want to display only the hours from now to the end of the day. Is it possible to manage this directly to the back end component or I have to modify the code?  Thank you for your support  Best regards")* was created by *[pagemaster](/forum/user/50033-pagemaster "View pagemaster's Profile")*

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

Hello,

I created a custom field where there is a Dropdown menu (see in attach) where it&#96;s possible to select the delivery hours, but I want to display only the hours from now to the end of the day. Is it possible to manage this directly to the back end component or I have to modify the code?

Thank you for your support

Best regards

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

Last edit: 6 years 2 hours ago by [pagemaster](/forum/user/50033-pagemaster "View pagemaster's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMDExNy1hZGQtY29uZGl0aW9ucy10by1jdXN0b20tZmllbGRzP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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: 86324
- Thank you received: 14286
-
-

6 years 4 months ago [\#320497](#320497) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Add conditions to custom fields](/forum/4-how-to/900117-add-conditions-to-custom-fields#320497 "-- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.2.26  Hello,  I created a custom field where there is a Dropdown menu (see in attach) where it&#96;s possible to select the delivery hours, but I want to display only the hours from now to the end of the day. Is it possible to manage this directly to the back end component or I have to modify the code?  Thank you for your support  Best regards")*

Hi,

That will require developing a plugin to add a new type of custom field based on the single dropdown type but with a dynamic calculation of the choices available.
You can't do that with the options available by default.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMDExNy1hZGQtY29uZGl0aW9ucy10by1jdXN0b20tZmllbGRzP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

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

Less More

- Posts: 85
- Thank you received: 9
-
-

6 years 2 hours ago [\#325469](#325469) by [pagemaster](/forum/user/50033-pagemaster "View pagemaster's Profile")  Replied by *[pagemaster](/forum/user/50033-pagemaster "View pagemaster's Profile")* on topic *[Add conditions to custom fields](/forum/4-how-to/900117-add-conditions-to-custom-fields#325469 "-- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.2.26  Hello,  I created a custom field where there is a Dropdown menu (see in attach) where it&#96;s possible to select the delivery hours, but I want to display only the hours from now to the end of the day. Is it possible to manage this directly to the back end component or I have to modify the code?  Thank you for your support  Best regards")*

I solved with custom code.

This is the code of the view **HikaShop - checkout / show\_block\_fields.php**:
Code:

if(empty($this-&gt;options['read_only'])) { $onWhat = ($oneExtraField-&gt;field_type == 'radio') ? 'onclick' : 'onchange'; $stringShippingHours = explode("select", $this-&gt;fieldClass-&gt;display( $oneExtraField, false, false, false )); ?&gt; &lt;?php if($_SESSION["nField"] == 0){ ?&gt; &lt;select id="orariodconsegna" name="data[order_1_4][orariodconsegna]" size="1" class="hikashop_field_dropdown hkform-control" onchange="window.hikashop.toggleField(this.value,'orariodconsegna','order_1_4',0,'hikashop_');"&gt; &lt;?php foreach($stringShippingHours as $stringShippingHour){ $tz = 'Europe/Rome'; $timestamp = time(); $dt = new DateTime("now", new DateTimeZone($tz)); //first argument "must" be a string $dt-&gt;setTimestamp($timestamp); //adjust the object to correct timestamp $actualHour = $dt-&gt;format('H'); $nextHour = $actualHour + 1; if($nextHour &lt; 10){ $nextHour = '0' . $nextHour; } $fromNow = explode($actualHour . ':00-' . $nextHour . ':00&lt;/option&gt;', $stringShippingHour); echo $fromNow[1] . '&lt;br&gt;'; } ?&gt; &lt;/select&gt; &lt;?php } ?&gt; &lt;?php }else{ echo $this-&gt;fieldClass-&gt;show($oneExtraField, @$cart-&gt;cart_fields-&gt;$fieldName); } ?&gt;

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMDExNy1hZGQtY29uZGl0aW9ucy10by1jdXN0b20tZmllbGRzP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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.098 seconds

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