• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WooCommerce a2z

WooCommerce a2z

WooCommerce

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / WC_Shipping_Zones::get_zone_by() – Get shipping zone by an ID.

You appear to be a bot. Output may be restricted

Description

Get shipping zone by an ID.

Usage

$WC_Shipping_Zone|bool = WC_Shipping_Zones::get_zone_by( $by, $id );

Parameters

$by
( string ) optional default: zone_id – Get by 'zone_id' or 'instance_id'.
$id
( int ) optional – ID.

Returns

WC_Shipping_Zone|bool

Source

File name: woocommerce/includes/class-wc-shipping-zones.php
Lines:

1 to 23 of 23
  public static function get_zone_by( $by = 'zone_id', $id = 0 ) {
    $zone_id = false;

    switch ( $by ) {
      case 'zone_id':
        $zone_id = $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;
    }

    if ( false !== $zone_id ) {
      try {
        return new WC_Shipping_Zone( $zone_id );
      } catch ( Exception $e ) {
        return false;
      }
    }

    return false;
  }
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 6th April 2020

Primary Sidebar

Information

Function name: WC_Shipping_Zones::get_zone_by
Class ref: WC_Shipping_Zones
Plugin ref: WooCommerce
Version: 4.8.0
Sourcefile: includes/class-wc-shipping-zones.php
File ref: includes/class-wc-shipping-zones.php
Deprecated?: No
API Letters: G,S,W,Z

Footer

WooCommerce a2z
WooCommerce a2z
WooCommerce
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  woocommerce.wp-a2z.org
© Copyright WooCommerce a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites