如何以编程方式了解 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 函数是什么(如果有)。如果无法正常运行,获取运输状态的方式是什么

区域是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();
...