I'm working on a custom module that will display shipping estimates on the product page. All of my customers are required to sign up and log in (it's a trade-only website), so I have the customer's default shipping address at my disposal (guaranteed). Therefor, I'm going to provide a shipping estimate based on the default shipping address. So far, the only way I've found to convert the customer/address
object into a sales_model_quote_address
is as follows:
$customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
$address = Mage::getModel('customer/address')->load($customerAddressId);
$address_data = array (
'prefix' => $address->getPrefix(),
'firstname' => $address->getFirstname(),
'lastname' => $address->getLastname(),
'street' => $address->getStreet(),
'city' => $address->getCity(),
'region_id' => $address->getRegionId(),
'region' => $address->getRegion(),
'postcode' => $address->getPostcode(),
'country_id' => $address->getCountryId(),
'telephone' => $address->getTelephone(),
'email' => $address->getEmail()
);
$quoteShippingAddress = new Mage_Sales_Model_Quote_Address();
$quoteShippingAddress->setData($address_data);
This does work, but it seems a bit hacky/messy. Can anyone suggest a sensible alternative? Thanks in advance.