Check if product has weight before calculate weigth total in cart

Closes #19347
This commit is contained in:
Claudio Sanches 2018-03-12 12:54:00 -03:00
parent 7aef2349bf
commit 768a21e788
1 changed files with 3 additions and 1 deletions

View File

@ -673,7 +673,9 @@ class WC_Cart extends WC_Legacy_Cart {
$weight = 0;
foreach ( $this->get_cart() as $cart_item_key => $values ) {
$weight += (float) $values['data']->get_weight() * $values['quantity'];
if ( $values['data']->has_weight() ) {
$weight += (float) $values['data']->get_weight() * $values['quantity'];
}
}
return apply_filters( 'woocommerce_cart_contents_weight', $weight );