Jump to content
omega1

Need customer email in ShoppingCartCheckoutCompletePage hook

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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! 🙄

Share this post


Link to post
Share on other sites
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 😄

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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 by brian!

Share this post


Link to post
Share on other sites

Thanks brain!

For future reference, this worked: 

$customer_email = $vars['clientdetails']['email'];

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

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