4

When an unregistered customer goes to the checkout page and registers for an account there, on the final stage when the customer presses "Place order" Magento adds the new customer to the database.

I want to catch that event and get the new customer's details.

Problems

  1. The event customer_register_success doesn't work on the onepage checkout page
  2. The event checkout_type_onepage_save_order_after works every time a customer presses "Place order", and I want to catch only the first time

I want to catch the exact event that adds the new customer after they've registered in the onepage checkout page, and get the details of that new customer (after the event).

2

I've only had a quick look through the Onepage model but it looks like you should be able to use the checkout_type_onepage_save_order_after event, just apply some extra conditions.

As you can see here the core model uses the checkout method to find out what "type" of checkout process it should be.

Knowing what is in the event, you can apply the same logic using that event, i.e.:

/**
 * Event: checkout_type_onepage_save_order_after
 */
public function getNewCustomer(Varien_Event_Observer $observer)
{
    /** @var Mage_Sales_Model_Quote $quote */
    $quote = $observer->getEvent()->getQuote();

    // Don't continue unless it's a new customer registration
    if ($quote->getCheckoutMethod !== Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER) {
        return $this;
    }

    // You know it's a NEW customer now...

    /** @var Mage_Customer_Model_Customer $customer */
    $customer = $quote->getCustomer();
}
  • 2
    Hi Robbie, thank you for your answer, But $quote->getCheckoutMethod() is 'login_in' even on new customer registration, so it's not really helpfull. After a bit of trial and error this "$quote->getCheckoutMethod(true);" gives 'register'. So thank you Joseph – Joseph Aug 2 '16 at 18:40

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.