Viewing Snippet "Woocommerce get shipping methods get zone locations WC_Shipping_Zone class tbody fix missing shipping zones and regions."id: 110<tbody class="wc-shipping-zone-rows wc-shipping-tables-tbody"> <?php // Getting shipping methods for what context. Valid values, admin, json. $data_store = WC_Data_Store::load( 'shipping-zone' ); $raw_zones = $data_store->get_zones(); foreach ( $raw_zones as $zone ) { ?> <tr><td width="1%" class="wc-shipping-zone-custom"></td> <td class="wc-shipping-zone-name"> <?php echo $zone->zone_name; ?> </td> <td class="wc-shipping-zone-region"> <ul> <?php // Get the shipping Zone object $zone_locations = new WC_Shipping_Zone($zone->zone_id); $locations = $zone_locations->get_zone_locations(true, 'values'); $postcodes = array(); if( $locations ) { foreach ( $locations as $location ) { if ( 'postcode' === $location->type ) { echo '<li style="float:left">' . esc_html($location->code) . ' </li>'; } else { echo '<li style="float:left">' . esc_html($location->type) . ':' . esc_html($location->code) . ' </li>'; } } } else { echo '<li>' . esc_html_e( 'No regions set.', 'woocommerce' ) . '</li>'; } ?> </ul> </td> <td class="wc-shipping-zone-methods"> <ul> <?php // Get the shipping Zone object $shipping_zone = new WC_Shipping_Zone($zone->zone_id); $shipping_methods = $shipping_zone->get_shipping_methods( true, 'values' ); if( $shipping_methods ) { // Loop through each shipping methods set for the current shipping zone foreach ( $shipping_methods as $instance_id => $shipping_method ) { // The dump of protected data from the current shipping method echo '<li>' . $shipping_method->method_title . '<span> </span></li>'; } } else { echo '<li>' . esc_html_e( 'No shipping methods offered to this zone.', 'woocommerce' ) . '</li>'; } ?> </ul> </td> <td class="wc-shipping-zone-actions"> <a class="wc-shipping-zone-action-edit" href="admin.php?page=wc-settings&tab=shipping&zone_id=<?php echo absint($zone->zone_id); ?>"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a> <!-- | <a href="#" class="wc-shipping-zone-delete wc-shipping-zone-actions"><?php esc_html_e( 'Delete', 'woocommerce' ); ?></a>--> </td></tr> <?php } ?> </tbody>2024-01-07 17:01:30 | stat: | filed as: PHP Click to get sharing URL: share snippet 110