2

我尝试获取地址,客户在结帐时的地址步骤中选择该地址。

我在 /app/code/local/Mandarin/AddressTypeDiscount/Block/Onepage/Review.php 中使用此代码:

$checkout = Mage::getSingleton('checkout/session')->getQuote();
$bilAddress = $checkout->getBillingAddress();
$mylog = print_r($bilAddress, true);
Mage::log("addres:".$mylog, null, 'mygento.log');

但在我的日志文件中,我得到了所有客户地址的数组。

我如何在地址步骤中获得选定的地址?谢谢。

4

2 回答 2

10

您的代码似乎是正确的,请参阅Magento 中一页结帐的订单审查部分中的获取帐单信息

print_r($bilAddress, true)将打印整个对象,而不是尝试$bilAddress->getData()

尝试

 $checkout = Mage::getSingleton('checkout/session')->getQuote();
 $billAddress = $checkout->getBillingAddress();

 Mage::log($billAddress->getData());
于 2013-06-05T13:36:51.623 回答
2

对于基于订单的增量订单地址id,

$order_id=Mage::getSingleton('checkout/session')->getLastRealOrderId();
$sales_order=Mage::getModel('sales/order')->load($order_id);
$billing_address_id=$sales_order->billing_address_id; 
$shipping_address_id=$sales_order->shipping_address_id;

对于基于客户的订单的地址实体 id,

$quote = Mage::getSingleton('checkout/session')->getQuote();
$billing_address_id=$quote->getBillingAddress()->customer_address_id;
$shipping_address_id=$quote->getShippingAddress()->customer_address_id;

来源

于 2013-06-05T13:36:43.367 回答