Automattic\WooCommerce\Internal\Shipping\FlatRate
WeightPlaceholder::get_for_package
Get the total weight of the shippable items in a package, in the store's weight unit.
Method of the class: WeightPlaceholder{}
No Hooks.
Returns
float.
Usage
$WeightPlaceholder = new WeightPlaceholder(); $WeightPlaceholder->get_for_package( $package ): float;
- $package(array) (required)
- Package of items from the cart.
Changelog
| Since 11.3.0 | Introduced. |
WeightPlaceholder::get_for_package() WeightPlaceholder::get for package code WC 11.3.0
public function get_for_package( array $package ): float {
$items = $package['contents'] ?? array();
return is_array( $items ) ? $this->get_for_items( $items ) : 0.0;
}