OK so I have a function as an extension to the firecheckout module to check if the email entered exists as a customer account...
I've basically followed the steps found on this url (Solution 1).. http://www.helpsforcoder.com/magento/31953-check-for-customer-email-address-exists-in-checkout.html
I've added that function to the file at...
/app/code/local/TM/FireCheckout/controllers/IndexController.php
Within class TM_FireCheckout_IndexController extends Mage_Checkout_OnepageController
But when I try to call the function over ajax I get the html for a 404 page in the alert... here's my JavaScript function...
jQuery('input[title="Email Address"]').blur(function(){
var email = jQuery(this).val();
new Ajax.Request("<?php echo $this->getUrl('firecheckout/index/checkEmailexists');?>", {
method: 'Post',
parameters: {'billing[email]':email},
onComplete: function(transport) {
alert(transport.responseText);
}
});
});
here's the IndexController.php SE wouldnt let me post the whole file... too big so I've removed other functions...
<?php
require_once 'Mage/Checkout/controllers/OnepageController.php';
class TM_FireCheckout_IndexController extends Mage_Checkout_OnepageController
{
protected $_updateCheckoutLayout = null;
protected $_shippingMethodDependsOnAddress = null;
protected $_totalDependsOnShippingAddress = null;
//other native functions go here...
public function checkEmailexistsAction()
{
if ($this->_expireAjax()) {
echo 'Ajax Expired';
return;
}
if (!$this->getRequest()->isPost()) {
echo '!isPost';
return;
}
$websiteId = Mage::app()->getWebsite()->getId();
$data = $this->getRequest()->getPost('billing', array());
$email = $data['email'];
$customer = Mage::getModel('customer/customer');
if ($websiteId) {
$customer->setWebsiteId($websiteId);
}
$customer->loadByEmail($email);
if ($customer->getId()) {
// This is the part of the code that runs when a customer exists ...
return true;
}
else {
// This is the part of the code that runs when a customer does not yet exist ...
return false;
}
}
}