omega1 Posted November 2, 2019 Share Posted November 2, 2019 Hi, I am using the ShoppingCartCheckoutCompletePage hook to perform some backend server work whenever a customer pays for a service, but I also need their email address. ShoppingCartCheckoutCompletePage does not seem to contain the email address, what is the easiest way to do this? I am assuming that the only way to do this is somehow use the orderid available in ShoppingCartCheckoutCompletePage and work backwards to match it to a customer in the WHMCS database? Any suggestions? Thank you. 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted November 3, 2019 Share Posted November 3, 2019 You should be able to find the email address in $vars['clientdetails']. It contains an array of the client details. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 3, 2019 Share Posted November 3, 2019 just to expand on Dennis' answer, by the time the user reaches the complete page, they'll definitely be logged in and so that's why you'll have access to the $clientsdetails array. note that the array is called $clientsdetails and not $clientdetails as Dennis mentioned... that's a mistake i've made plenty of times myself! 🙄 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted November 3, 2019 Share Posted November 3, 2019 1 minute ago, brian! said: note that the array is called $clientsdetails and not $clientdetails as Dennis mentioned... that's a mistake i've made plenty of times myself! 🙄 Ah balls, you're right. The naming is not logical 😄 0 Quote Link to comment Share on other sites More sharing options...
omega1 Posted November 3, 2019 Author Share Posted November 3, 2019 Hi, many thanks both for your replies, much appreciated. Just checking, is it this part of the array for the email address? $email = $clientsdetails['email']; And this is definitely available within ShoppingCartCheckoutCompletePage? Thanks again. 0 Quote Link to comment Share on other sites More sharing options...
omega1 Posted November 3, 2019 Author Share Posted November 3, 2019 Just checking this again... The hook page for ShoppingCartCheckoutCompletePage says it is 'clientdetails' not 'clientsdetails' is the hook page wrong? https://developers.whmcs.com/hooks-reference/shopping-cart/#shoppingcartcheckoutcompletepage Also, I guess that if I'm using this: <?php add_hook('ShoppingCartCheckoutCompletePage', 1, function($vars) { // My PHP code }); Then this would give me the email address? $customer_email = $vars['clientsdetails']['email']; Thanks again. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 3, 2019 Share Posted November 3, 2019 (edited) 12 minutes ago, omega1 said: The hook page for ShoppingCartCheckoutCompletePage says it is 'clientdetails' not 'clientsdetails' is the hook page wrong? https://developers.whmcs.com/hooks-reference/shopping-cart/#shoppingcartcheckoutcompletepage possibly it has access to both... 12 minutes ago, omega1 said: Then this would give me the email address? that's the way that I would do it (by accessing $vars) Edited November 3, 2019 by brian! 0 Quote Link to comment Share on other sites More sharing options...
omega1 Posted November 3, 2019 Author Share Posted November 3, 2019 Thanks brain! For future reference, this worked: $customer_email = $vars['clientdetails']['email']; 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.