WC_Cart::get_cart_contents_weight
Get weight of items in the cart.
Метод класса: WC_Cart{}
Хуки из метода
Возвращает
float.
Использование
$WC_Cart = new WC_Cart(); $WC_Cart->get_cart_contents_weight();
Список изменений
| С версии 2.5.0 | Введена. |
Код WC_Cart::get_cart_contents_weight() WC Cart::get cart contents weight WC 10.3.5
public function get_cart_contents_weight() {
$weight = 0.0;
foreach ( $this->get_cart() as $values ) {
if ( $values['data']->has_weight() ) {
$weight += (float) $values['data']->get_weight() * $values['quantity'];
}
}
return apply_filters( 'woocommerce_cart_contents_weight', $weight );
}