WooCommerce Code Reference
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • WooCommerce Docs
  • REST API Docs

Packages

  • None
  • WooCommerce
    • Abstracts
    • Admin
      • Customize
      • Functions
      • Importers
      • Meta
      • Reports
      • System
    • API
    • Classes
      • Data
        • Store
      • Emails
      • Embed
      • Integrations
      • Interfaces
      • Log
        • Handlers
      • Payment
      • Products
      • Shipping
      • Walkers
    • Export
    • Functions
    • Import
    • l10n
    • PaymentTokens
    • PayPal
    • Shortcodes
      • Cart
      • Checkout
      • My
        • Account
      • Order
        • Tracking
    • Webhooks
    • Widgets
  • WP-Background-Processing

Classes

  • Abstract_WC_Order_Data_Store_CPT
  • WC_Abstract_Order
  • WC_AJAX
  • WC_Autoloader
  • WC_Background_Emailer
  • WC_Background_Process
  • WC_Background_Updater
  • WC_Breadcrumb
  • WC_Cache_Helper
  • WC_Cart
  • WC_Cart_Fees
  • WC_Cart_Session
  • WC_Cart_Totals
  • WC_Checkout
  • WC_Coupon
  • WC_Customer
  • WC_Customer_Download
  • WC_Customer_Download_Log
  • WC_DateTime
  • WC_Discounts
  • WC_Download_Handler
  • WC_Geo_IP
  • WC_Geo_IP_Record
  • WC_Geolocation
  • WC_HTTPS
  • WC_Install
  • WC_Legacy_Cart
  • WC_Legacy_Coupon
  • WC_Legacy_Customer
  • WC_Legacy_Payment_Token
  • WC_Legacy_Shipping_Zone
  • WC_Legacy_Webhook
  • WC_Log_Levels
  • WC_Logger
  • WC_Order
  • WC_Order_Data_Store_CPT
  • WC_Order_Factory
  • WC_Order_Item
  • WC_Order_Item_Coupon
  • WC_Order_Item_Fee
  • WC_Order_Item_Meta
  • WC_Order_Item_Product
  • WC_Order_Item_Shipping
  • WC_Order_Item_Tax
  • WC_Order_Query
  • WC_Order_Refund
  • WC_Payment_Gateway_CC
  • WC_Payment_Gateway_eCheck
  • WC_Payment_Tokens
  • WC_Product_Attribute
  • WC_Product_Data_Store_CPT
  • WC_Product_Download
  • WC_Product_Factory
  • WC_Product_Query
  • WC_Product_Variable_Data_Store_CPT
  • WC_Product_Variation
  • WC_Query
  • WC_Regenerate_Images
  • WC_Regenerate_Images_Request
  • WC_Register_WP_Admin_Settings
  • WC_Session_Handler
  • WC_Shipping_Zone
  • WC_Shipping_Zones
  • WC_Shortcodes
  • WC_Structured_Data
  • WC_Tax
  • WC_Template_Loader
  • WC_Tracker
  • WC_Twenty_Eleven
  • WC_Twenty_Fifteen
  • WC_Twenty_Fourteen
  • WC_Twenty_Seventeen
  • WC_Twenty_Sixteen
  • WC_Twenty_Ten
  • WC_Twenty_Thirteen
  • WC_Twenty_Twelve
  • WC_Validation

Class WC_Shipping_Zone

Represents a single shipping zone

WC_Data
Extended by WC_Legacy_Shipping_Zone
Extended by WC_Shipping_Zone
Package: WooCommerce\Classes
Category: Class
Author: WooCommerce
Version: 3.0.0
Since: 2.6.0
Class: WC_Shipping_Zone
Located at class-wc-shipping-zone.php

Methods summary

public
# __construct( integer|object $zone = null )

Constructor for zones.

Constructor for zones.

Parameters

$zone
Zone ID to load from the DB or zone object.

Overrides

WC_Data::__construct
public string
# get_zone_name( string $context = 'view' )

Get zone name.

Get zone name.

Parameters

$context

Returns

string
public integer
# get_zone_order( string $context = 'view' )

Get zone order.

Get zone order.

Parameters

$context

Returns

integer
public array
# get_zone_locations( string $context = 'view' )

Get zone locations.

Get zone locations.

Parameters

$context

Returns

array
of zone objects
public string
# get_formatted_location( integer $max = 10, string $context = 'view' )

Return a text string representing what this zone is for.

Return a text string representing what this zone is for.

Parameters

$max
$context

Returns

string
public array
# get_shipping_methods( boolean $enabled_only = false )

Get shipping methods linked to this zone.

Get shipping methods linked to this zone.

Parameters

$enabled_only
return enabled methods.

Returns

array
of objects
public
# set_zone_name( string $set )

Set zone name.

Set zone name.

Parameters

$set
public
# set_zone_order( integer $set )

Set zone order.

Set zone order.

Parameters

$set
public
# set_zone_locations( array $locations )

Set zone locations.

Set zone locations.

Parameters

$locations

Since

3.0.0
public integer
# save( )

Save zone data to the database.

Save zone data to the database.

Returns

integer

Overrides

WC_Data::save
protected string
# generate_zone_name( )

Generate a zone name based on location.

Generate a zone name based on location.

Returns

string
public boolean
# is_valid_location_type( string $type )

Is passed location type valid?

Is passed location type valid?

Parameters

$type

Returns

boolean
public
# add_location( string $code, string $type )

Add location (state or postcode) to a zone.

Add location (state or postcode) to a zone.

Parameters

$code
$type
state or postcode
public
# clear_locations( array|string $types = array( 'postcode', 'state', 'country', 'continent' ) )

Clear all locations for this zone.

Clear all locations for this zone.

Parameters

$types
of location to clear
public
# set_locations( array $locations = array() )

Set locations.

Set locations.

Parameters

$locations
Array of locations
public integer
# add_shipping_method( string $type )

Add a shipping method to this zone.

Add a shipping method to this zone.

Parameters

$type
shipping method type

Returns

integer
new instance_id, 0 on failure
public True
# delete_shipping_method( integer $instance_id )

Delete a shipping method from a zone.

Delete a shipping method from a zone.

Parameters

$instance_id

Returns

True
on success, false on failure

Methods inherited from WC_Legacy_Shipping_Zone

create(), get_zone_id(), read(), update()

Methods inherited from WC_Data

__clone(), __sleep(), __toString(), __wakeup(), add_meta_data(), apply_changes(), delete(), delete_meta_data(), delete_meta_data_by_mid(), error(), filter_null_meta(), get_changes(), get_data(), get_data_keys(), get_data_store(), get_extra_data_keys(), get_hook_prefix(), get_id(), get_meta(), get_meta_data(), get_object_read(), get_prop(), is_internal_meta_key(), maybe_read_meta_data(), meta_exists(), read_meta_data(), save_meta_data(), set_date_prop(), set_defaults(), set_id(), set_meta_data(), set_object_read(), set_prop(), set_props(), update_meta_data()

Properties summary

protected integer|null $id

Zone ID

Zone ID

# null
protected string $object_type

This is the name of this object type.

This is the name of this object type.

# 'shipping_zone'
protected array $data

Zone Data

Zone Data

# array( 'zone_name' => '', 'zone_order' => 0, 'zone_locations' => array(), )

Properties inherited from WC_Data

$cache_group, $changes, $data_store, $default_data, $extra_data, $meta_data, $object_read

WooCommerce Code Reference API documentation generated by ApiGen