0

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; 
    }
    }
}

1 Answer 1

0

the controller function name must be name like abcAction().so your function must be public and

checkEmailexistsAction()
4
  • Yea the function is called that public function checkEmailexistsAction()
    – alex
    Oct 6, 2015 at 12:32
  • can you post the IndexController.php in question Oct 6, 2015 at 12:36
  • check the firecheckout in enable from backend? and refresh the cache. i tested this function and it is working for me. Oct 6, 2015 at 12:54
  • yes, firecheckout is enabled, in the console i get... POST hoh.dev/firecheckout/index/checkEmailexists 404 (Not Found)
    – alex
    Oct 6, 2015 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.