Php 作为客人结账时,Magento通过url或会话自动填写账单地址表
情况:以来宾身份结账(数据库中没有客户账单地址) 问题:如何使用url或会话中的变量自动填写账单地址表 对我来说,完美的解决方案是:Php 作为客人结账时,Magento通过url或会话自动填写账单地址表,php,magento,zend-form,Php,Magento,Zend Form,情况:以来宾身份结账(数据库中没有客户账单地址) 问题:如何使用url或会话中的变量自动填写账单地址表 对我来说,完美的解决方案是: 尽可能少地更改,例如在此文件中 app/design/frontend/default/my_theme_name/template/persistent/checkout/onepage/billing.phtml 并以这种方式访问变量 $this->getAddress()->getName() 我的临时解决办法: /* array comes from
/* 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();
不要使用“$this”
这里它必须是报价对象(Mage\u Sales\u Model\u Quote
),而不是计费块(Mage\u Checkout\u Block\u Onepage\u Billing
)。使用$this->getQuote()
不要使用
“$this”
这里它必须是报价对象(Mage\u Sales\u Model\u Quote
),而不是计费块(Mage\u Checkout\u Block\u Onepage\u Billing
)。使用$this->getQuote()
所以你想自动填写一个地址,他们还没有提供?准确地说。你知道如何解决这个问题吗?所以你想自动填写一个地址,他们还没有提供?准确地说。你知道如何解决这个问题吗?
$this
->setBillingAddress(Mage::getSingleton('sales/quote_address')
->importCustomerAddress($customAddress));