1

One particular user logged in to his account from frontend and adds some items to the shopping cart. And then he logged out. And again when he logged in I want to get his quote address object.

How to achieve this? Is there any event which fires and I can get the quote address object? Any suggestions will be appreciated.

2 Answers 2

2

To get a customer's default billing adress you can do the following:

<?php
$customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
$visitorData = Mage::getModel('customer/customer')->load($customerId);
$billingaddress = Mage::getModel('customer/address')->load($visitorData->default_billing);
$addressdata = $billingaddress ->getData();
$addressdata['street'];
$addressdata['city'];
$addressdata['postcode'];
$addressdata['region'];
$addressdata['telephone'];

var_dump($addressdata);
2
  • I was asking about quote address object. Not the customer billing address.
    – Sukeshini
    Nov 5, 2013 at 3:12
  • 2
    From what I understood, he didn't actually order anything right? He just put some items on the shopping cart and logged out. If that's the case, there's no quote address to get, only his default address that the customer filled when signing up. Nov 5, 2013 at 12:49
1

What you can do is listen to customer_customer_authenticated then get the quote_address:

$quote = Mage::getResourceModel('sales/quote_collection')
    ->addAttributeToFilter('customer_id', $customer->getId())
    ->addAttributeToFilter('is_active', 1)
    ->getFirstItem();

if($quote) {
    $quote->getBillingAddress(); // quote billing address object
    $quote->getShippingAddress(); // quote shipping address object
}

if you are using the multi checkout you want to use getAllShippingAddresses() and maybe the method getAllAddresses() on $quote is interesting for you.

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.