Created
April 22, 2021 14:28
-
-
Save ucheng/7897f1bc390f56f82915d5c3e97600ee to your computer and use it in GitHub Desktop.
build custom shipping address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $raw_address = Array ( | |
// [first_name] => YU CHENG | |
// [last_name] => WANG | |
// [company] => | |
// [address_1] => 新北路 | |
// [address_2] => | |
// [city] => 板橋區 | |
// [state] => NEW TAIPEI CITY | |
// [postcode] => 100 | |
// [country] => TW | |
// ) | |
$country = $order->get_shipping_country(); // country code, ex: TW | |
$city = $order->get_shipping_city(); | |
$states = WC()->countries->get_states(); // state codes | |
$state = $order->get_shipping_state(); // shipping state code | |
$full_state = ( $country && $state && isset($states[$country][$state])) ? $states[$country][$state] : $state; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment