Skip to content

Commit

Permalink
Prevent issues with type conversion in case of empty dimension fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Apr 22, 2024
1 parent b77c231 commit f716026
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/PickupDelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/ShipmentItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() : '',
Expand Down

0 comments on commit f716026

Please sign in to comment.