WC_Shipping
in package
Shipping class.
Table of Contents
- $enabled : bool
- True if shipping is enabled.
- $packages : array<string|int, mixed>
- Stores packages to ship and to get quotes for.
- $shipping_classes : array<string|int, mixed>
- Stores the shipping classes.
- $shipping_methods : array<string|int, mixed>|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<string|int, mixed>
- Calculate shipping for (multiple) packages of cart items.
- calculate_shipping_for_package() : array<string|int, mixed>|bool
- Calculate shipping rates for a package,
- get_packages() : array<string|int, mixed>
- Get packages.
- get_shipping_classes() : array<string|int, mixed>
- Get an array of shipping classes.
- get_shipping_method_class_names() : array<string|int, mixed>
- Shipping methods register themselves by returning their main class name through the woocommerce_shipping_methods filter.
- get_shipping_methods() : array<string|int, 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() : array<string|int, 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<string|int, mixed>
$packages
= array()
$shipping_classes
Stores the shipping classes.
public
array<string|int, mixed>
$shipping_classes
= array()
$shipping_methods
Stores methods loaded into woocommerce.
public
array<string|int, mixed>|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
mixed —calculate_shipping()
Calculate shipping for (multiple) packages of cart items.
public
calculate_shipping([array<string|int, mixed> $packages = array() ]) : array<string|int, mixed>
Parameters
- $packages : array<string|int, mixed> = array()
-
multi-dimensional array of cart items to calc shipping for.
Return values
array<string|int, mixed> — Array of calculated packages.calculate_shipping_for_package()
Calculate shipping rates for a package,
public
calculate_shipping_for_package([array<string|int, mixed> $package = array() ], int $package_key) : array<string|int, mixed>|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<string|int, mixed> = array()
-
Package of cart items.
- $package_key : int
-
Index of the package being calculated. Used to cache multiple package rates.
Return values
array<string|int, mixed>|bool —get_packages()
Get packages.
public
get_packages() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_shipping_classes()
Get an array of shipping classes.
public
get_shipping_classes() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_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<string|int, mixed>
Return values
array<string|int, mixed> —get_shipping_methods()
Returns all registered shipping methods for usage.
public
get_shipping_methods() : array<string|int, WC_Shipping_Method>
Return values
array<string|int, WC_Shipping_Method> —init()
Initialize shipping.
public
init() : mixed
Return values
mixed —instance()
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<string|int, mixed> $package) : bool
Packages are shippable until proven otherwise e.g. after getting a shipping country.
Parameters
- $package : array<string|int, mixed>
-
Package of cart items.
Return values
bool —load_shipping_methods()
Loads all shipping methods which are hooked in.
public
load_shipping_methods([array<string|int, mixed> $package = array() ]) : array<string|int, WC_Shipping_Method>
If a $package is passed, some methods may add themselves conditionally and zones will be used.
Parameters
- $package : array<string|int, mixed> = array()
-
Package information.
Return values
array<string|int, 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|void —reset_shipping()
Reset shipping.
public
reset_shipping() : mixed
Reset the totals for shipping as a whole.
Return values
mixed —sort_shipping_methods()
Deprecated
public
sort_shipping_methods() : mixed
Tags
Return values
mixed —unregister_shipping_methods()
Unregister shipping methods.
public
unregister_shipping_methods() : mixed