The billing state is correctly being display in checkout page and is required for all countries but for some reason it’s not being displayed neither in the order detail pages (thankyou page + order admin page) and emails except for United States even though the state is correctly saved in the database.
I don’t want to use this:
/ Display billing state in admin order details
add_action('woocommerce_admin_order_data_after_billing_address', 'display_billing_state_in_admin_order', 10, 1);
function display_billing_state_in_admin_order($order) {
$billing_state = $order->get_billing_state();
if ($billing_state) {
echo '<p><strong>' . __('Billing State:', 'woocommerce') . '</strong> ' . esc_html($billing_state) . '</p>';
} else {
echo '<p><strong>' . __('Billing State:', 'woocommerce') . '</strong> ' . __('N/A', 'woocommerce') . '</p>';
}
}
// Display billing state in WooCommerce emails
add_action('woocommerce_email_order_meta', 'display_billing_state_in_emails', 20, 4);
function display_billing_state_in_emails($order, $sent_to_admin, $plain_text, $email) {
$billing_state = $order->get_billing_state();
if ($billing_state) {
echo '<p><strong>' . __('Billing State:', 'woocommerce') . '</strong> ' . esc_html($billing_state) . '</p>';
} else {
echo '<p><strong>' . __('Billing State:', 'woocommerce') . '</strong> ' . __('N/A', 'woocommerce') . '</p>';
}
}
but rather to ensure that the state is displayed not only for the US
(country code) but for all countries.
Thanks in advance 🙂
Rush84800 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.