From f3b0bfe703a8dfa0746bfd6875ae8ea8a81443ec Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Sun, 28 Jan 2018 21:48:41 +0100
Subject: [PATCH] Fix warning message when product variation has no weight

---
 includes/rules_shipping_framework_woocommerce.php | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/includes/rules_shipping_framework_woocommerce.php b/includes/rules_shipping_framework_woocommerce.php
index fc01c1a..f0c75f2 100644
--- a/includes/rules_shipping_framework_woocommerce.php
+++ b/includes/rules_shipping_framework_woocommerce.php
@@ -185,9 +185,11 @@ class RulesShippingFrameworkWooCommerce extends RulesShippingFramework {
 		);
 		foreach ($products as $product) {
 			$w = $product['data']->get_weight();
-			$dimensions['maxweight'] = max ($dimensions['maxweight'], $w);
-			$dimensions['minweight'] = min ($dimensions['minweight'], $w);
-			$dimensions['weight'] += $w * $product['quantity'];
+			if (is_numeric($w)) {
+				$dimensions['maxweight'] = max ($dimensions['maxweight'], $w);
+				$dimensions['minweight'] = min ($dimensions['minweight'], $w);
+				$dimensions['weight'] += $w * $product['quantity'];
+			}
 		}
 		return $dimensions;
 	}
-- 
GitLab