type:
snippet
category:
checkout
name:
Performing actions when customer has logged in on the checkout
versions:
0.7.0, 0.7.1, 0.7.2, 1.0
reference:
http://forum.foxycart.com/discussion/5518/help-with-additional-functionality-of-sso
tags:
checout, snippet, login, authenticated
date:
2012-02-14

Performing actions when customer has logged in on the checkout

Sometimes you need to perform actions only for returning users who have logged into your checkout, such as displaying a 'welcome back' message or displaying special options or pricing for valued customers. This code lets you run logic only when they successfully log in.

Step 1: Add the javascript

Paste the following code above the closing </head> tag in your checkout template:

<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function() {
  jQuery(document).ajaxComplete(function(event, request, settings) {
    if (settings.url.indexOf('CheckLogin') != -1) {
      if (jQuery("#customer_id").val() != 0) {
        // Logic for logged in users here
      }
    }
  });
});
</script>

Site Tools