Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jswebschmiede/eb903142ac2ee0f100672f600f3ce9f3 to your computer and use it in GitHub Desktop.
Save jswebschmiede/eb903142ac2ee0f100672f600f3ce9f3 to your computer and use it in GitHub Desktop.
Wordpress - WooCommerce get physical store address
// 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