Jump to content

Hook $vars show just 1 with print_r ?


kjavitz

Recommended Posts

Hi,

 

having a hardtime getting a list of all available vars from the hook for order creation http://docs.whmcs.com/Hooks:Order_Process.

 

Here is the code, I've tried different methods and always same result all I get is "1" which is not helpful for the email debug. Does anyone have any debug code that works and shows the variables? HELP :?:

 

function create_free_trial($vars) {

$to = "kjavitz@gmail.com";
   $subject = "Hello, i'm the hook!";
   $varsemail = print_r($vars);
   $message = $varsemail;
   $from = "kjavitz@gmail.com";
   $headers = "From:" . $from;
   mail($to,$subject,$message,$headers);

}

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

Link to comment
Share on other sites

Hi

 

You can't print_r(); an array in a mailto(); You have to use $vars["variablename"];

 

function create_free_trial($vars) {

$to = "kjavitz@gmail.com";
   $subject = "Hello, i'm the hook!";
   $varsemail = " 1->".$vars["variable1"]." 2->".$vars["variable2"]." 3->".$vars["variable3"]." ";
   $message = $varsemail;
   $from = "kjavitz@gmail.com";
   $headers = "From:" . $from;
   mail($to,$subject,$message,$headers);

}

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

Link to comment
Share on other sites

thanks, actually I figured it out after posting this. The issue was it needed to have print_r($vars, TRUE) to make it return the values like:

 

$varsemail = print_r($vars, TRUE);

 

then all the variables are in the email. Weird thing is though that the product id returned is wrong it should be the product id of 15 but instead it gives the service id so I can't do an if statement to check what product was ordered, it does not give the product id for product, rather the order id, so I'll have ot custom code that I guess.

 

Array
(
   [OrderID] => 876
   [OrderNumber] => 5525116701
   [serviceIDs] => Array
       (
           [0] => 987
       )

   [DomainIDs] => Array
       (
       )

   [AddonIDs] => Array
       (
       )

   [RenewalIDs] => Array
       (
       )

   [PaymentMethod] => paypal
   [invoiceID] => 0
   [TotalDue] => 0.00
   [Products] => Array
       (
           [0] => 987
       )

   [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