WC_Shipping_Zone_Data_Store::get_zone_locations_for_idsprivateWC 1.0

Retrieve the zone location 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_id, location_code, and location_type for each zone location.

Usage

// private - for code of main (parent) class only
$result = $this->get_zone_locations_for_ids( $ids );
$ids(array) (required)
The zone_ids to retrieve.

WC_Shipping_Zone_Data_Store::get_zone_locations_for_ids() code WC 10.3.3

private function get_zone_locations_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, location_code, location_type FROM {$wpdb->prefix}woocommerce_shipping_zone_locations " .
		'WHERE zone_id IN ( ' . implode( ',', $zone_ids ) . ' ) '
	);
	// phpcs:enable WordPress.DB.PreparedSQL.NotPrepared
}