Custom Code Where to put it?
5 years 3 months ago #333199
by speru
Custom Code Where to put it? was created by speru
-- 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
-- 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.
5 years 3 months ago #333223
by nicolas
Replied by nicolas on topic Custom Code Where to put it?
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.
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.
5 years 3 months ago #333316
by speru
Replied by speru on topic Custom Code Where to put it?
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
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.179 seconds