Jump to content

Need customer email in ShoppingCartCheckoutCompletePage hook


omega1

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.

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

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

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

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