Jump to content

Action Hook not firing?


alturic

Recommended Posts

<?php
function create_store($OrderID, $OrderNumber, $InvoiceID, $Products, $Addons, $Domains) {
echo"<pre>";
print_r($OrderID);
print_r($OrderNumber);
print_r($InvoiceID);
print_r($Products);
print_r($Addons);
print_r($Domains);
echo"</pre>";
}
add_hook("AfterShoppingCartCheckout",1,"create_store","");
?>

 

Unless I'm misunderstanding what should happen here (I don't think I am simply do to "where else will these echo", the user should get this echo'ed to them upon checkout, right?

 

I have a file in includes/hooks called blah.php and nothing happens at checkout, anywhere.

Link to comment
Share on other sites

the right format is like that:

function create_store($vars) {

$orderID = $vars['orderid'];
$orderNumber = $vars['order_number'];

}
add_hook("AfterShoppingCartCheckout",1,"create_store"); 

 

- - - Updated - - -

 

i'm not sure in the AfterShoppingCartCheckout hook got deprecated - it's not on the list of hooks below...

 

http://docs.whmcs.com/Hooks:Alphabetical

http://forum.whmcs.com/showthread.php?94566-Is-the-AfterShoppingCartCheckout-hook-still-supported

not quite sure, i didn't saw it on the list too, but the documentation exist, and with no mention to deprecation or so

http://docs.whmcs.com/Hooks:AfterShoppingCartCheckout

Link to comment
Share on other sites

Let me explain what I'm looking to do and you guys give me input on which hook you'd use. So I have a script that will add a user to our forum. Great, if it was for all users we can use anything, BUT what all vars can you pull? Example, I only want it to fire if the order has been paid and only if one of the $products has a Yes for a configoptions optionname, so I was thinking of doing the hook for accept order because we'd only accept an order if the invoice is paid.

 

Also, if I did hook it to accept order, would I have to do foreach's for when/if we bulk approve orders? Or do these hooks fire once for each order if bulk "accept order"ing?

 

- - - Updated - - -

 

Oh, and i dont have to include hooks in the hooks dir, right? Whmcs will always include all files in there?

Link to comment
Share on other sites

hook actions will run once per order so you don't need the foreach part

 

if you need to create forum account for client when they order (and pay) for the first time, you may need to use InvoicePaid action hook,

you can first check if the account created before (in forum DB) if not create it then.

http://docs.whmcs.com/Hooks:InvoicePaid

 

- - - Updated - - -

 

Oh, and i dont have to include hooks in the hooks dir, right? Whmcs will always include all files in there?

all files in /includes/hooks folder called automatically by WHMCS, you job is to write the right syntax and let WHMCS handle it

Link to comment
Share on other sites

  • 6 months later...

How can I access AfterShoppingCartCheckout variables, for example 'orderid' or 'orderdomainsid'? I have created 'myaddon' addon, activated in admin backend, created myaddon.php and hooks.php files, with following code in hooks.php file:

 

<?php

 

/**

*

* TEST HOOK

*

*/

 

function hook_MyAddonOrderTest($vars)

{

//print_r($params);

mail('me@domain.com', 'test', $vars['orderid']);

}

 

add_hook("AfterShoppingCartCheckout", 1, "hook_MyAddonOrderTest");

 

I have tested and hook runs normally, I receive mail, but I can't access any of avaliable variables, according to docs. Is there any chance to access hook related variables inside hook, or I am doing something wrong?

 

Any help would be appreciated.

 

Thanks,

 

Alan

Link to comment
Share on other sites

Hi, sentq

 

I figured it out. It seems that documentation for AfterShoppingCartCheckout is outdated. Full list of avaliable variables is as follows:

 

Array

(

[OrderID] => 36

[OrderNumber] => 1093359502

[serviceIDs] => Array

(

 

)

 

[DomainIDs] => Array

(

)

 

[AddonIDs] => Array

(

)

 

[RenewalIDs] => Array

(

)

 

[PaymentMethod] =>

[invoiceID] =>

[TotalDue] =>

[Products] => Array

(

 

)

 

[Domains] => Array

(

)

 

[Addons] => Array

(

)

 

[Renewals] => Array

(

)

 

)

Link to comment
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