Custom Code Where to put it?

  • Posts: 20
  • Thank you received: 1
  • Hikashop Business
3 years 5 months ago #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

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
3 years 5 months ago #333223

Hi,

Normally, you're supposed to add your custom code in view overrides via the Display>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 or Create an account to join the conversation.

  • Posts: 20
  • Thank you received: 1
  • Hikashop Business
3 years 5 months ago #333316

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 or Create an account to join the conversation.

Time to create page: 0.061 seconds
Powered by Kunena Forum