Last active
June 5, 2024 08:03
-
-
Save braddalton/b8bd51004a6762de9129027a8660f020 to your computer and use it in GitHub Desktop.
WC Shipping Zone ID's https://wpsites.net/wordpress-tutorials/find-woocommerce-shipping-zone-id/
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
add_action('loop_start', 'list_woocommerce_shipping_zones'); | |
function list_woocommerce_shipping_zones() { | |
if ( current_user_can( 'manage_woocommerce' ) ) { | |
$zones = WC_Shipping_Zones::get_zones(); | |
foreach ($zones as $zone) { | |
echo 'Shipping Zone Name: ' . $zone['zone_name'] . ' | ID: ' . $zone['id'] . '<br>'; | |
} | |
// Also include the default zone | |
$default_zone = new WC_Shipping_Zone(0); | |
echo '<span style="position:relative;color:red;z-index: 9999;">Shipping Zone Name: ' . $default_zone->get_zone_name() . ' | ID: ' . $default_zone->get_id() . '<br></span>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment