1 回答

TA貢獻(xiàn)1851條經(jīng)驗 獲得超5個贊
嘗試以下操作(假設(shè)$order變量被定義為當(dāng)前WC_Order對象):
<?php
$shipping_country = $order->get_shipping_country();
$shipping_state = $order->get_shipping_state();
if( ! empty($shipping_state) ) {
$country_states = WC()->countries->get_states( $shipping_country );
$value = isset($country_states[$shipping_state]) ? $country_states[$shipping_state] : $shipping_state;
if( ! empty($value) ) {
echo '<p><strong>' . __("Region / Province", "woocommerce") . '</strong>: ' . esc_html($value) . '</p>';
}
}
?>
經(jīng)過測試并有效。
- 1 回答
- 0 關(guān)注
- 151 瀏覽
添加回答
舉報