From f71602617678c771ee814d9263d4fd0394bf8c7b Mon Sep 17 00:00:00 2001 From: vendidero Date: Mon, 22 Apr 2024 10:53:10 +0200 Subject: [PATCH] Prevent issues with type conversion in case of empty dimension fields. --- src/PickupDelivery.php | 12 ++++++------ src/ShipmentItem.php | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/PickupDelivery.php b/src/PickupDelivery.php index f46bdac3..7103e315 100644 --- a/src/PickupDelivery.php +++ b/src/PickupDelivery.php @@ -375,18 +375,18 @@ public static function get_pickup_delivery_cart_args() { foreach ( wc()->cart->get_cart() as $values ) { if ( $product = wc_gzd_shipments_get_product( $values['data'] ) ) { if ( $product->has_dimensions() ) { - $length = (float) wc_get_dimension( $product->get_shipping_length(), wc_gzd_get_packaging_dimension_unit() ); - $width = (float) wc_get_dimension( $product->get_shipping_width(), wc_gzd_get_packaging_dimension_unit() ); - $height = (float) wc_get_dimension( $product->get_shipping_height(), wc_gzd_get_packaging_dimension_unit() ); + $length = (float) wc_get_dimension( (float) $product->get_shipping_length(), wc_gzd_get_packaging_dimension_unit() ); + $width = (float) wc_get_dimension( (float) $product->get_shipping_width(), wc_gzd_get_packaging_dimension_unit() ); + $height = (float) wc_get_dimension( (float) $product->get_shipping_height(), wc_gzd_get_packaging_dimension_unit() ); if ( $length > $max_dimensions['length'] ) { - $max_dimensions['length'] = (float) $length; + $max_dimensions['length'] = $length; } if ( $width > $max_dimensions['width'] ) { - $max_dimensions['width'] = (float) $width; + $max_dimensions['width'] = $width; } if ( $height > $max_dimensions['height'] ) { - $max_dimensions['height'] = (float) $height; + $max_dimensions['height'] = $height; } } } diff --git a/src/ShipmentItem.php b/src/ShipmentItem.php index 6ab62282..6b1cc964 100644 --- a/src/ShipmentItem.php +++ b/src/ShipmentItem.php @@ -406,9 +406,9 @@ public function sync( $args = array() ) { 'total' => $total + $tax_total, 'subtotal' => $subtotal + $tax_subtotal, 'weight' => $product ? wc_get_weight( $product->get_weight(), $shipment->get_weight_unit() ) : '', - 'length' => $s_product ? wc_get_dimension( $s_product->get_shipping_length(), $shipment->get_dimension_unit() ) : '', - 'width' => $s_product ? wc_get_dimension( $s_product->get_shipping_width(), $shipment->get_dimension_unit() ) : '', - 'height' => $s_product ? wc_get_dimension( $s_product->get_shipping_height(), $shipment->get_dimension_unit() ) : '', + 'length' => $s_product ? wc_get_dimension( (float) $s_product->get_shipping_length(), $shipment->get_dimension_unit() ) : '', + 'width' => $s_product ? wc_get_dimension( (float) $s_product->get_shipping_width(), $shipment->get_dimension_unit() ) : '', + 'height' => $s_product ? wc_get_dimension( (float) $s_product->get_shipping_height(), $shipment->get_dimension_unit() ) : '', 'hs_code' => $s_product ? $s_product->get_hs_code() : '', 'customs_description' => $s_product ? $s_product->get_customs_description() : '', 'manufacture_country' => $s_product ? $s_product->get_manufacture_country() : '',