From 889d41459efc734b3bb2b7c3fa1b15ceb3a1d686 Mon Sep 17 00:00:00 2001 From: vendidero Date: Thu, 2 Jan 2025 16:50:43 +0100 Subject: [PATCH] Assume packaging weight unit as default unit when displaying reports. --- src/Packaging/Report.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Packaging/Report.php b/src/Packaging/Report.php index d2f8a785..5c96c9fc 100644 --- a/src/Packaging/Report.php +++ b/src/Packaging/Report.php @@ -259,6 +259,10 @@ public function get_packaging_count( $packaging_id, $country = '' ) { } public function get_packaging_weight( $packaging_id, $country = '', $round = true, $unit = '' ) { + if ( '' === $unit ) { + $unit = wc_gzd_get_packaging_weight_unit(); + } + $weight = 0.0; if ( '' === $country ) { @@ -266,7 +270,7 @@ public function get_packaging_weight( $packaging_id, $country = '', $round = tru $weight = $this->args['packaging'][ "$packaging_id" ]['weight_in_kg']; } } elseif ( isset( $this->args['countries'][ $country ], $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ] ) ) { - $weight = $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ]['weight_in_kg']; + $weight = $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ]['weight_in_kg']; } $weight = wc_get_weight( $weight, $unit, 'kg' ); @@ -275,6 +279,10 @@ public function get_packaging_weight( $packaging_id, $country = '', $round = tru } public function get_total_packaging_weight_by_country( $country, $round = true, $unit = '' ) { + if ( '' === $unit ) { + $unit = wc_gzd_get_packaging_weight_unit(); + } + $weight = 0.0; if ( isset( $this->args['countries'][ $country ] ) ) {