PHP Class WC_Shipping

Handles shipping and loads shipping methods via hooks.
Author: WooThemes
Afficher le fichier Open project: woocommerce/woocommerce Class Usage Examples

Méthodes publiques

Свойство Type Description
$enabled True if shipping is enabled.
$packages Stores packages to ship and to get quotes for.
$shipping_classes Stores the shipping classes.
$shipping_methods Stores methods loaded into woocommerce.
$shipping_taxes Stores an array of shipping taxes.
$shipping_total Stores the cost of shipping

Protected Properties

Свойство Type Description
$_instance The single instance of the class

Méthodes publiques

Méthode Description
__clone ( ) Cloning is forbidden.
__construct ( ) Initialize shipping.
__wakeup ( ) Unserializing instances of this class is forbidden.
calculate_shipping ( array $packages = [] ) Calculate shipping for (multiple) packages of cart items.
calculate_shipping_for_package ( array $package = [], integer $package_key ) : array 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 ( ) : array Returns all registered shipping methods for usage.
init ( ) Initialize shipping.
instance ( ) : WC_Shipping Main WC_Shipping Instance.
load_shipping_methods ( array $package = [] ) : array Loads all shipping methods which are hooked in. If a $package is passed some methods may add themselves conditionally.
register_shipping_method ( object | string $method ) Register a shipping method.
reset_shipping ( ) Reset shipping.
sort_shipping_methods ( )
unregister_shipping_methods ( ) Unregister shipping methods.

Méthodes protégées

Méthode Description
is_package_shippable ( array $package ) : boolean See if package is shippable.

Private Methods

Méthode Description
get_default_method ( array $available_methods, boolean $current_chosen_method = false ) : string Get the default method.

Method Details

__clone() public méthode

Cloning is forbidden.
Since: 2.1
public __clone ( )

__construct() public méthode

Initialize shipping.
public __construct ( )

__wakeup() public méthode

Unserializing instances of this class is forbidden.
Since: 2.1
public __wakeup ( )

calculate_shipping() public méthode

Calculate shipping for (multiple) packages of cart items.
public calculate_shipping ( array $packages = [] )
$packages array multi-dimensional array of cart items to calc shipping for

calculate_shipping_for_package() public méthode

Calculates each shipping methods cost. Rates are stored in the session based on the package hash to avoid re-calculation every page load.
public calculate_shipping_for_package ( array $package = [], integer $package_key ) : array
$package array cart items
$package_key integer Index of the package being calculated. Used to cache multiple package rates.
Résultat array

get_packages() public méthode

Get packages.
public get_packages ( ) : array
Résultat array

get_shipping_classes() public méthode

Get an array of shipping classes.
public get_shipping_classes ( ) : array
Résultat array

get_shipping_method_class_names() public méthode

Shipping methods register themselves by returning their main class name through the woocommerce_shipping_methods filter.

get_shipping_methods() public méthode

Returns all registered shipping methods for usage.
public get_shipping_methods ( ) : array
Résultat array

init() public méthode

Initialize shipping.
public init ( )

instance() public static méthode

Ensures only one instance of WC_Shipping is loaded or can be loaded.
Since: 2.1
public static instance ( ) : WC_Shipping
Résultat WC_Shipping Main instance

is_package_shippable() protected méthode

See if package is shippable.
protected is_package_shippable ( array $package ) : boolean
$package array
Résultat boolean

load_shipping_methods() public méthode

Loads all shipping methods which are hooked in. If a $package is passed some methods may add themselves conditionally and zones will be used.
public load_shipping_methods ( array $package = [] ) : array
$package array
Résultat array

register_shipping_method() public méthode

Register a shipping method.
public register_shipping_method ( object | string $method )
$method object | string Either the name of the method's class, or an instance of the method's class.

reset_shipping() public méthode

Reset the totals for shipping as a whole.
public reset_shipping ( )

sort_shipping_methods() public méthode

Deprecation: 2.6.0 Was previously used to determine sort order of methods, but this is now controlled by zones and thus unused.

unregister_shipping_methods() public méthode

Unregister shipping methods.

Property Details

$_instance protected_oe static_oe property

The single instance of the class
Since: 2.1
protected static $_instance

$enabled public_oe property

True if shipping is enabled.
public $enabled

$packages public_oe property

Stores packages to ship and to get quotes for.
public $packages

$shipping_classes public_oe property

Stores the shipping classes.
public $shipping_classes

$shipping_methods public_oe property

Stores methods loaded into woocommerce.
public $shipping_methods

$shipping_taxes public_oe property

Stores an array of shipping taxes.
public $shipping_taxes

$shipping_total public_oe property

Stores the cost of shipping
public $shipping_total