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

#   Custom Code Where to put it?

##

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

Less More

- Posts: 20
- Thank you received: 1
-
-
- [](https://starwoodsystems.com/)
-

5 years 5 months ago [\#333199](#333199) by [speru](/forum/user/26914-speru "View speru's Profile")  *[Custom Code Where to put it?](/forum/2-general-talk-about-hikashop/902720-custom-code-where-to-put-it#333199 "-- HikaShop version -- : 4.4.1 -- Joomla version -- : 3.9.27 -- PHP version -- : 7.4.19 -- Browser(s) name and version -- : Firefox 90.0b3  Hi I modify various templates so I can modify the display to what I require. Currently I add all my custom code to the end of the relevant HikaShop files. However, if I want to re-use my custom code, I have to duplicate it in each HikaShop files that I modify. So, is there a custom directory where I can store my files with custom functions / classes that can then be called from my modified HikaShop files?  For example, I have modified the product/cart.php file to add some complex validation based on what is in the cart. I would like to now run the same checks on the checkout page, but I don't want to have to copy/paste the code from the productcart.php customised file.  Thanks")* was created by *[speru](/forum/user/26914-speru "View speru's Profile")*

-- HikaShop version -- : 4.4.1
-- Joomla version -- : 3.9.27
-- PHP version -- : 7.4.19
-- Browser(s) name and version -- : Firefox 90.0b3

Hi
I modify various templates so I can modify the display to what I require. Currently I add all my custom code to the end of the relevant HikaShop files.
However, if I want to re-use my custom code, I have to duplicate it in each HikaShop files that I modify. So, is there a custom directory where I can store my files with custom functions / classes that can then be called from my modified HikaShop files?

For example, I have modified the product/cart.php file to add some complex validation based on what is in the cart. I would like to now run the same checks on the checkout page, but I don't want to have to copy/paste the code from the productcart.php customised file.

Thanks

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzkwMjcyMC1jdXN0b20tY29kZS13aGVyZS10by1wdXQtaXQ/dG1wbD1tYXJrZG93bg==) 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: 86586
- Thank you received: 14325
-
-

5 years 5 months ago [\#333223](#333223) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Custom Code Where to put it?](/forum/2-general-talk-about-hikashop/902720-custom-code-where-to-put-it#333223 "-- HikaShop version -- : 4.4.1 -- Joomla version -- : 3.9.27 -- PHP version -- : 7.4.19 -- Browser(s) name and version -- : Firefox 90.0b3  Hi I modify various templates so I can modify the display to what I require. Currently I add all my custom code to the end of the relevant HikaShop files. However, if I want to re-use my custom code, I have to duplicate it in each HikaShop files that I modify. So, is there a custom directory where I can store my files with custom functions / classes that can then be called from my modified HikaShop files?  For example, I have modified the product/cart.php file to add some complex validation based on what is in the cart. I would like to now run the same checks on the checkout page, but I don't want to have to copy/paste the code from the productcart.php customised file.  Thanks")*

Hi,

Normally, you're supposed to add your custom code in view overrides via the Display&gt;Views menu (or following the standard view override mechanisms in Joomla).
When you do so, all your view overrides are stored in the folder templates/YOUR_TEMPLATE/html/com_hikashop/
So what you can do is add a file in that folder with your functions.
Then, in the override files you can add a require_once() on that file so that you'll be able to use the functions from there in your custom code.

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

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

Less More

- Posts: 20
- Thank you received: 1
-
-
- [](https://starwoodsystems.com/)
-

5 years 5 months ago [\#333316](#333316) by [speru](/forum/user/26914-speru "View speru's Profile")  Replied by *[speru](/forum/user/26914-speru "View speru's Profile")* on topic *[Custom Code Where to put it?](/forum/2-general-talk-about-hikashop/902720-custom-code-where-to-put-it#333316 "-- HikaShop version -- : 4.4.1 -- Joomla version -- : 3.9.27 -- PHP version -- : 7.4.19 -- Browser(s) name and version -- : Firefox 90.0b3  Hi I modify various templates so I can modify the display to what I require. Currently I add all my custom code to the end of the relevant HikaShop files. However, if I want to re-use my custom code, I have to duplicate it in each HikaShop files that I modify. So, is there a custom directory where I can store my files with custom functions / classes that can then be called from my modified HikaShop files?  For example, I have modified the product/cart.php file to add some complex validation based on what is in the cart. I would like to now run the same checks on the checkout page, but I don't want to have to copy/paste the code from the productcart.php customised file.  Thanks")*

Many thanks for your reply.
I thought it might be something like that, but was not sure where to store my code.
I will give it a try and let you know how it goes.
Thanks

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

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