Created
April 19, 2022 10:59
-
-
Save jswebschmiede/eb903142ac2ee0f100672f600f3ce9f3 to your computer and use it in GitHub Desktop.
Wordpress - WooCommerce get physical store address
This file contains 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
// The main address pieces: | |
$store_address = get_option( 'woocommerce_store_address' ); | |
$store_address_2 = get_option( 'woocommerce_store_address_2' ); | |
$store_city = get_option( 'woocommerce_store_city' ); | |
$store_postcode = get_option( 'woocommerce_store_postcode' ); | |
// The country/state | |
$store_raw_country = get_option( 'woocommerce_default_country' ); | |
// Split the country/state | |
$split_country = explode( ":", $store_raw_country ); | |
// Country and state separated: | |
$store_country = $split_country[0]; | |
$store_state = $split_country[1]; | |
echo $store_address . "<br />"; | |
echo ( $store_address_2 ) ? $store_address_2 . "<br />" : ''; | |
echo $store_city . ', ' . $store_state . ' ' . $store_postcode . "<br />"; | |
echo $store_country; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment