如何通过编程方式知道magento中的发货地址的状态


How to know the state of the shipping address in magento programmatically?

我正在用magento编写以下代码。

$orderId = '100000023';
        $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
        $billingAddress = $order->getBillingAddress();
        $shippingAddress = $order->getShippingAddress();
        print_r($billingAddress);

现在,如果我想要运输的状态,要使用的GET函数是什么(如果有的话)。如果不起作用,获取运输状态的方法是什么

Region是magento中地址状态的变量名。您可以获得它:

    $orderId = '100000023';
    $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
    $billingAddress = $order->getBillingAddress();
    $shippingAddress = $order->getShippingAddress();
    echo $shippingAddress->getRegion(); 

如果你想获得地区id,那么用获取

<?php echo $shippingAddress->getRegionId();?>

如果您想查看来自某个模型的所有数据(在本例中为发货地址),只需将debug()方法与Zend_debug结合使用即可转储所有数据:

$orderId = '100000023';
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$billingAddress = $order->getBillingAddress();
$shippingAddress = $order->getShippingAddress();
Zend_Debug::dump($shippingAddress->debug());

你应该得到这样的东西:

array(13) {
  ["entity_id"] => string(1) "2"
  ["parent_id"] => string(1) "1"
  ["region_id"] => string(2) "15"
  ["region"] => string(8) "Delaware"
  ["postcode"] => string(6) "12345"
  ["lastname"] => string(3) "Musterman"
  ["street"] => string(5) "Main Street"
  ["city"] => string(4) "Newark"
  ["email"] => string(13) "someemail@gmail.com"
  ["telephone"] => string(6) "234324"
  ["country_id"] => string(2) "US"
  ["firstname"] => string(3) "Max"
  ["address_type"] => string(8) "shipping"
}

您可以通过以下方式获取所有这些数据:

$shippingAddress->getEntityId();
$shippingAddress->getParentId();
$shippingAddress->getRegionId();
$shippingAddress->getRegion();
...