Merge pull request #18049 from woocommerce/fix/undefined-var

Fixed undefined variable on WC_Shipping_Zones::get_zone_by
This commit is contained in:
Mike Jolley 2017-12-07 14:32:21 +00:00 committed by GitHub
commit 86ff5f5842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 24 deletions

View File

@ -1,25 +1,27 @@
<?php
/**
* Handles storage and retrieval of shipping zones
*
* @package WooCommerce/Classes
* @author Automattic
* @version 3.3.0
* @since 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Handles storage and retrieval of shipping zones
*
* @class WC_Shipping_Zones
* @since 2.6.0
* @version 3.0.0
* @package WooCommerce/Classes
* @category Class
* @author WooCommerce
* Shipping zones class.
*/
class WC_Shipping_Zones {
/**
* Get shipping zones from the database
* Get shipping zones from the database.
*
* @since 2.6.0
* @return array of arrays
* @return array Array of arrays.
*/
public static function get_zones() {
$data_store = WC_Data_Store::load( 'shipping-zone' );
@ -27,7 +29,7 @@ class WC_Shipping_Zones {
$zones = array();
foreach ( $raw_zones as $raw_zone ) {
$zone = new WC_Shipping_Zone( $raw_zone );
$zone = new WC_Shipping_Zone( $raw_zone );
$zones[ $zone->get_id() ] = $zone->get_data();
$zones[ $zone->get_id() ]['zone_id'] = $zone->get_id();
$zones[ $zone->get_id() ]['formatted_zone_location'] = $zone->get_formatted_location();
@ -39,8 +41,9 @@ class WC_Shipping_Zones {
/**
* Get shipping zone using it's ID
*
* @since 2.6.0
* @param int $zone_id
* @param int $zone_id Zone ID.
* @return WC_Shipping_Zone|bool
*/
public static function get_zone( $zone_id ) {
@ -49,20 +52,23 @@ class WC_Shipping_Zones {
/**
* Get shipping zone by an ID.
*
* @since 2.6.0
* @param string $by zone_id or instance_id
* @param int $id
* @param string $by Get by 'zone_id' or 'instance_id'.
* @param int $id ID.
* @return WC_Shipping_Zone|bool
*/
public static function get_zone_by( $by = 'zone_id', $id = 0 ) {
$zone_id = false;
switch ( $by ) {
case 'zone_id' :
case 'zone_id':
$zone_id = $id;
break;
case 'instance_id' :
break;
case 'instance_id':
$data_store = WC_Data_Store::load( 'shipping-zone' );
$zone_id = $data_store->get_zone_id_by_instance_id( $id );
break;
break;
}
if ( false !== $zone_id ) {
@ -77,11 +83,10 @@ class WC_Shipping_Zones {
}
/**
* Get shipping zone using it's ID
* Get shipping zone using it's ID.
*
* @since 2.6.0
*
* @param $instance_id
*
* @param int $instance_id Instance ID.
* @return bool|WC_Shipping_Method
*/
public static function get_shipping_method( $instance_id ) {
@ -102,7 +107,8 @@ class WC_Shipping_Zones {
/**
* Delete a zone using it's ID
* @param int $zone_id
*
* @param int $zone_id Zone ID.
* @since 2.6.0
*/
public static function delete_zone( $zone_id ) {
@ -112,9 +118,10 @@ class WC_Shipping_Zones {
/**
* Find a matching zone for a given package.
*
* @since 2.6.0
* @uses wc_make_numeric_postcode()
* @param object $package
* @param array $package Shipping package.
* @return WC_Shipping_Zone
*/
public static function get_zone_matching_package( $package ) {