Override function in helper.php

  • Posts: 19
  • Thank you received: 2
  • Hikaserial Standard Hikashop Business
2 years 9 months ago #334251

-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.9.28
-- PHP version -- : 7.4.20
-- Browser(s) name and version -- : all

Hi,

I have a question how to correctly override function in /administrator/components/com_hikashop/helpers/helper.php? I need to change a little the generation of order number in hikashop_encode function. I know how to override some class in helpers (eg image.php) but don't know how to do it with this helper functions.

Thanks, Jan

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

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
2 years 9 months ago #334252

Hi,

Well, it's possible to override the whole function with a system plugin implementing a function of the same name.
However, I would rather recommend you do a normal plugin of the group "hikashop" and implement the onBeforeOrderNumberGenerate(&$data, &$result) and / or the onBeforeInvoiceNumberGenerate(&$data, &$result) events.
In $data, you'll have the information of the order and you can just set in $result whatever you want and it will become the order / invoice number.
If you want to know how to make a plugin, you can read the two first parts of the page www.hikashop.com/support/documentation/6...mentation.html#intro and use the link to the Joomla documentation which goes in depth about creating plugins for Joomla.

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

  • Posts: 19
  • Thank you received: 2
  • Hikaserial Standard Hikashop Business
2 years 9 months ago #334286

Super, thanks, I'll do it this way. It would be fine to mention these events in Hikashop developer documentation.

Jan

Last edit: 2 years 9 months ago by braverman.

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

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
2 years 9 months ago #334287

Hi,

Thanks for the feedback. I've added these to the developer documentation.

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

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
1 year 7 months ago #344596

What is helpers ?

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

  • Posts: 81513
  • Thank you received: 13068
  • MODERATOR
1 year 7 months ago #344601

Hi,

Joomla is based on the MVC model ( en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller ). And HikaShop too.
So in HikaShop's folder, you'll find "classes" which is for the models, "controllers", for the controllers and "views" for the views.
The "helpers" folder contains files with helpers that can be used by the MVC elements which aren't tied to one view, one controller or one model. For example the "translation" helper has functions that are used by the views and controllers to manage the translations of the content.

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

Time to create page: 0.071 seconds
Powered by Kunena Forum