Jump to content
jimlongo

hook for output on cart page

Recommended Posts

I'm landing on a page that looks like

mywhmcs.com/cart.php?a=confproduct

I need to do some work and ouput some html or javascript in my addon module.

I've tried a bunch of hooks in '/addons/mymodule/hooks.php', can't find one that ouputs to the body of the page.

 

Thanks.

Share this post


Link to post
Share on other sites

Let me rephrase my question.  I'm a little confused by the documentation about hooks.

Originally this module was inherited from a well known developer of modules.

It has both "/addons/MyModule/hooks.php" and  "/servers/MyModule/hooks.php" files.

The functions and hooks in "/servers/MyModule/hooks.php" are the ones that have stopped firing.  Looking through the activity log, i don't even see an attempt to load this file.

Q: what is the difference between these 2 files and "/includes/hooks/MyModule.php" ?  Because when I move the hooks from /servers/ to /includes/ they now fire as I would expect.  For instance ClientAreaPageCart hook now fires when I'm on the page.  What are the reasons for having the various places to put hooks?

Edited by jimlongo

Share this post


Link to post
Share on other sites

I suspect you created hooks.php file when the module was already activated. In this case your file is ignored as WHMCS detects it only on module activation. You have two options: 

  • Deactivate and reactivate the module 
  • In tblconfiguration there's a setting that stores a comma separated list of modules that are using hooks.php. I can't remember the exact name of tblconfiguration.setting but it should be something like "ModuleHooks". Add you module to the list and save

Share this post


Link to post
Share on other sites
Posted (edited)

@Kian Thank you. No that's not the case, and thank you I did know that you need to deactivate-reactivate the module when making changes.

The information i'm really looking for is an explanation of what the various hooks files should be used for.  Surely it's not just a matter of use whichever one you want.

We have servers/mymodule/hooks.php, addons/mymodule/hooks.php and includes/hooks/anything.php, I think this requires some explanation in the docs.

https://developers.whmcs.com/hooks/getting-started/

 

Regarding your second bullet, I have tblconfiguration.ModuleHooks.value = cpanel,plesk

Edited by jimlongo

Share this post


Link to post
Share on other sites
17 minutes ago, jimlongo said:

We have servers/mymodule/hooks.php,

that's a provisioning module - https://developers.whmcs.com/provisioning-modules/

17 minutes ago, jimlongo said:

addons/mymodule/hooks.php

that's an addon module - https://developers.whmcs.com/addon-modules/

18 minutes ago, jimlongo said:

includes/hooks/anything.php

hooks without a module. 🙂

Share this post


Link to post
Share on other sites
Posted (edited)

@brian!Thank you.

Perhaps you could expand a little bit.  My module acts within WHMCS pages( adding UI, adjusting prices, expecting input), I assume that's an add-on module?

Sometimes it is provisioning services (for instance when an order has been placed and submitted), I guess a provisioning module.

hooks without a  module . . . would I ever need this?

Edited by jimlongo

Share this post


Link to post
Share on other sites
18 hours ago, Kian said:
  • In tblconfiguration there's a setting that stores a comma separated list of modules that are using hooks.php. I can't remember the exact name of tblconfiguration.setting but it should be something like "ModuleHooks". Add you module to the list and save

This is correct.  Somehow my module had been removed from the list.   if it's in the list then WHMCS looks for the hooks in /servers/MyModule/hooks.php

There may be another way (besides manually) to get it in the list, but I found that by "resaving" any of the Products/Services that uses my module (Product>Module Settings), it was put back in the list. 

Share this post


Link to post
Share on other sites
19 hours ago, jimlongo said:

Perhaps you could expand a little bit.  My module acts within WHMCS pages( adding UI, adjusting prices, expecting input), I assume that's an add-on module?

it's location tells you what it is - or should do. 🙂

19 hours ago, jimlongo said:

hooks without a  module . . . would I ever need this?

probably often... I mean, if you were coding a navbar hook to change the a menu in the client area, you wouldn't necessarily create an addon module just for that simple purpose - you could and it would work, but i'd consider it overkill.

I think most of the hooks posted in this place will be for the /includes/hooks directory - though that doesn't mean that they can't also be used in addon modules too.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated