Situation: Checkout as guest (no customer billing address in database).
Problem: How to fill out the billing address form automatically using variables from url or session?
Perfect solution for me would to be:
change as less as possible e.g. in this file
app/design/frontend/default/my_theme_name/template/persistent/checkout/onepage/billing.phtml
and access variables this way
$this->getAddress()->getName();
My temporary solution:
/* array comes from url or session */
$myAddress = array (
'firstname' => 'John',
'lastname' => 'Smith',
'street' => array (
'0' => '1st Street',
'1' => '2056',
),
'city' => 'Maspeth',
'region_id' => '',
'region' => '',
'postcode' => 'NY11378',
'country_id' => 'US',
'telephone' => '0017183209872'
);
$customAddress = Mage::getModel('customer/address');
$customAddress->setData($myAddress);
/* $this = Mage_Checkout_Block_Onepage_Billing */
$this
->setBillingAddress(Mage::getSingleton('sales/quote_address')
->importCustomerAddress($customAddress));
/* insert value into input field */
echo $this->getBillingAddress()->getName();