WC_Shipping_Zone_Data_Store::get_zone_data_for_ids
Retrieve the zone data for the given zone_ids.
Method of the class: WC_Shipping_Zone_Data_Store{}
No Hooks.
Returns
stdClass[]. An array of objects containing the zone data, keyed by the zone_id.
Usage
// private - for code of main (parent) class only $result = $this->get_zone_data_for_ids( $ids );
- $ids(array) (required)
- The zone_ids to retrieve.
WC_Shipping_Zone_Data_Store::get_zone_data_for_ids() WC Shipping Zone Data Store::get zone data for ids code WC 10.3.3
private function get_zone_data_for_ids( array $ids ) {
global $wpdb;
if ( empty( $ids ) || array( '0' ) === $ids || array( 0 ) === $ids ) {
return array();
}
$zone_ids = array_map( 'absint', $ids );
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared -- $zone_ids already run through absint.
return $wpdb->get_results(
"SELECT zone_id, zone_name, zone_order FROM {$wpdb->prefix}woocommerce_shipping_zones " .
'WHERE zone_id IN ( ' . implode( ',', $zone_ids ) . ' ) ',
OBJECT_K
);
// phpcs:enable WordPress.DB.PreparedSQL.NotPrepared
}