Foxy Forum Status

We're no longer responding to questions via our forum, but we will keep it up for historical reasons. If you can't find the answer you're looking for, please visit our knowledge base or contact us. If there's enough interest in the future, we may bring the forum back.

Get Customer Id and Customer Email in Checkout and Receipt

I am using v1.1. I am trying to get the customer's email and id for conversions within a tracking system. I figured they would be part of the FC.json object or something like that, but I can't seem to find them.

Are these available in the JS of the Checkout and Receipt templates?
  • Ok, I did find that there is a hidden input field <input type="hidden" id="customer_id" name="customer_id" value="o"> that is updated once the user logs in on the checkout page. Now I just need to see if I can get that info on the receipt page.

    Any ideas?
  • fc_adamfc_adam FoxyCart Team

    On version 1.1 receipt - you can get the customer email address like this: jQuery(".fc_customer_email .fc_text").html() - but unfortunately the customer ID isn't available on the receipt.

    Does this tracking need to happen with javascript? Or could it be done server-side using PHP or another server-side language? If you could, you could make use of our webhooks which will contain all the order information, along with the email and customer ID.

    For what it's worth - on 2.0 the customer ID and email is available within the JSON object.
  • It is used with javascript. Any reason why I couldn't/shouldn't send the customer_id along as a hidden custom field?
  • So I fixed up an API call using AJAX and PHP with the file living on my server, but it's being blocked because it's not on a https. Is there anyway around that?
  • fc_adamfc_adam FoxyCart Team

    What is the file on your server doing exactly? Is that where you're sending the analytics to? If so - you could make use of our webhooks and pass the information to your endpoint from your webhooks endpoint - details on that here:

    If you're trying to do this on the receipt though - with 2.0 there is a setting on the configuration page for changing the receipt to be served over HTTP instead of HTTPS. If you're talking about the checkout though, there is no way around it - all communication in and out needs to be done over HTTPS.
  • @fc_adam

    So all I need is the customer_id on the checkout page. I've got the receipt page working ok now. The PHP I have on my site is just getting some basic customer info, but all I really need is to get the customer_id once the customer logs in. I saw this snippet, , which should work fine, but it looks like the customer_id hidden field's value isn't the actual user id number. Otherwise that would be plenty.

    Thanks again
  • fc_adamfc_adam FoxyCart Team

    Could you confirm for me though - are you collating/collecting all of this on your server with a PHP script? If so - I would strongly recommend making use of the webhooks rather than passing it from the checkout/receipt.

    Another option would be to upgrade to 2.0 and you'd have that data available from the receipt there as well.
Sign In or Register to comment.