WC_Shipping
in package
Shipping class.
Table of Contents
- $enabled : bool
- True if shipping is enabled.
- $packages : array
- Stores packages to ship and to get quotes for.
- $shipping_classes : array
- Stores the shipping classes.
- $shipping_methods : array|null
- Stores methods loaded into woocommerce.
- $_instance : WC_Shipping
- The single instance of the class
- __clone() : mixed
- Cloning is forbidden.
- __construct() : mixed
- Initialize shipping.
- __get() : mixed
- Magic getter.
- __wakeup() : mixed
- Unserializing instances of this class is forbidden.
- calculate_shipping() : array
- Calculate shipping for (multiple) packages of cart items.
- calculate_shipping_for_package() : array|bool
- Calculate shipping rates for a package,
- get_packages() : array
- Get packages.
- get_shipping_classes() : array
- Get an array of shipping classes.
- get_shipping_method_class_names() : array
- Shipping methods register themselves by returning their main class name through the woocommerce_shipping_methods filter.
- get_shipping_methods() : \WC_Shipping_Method[]
- Returns all registered shipping methods for usage.
- init() : mixed
- Initialize shipping.
- instance() : WC_Shipping
- Main WC_Shipping Instance.
- is_package_shippable() : bool
- See if package is shippable.
- load_shipping_methods() : \WC_Shipping_Method[]
- Loads all shipping methods which are hooked in.
- register_shipping_method() : bool|void
- Register a shipping method.
- reset_shipping() : mixed
- Reset shipping.
- sort_shipping_methods() : mixed
- Deprecated
- unregister_shipping_methods() : mixed
- Unregister shipping methods.
Properties
$enabled
True if shipping is enabled.
public
bool
$enabled
= alse
$packages
Stores packages to ship and to get quotes for.
public
array
$packages
= array()
$shipping_classes
Stores the shipping classes.
public
array
$shipping_classes
= array()
$shipping_methods
Stores methods loaded into woocommerce.
public
array|null
$shipping_methods
=
ull
$_instance
The single instance of the class
protected
static WC_Shipping
$_instance
=
ull
Tags
Methods
__clone()
Cloning is forbidden.
public
__clone() : mixed
Tags
Return values
mixed__construct()
Initialize shipping.
public
__construct() : mixed
Return values
mixed__get()
Magic getter.
public
__get(string $name) : mixed
Parameters
- $name : string
-
Property name.
Return values
mixed__wakeup()
Unserializing instances of this class is forbidden.
public
__wakeup() : mixed
Tags
Return values
mixedcalculate_shipping()
Calculate shipping for (multiple) packages of cart items.
public
calculate_shipping([array $packages = array() ]) : array
Parameters
- $packages : array = array()
-
multi-dimensional array of cart items to calc shipping for.
Return values
array — Array of calculated packages.calculate_shipping_for_package()
Calculate shipping rates for a package,
public
calculate_shipping_for_package([array $package = array() ], int $package_key) : array|bool
Calculates each shipping methods cost. Rates are stored in the session based on the package hash to avoid re-calculation every page load.
Parameters
- $package : array = array()
-
Package of cart items.
- $package_key : int
-
Index of the package being calculated. Used to cache multiple package rates.
Return values
array|boolget_packages()
Get packages.
public
get_packages() : array
Return values
arrayget_shipping_classes()
Get an array of shipping classes.
public
get_shipping_classes() : array
Return values
arrayget_shipping_method_class_names()
Shipping methods register themselves by returning their main class name through the woocommerce_shipping_methods filter.
public
get_shipping_method_class_names() : array
Return values
arrayget_shipping_methods()
Returns all registered shipping methods for usage.
public
get_shipping_methods() : \WC_Shipping_Method[]
Return values
\WC_Shipping_Method[]init()
Initialize shipping.
public
init() : mixed
Return values
mixedinstance()
Main WC_Shipping Instance.
public
static instance() : WC_Shipping
Ensures only one instance of WC_Shipping is loaded or can be loaded.
Tags
Return values
WC_Shipping — Main instanceis_package_shippable()
See if package is shippable.
public
is_package_shippable(array $package) : bool
Packages are shippable until proven otherwise e.g. after getting a shipping country.
Parameters
- $package : array
-
Package of cart items.
Return values
boolload_shipping_methods()
Loads all shipping methods which are hooked in.
public
load_shipping_methods([array $package = array() ]) : \WC_Shipping_Method[]
If a $package is passed, some methods may add themselves conditionally and zones will be used.
Parameters
- $package : array = array()
-
Package information.
Return values
\WC_Shipping_Method[]register_shipping_method()
Register a shipping method.
public
register_shipping_method(object|string $method) : bool|void
Parameters
- $method : object|string
-
Either the name of the method's class, or an instance of the method's class.
Return values
bool|voidreset_shipping()
Reset shipping.
public
reset_shipping() : mixed
Reset the totals for shipping as a whole.
Return values
mixedsort_shipping_methods()
Deprecated
public
sort_shipping_methods() : mixed
Tags
Return values
mixedunregister_shipping_methods()
Unregister shipping methods.
public
unregister_shipping_methods() : mixed