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

#   Address dropdown override

##

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

Less More

- Posts: 61
- Thank you received: 3
-
-

2 years 3 weeks ago [\#364126](#364126) by [demoisellegol](/forum/user/79354-demoisellegol "View demoisellegol's Profile")  *[Address dropdown override](/forum/27-checkout/908802-address-dropdown-override#364126 "-- HikaShop version -- : 5.1.1 -- Joomla version -- : 5.2.0 -- PHP version -- : 8.2  hi I need to add a class to dropdown fields in checkout address block with overrides  earlier i created overrides for filters and ... as described in developer docs and it worked great  but when i do the same for field.override.php it doesnt work  please see the attached screenshot ..")* was created by *[demoisellegol](/forum/user/79354-demoisellegol "View demoisellegol's Profile")*

-- HikaShop version -- : 5.1.1
-- Joomla version -- : 5.2.0
-- PHP version -- : 8.2

hi
I need to add a class to dropdown fields in checkout address block with overrides

earlier i created overrides for filters and ... as described in developer docs and it worked great

but when i do the same for field.override.php it doesnt work

please see the attached screenshot ..  [ ![2024-10-28&#95;11-13-34.jpg](/forum/attachment/59936) ](/forum/attachment/59936 "...8&#95;11-13-34.jpg")

- [ ![2024-10-28&#95;11-13-34.jpg](/forum/attachment/59936) ](/forum/attachment/59936 "...8&#95;11-13-34.jpg") [ ](/forum/attachment/59936?download=1 "...8&#95;11-13-34.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwODgwMi1hZGRyZXNzLWRyb3Bkb3duLW92ZXJyaWRlP3RtcGw9bWFya2Rvd24=) 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: 86582
- Thank you received: 14322
-
-

2 years 3 weeks ago -  2 years 3 weeks ago [\#364129](#364129) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Address dropdown override](/forum/27-checkout/908802-address-dropdown-override#364129 "-- HikaShop version -- : 5.1.1 -- Joomla version -- : 5.2.0 -- PHP version -- : 8.2  hi I need to add a class to dropdown fields in checkout address block with overrides  earlier i created overrides for filters and ... as described in developer docs and it worked great  but when i do the same for field.override.php it doesnt work  please see the attached screenshot ..")*

Hi,

The field class file is special. It has the main class hikashopFieldClass which you can override normally. But it also have one class for each field type. It also has parent type classes like hikashopFieldDropdown and hikashopFieldItem which the type classes extend from.

So, suppose that your field uses the "single dropdown" type. The class which will be used is hikashopFieldSingledropdown which extends from hikashopFieldDropdown. When a field of that type has to be rendered, the _getFieldTypeClass method of hikashopFieldClass will look for the class hikashopFieldSingledropdown and load it.
If that class extends from hikashopFieldDropdown it will use it, even if you have a hikashopFieldDropdownOverride class defined.

So knowing all that, you need to do two things:
1. create an override class of hikashopFieldClass and override _getFieldTypeClass to look for hikashopFieldSingledropdownOverride and try to use it instead of the default class.
2. create hikashopFieldSingledropdownOverride as a copy of hikashopFieldSingledropdown and extend it from hikashopFieldDropdownOverride instead of hikashopFieldDropdown if you want it to use your override class.

Potentially, we could add by default a few lines of code in _getFieldTypeClass to look for an override class for the type classes. That way, developers would only have to handle that second point.
We didn't do it because HikaShop actually already has a field API which allows developers to add their own custom types to HikaShop:
[ www.hikashop.com/support/documentation/6...entation.html#fields](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#fields)
The plugins/hikashop/datepicker_field/ plugin is a good example of this as this is the plugin responsible for adding the "Advanced date picker" type to HikaShop.
A custom type can extend an existing type if customization is necessary.

Now, I feel like you're going about this the wrong way.
Why not create one or two view overrides where the custom address fields are displayed and just inject the class you want ?
You could for example edit the view file checkout / show_block_address via the menu Display&gt;Views and change the line: Code:

&lt;?php echo $html; ?&gt;

to: Code:

&lt;?php echo str_replace('hikashop_field_dropdown','hikashop_field_dropdown uk-select', $html); ?&gt;

In fact, in your view override, I would rather recommend to remove all the code and replace it with something like this: Code:

&lt;?php ob_start(); include HIKASHOP_ROOT.'components/com_hikashop/views/checkout/tmpl/show_block_address'; $html = ob_get_clean(); echo str_replace('hikashop_field_dropdown','hikashop_field_dropdown uk-select', $html);

Doing it like this means your customization is really minimal. Updates to the original show_block_address view file will still be taken into account so your customization is much more resilient to updates in the long term.

Last edit: 2 years 3 weeks ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

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

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

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