1

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.

1

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.

  • Hi Marius, thanks for the extreme fast reply. I've added a little more information in my post. The problem with your solution is that in the method "AccountController->_welcomeCustomer" where I want to include the script the $firstOrder->getId() is always null. – david Sep 3 '14 at 12:27
0

My solution now is to use the $this->_getSession()->getBeforeAuthUrl function which also turns to the url which the customer is forwarded to after the registration process. If it contains checkout/onepage you know the customer started the registration at the checkout.

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.