Magento – Check if registration during checkout

checkoutregister

can anyone tell me how I can find out if the registration of a new customer is done during the checkout or not. I need to know this information in the accountcontroller.

Edit:
My aim is to get rid of the message "If you are a registered VAT customer, please…" in success.phtml, but only if the customer was registered during the checkout.
Because I've disabled "account confirmation" and forwarding to "account overview" the customer can complete the purchase and after that this message appears – but doesn't make sense any more.

So in short I've got two use cases:

  • 1.) normal registration -> message added to queue (in AccountController->_welcomeCustomer) -> message displayed after finishing registration -> OK
  • 2.) checkout -> registration -> message added to queue (in AccountController->_welcomeCustomer) -> next steps in checkout-> purchase -> message displayed after purchase -> NOT OK

Thanks.

Best Answer

You can try this logic.
Get the first order of the customer.
Get the quote object of the order.
Check the checkout method of the quote.

Something like this:

$customerId = Mage::getSingleton('customer/session')->getCustomer()->getId()
$orders = Mage::getModel('sales/order')->getCollection()
    ->addFieldToFilter('customer_id', $customerId)
    ->setOrder('entity_id', 'ASC')
    ->setCurPage(1)
    ->setPageSize(1); //limit to 1;
$firstOrder = $orders->getFirstItem(); 

if (!$firstOrder->getId()) {
   //it means the customer did not place any orders so he did not register at checkout
}
else {
    $quoteId = $firstOrder->getQuoteId();
    $quote = Mage::getModel('sales/quote')->load($quoteId);
    $checkoutMethod = $quote->getCheckoutMethod();
    if ($checkoutMethod == 'register') {
        //customer registered at checkout
    }
    else {
       //customer did not register at checkout
    }
}

I didn't test the code but the idea seams ok to me.