Skip to content

Commit 889d414

Browse files
committed
Assume packaging weight unit as default unit when displaying reports.
1 parent cee706e commit 889d414

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Packaging/Report.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,18 @@ public function get_packaging_count( $packaging_id, $country = '' ) {
259259
}
260260

261261
public function get_packaging_weight( $packaging_id, $country = '', $round = true, $unit = '' ) {
262+
if ( '' === $unit ) {
263+
$unit = wc_gzd_get_packaging_weight_unit();
264+
}
265+
262266
$weight = 0.0;
263267

264268
if ( '' === $country ) {
265269
if ( isset( $this->args['packaging'][ "$packaging_id" ] ) ) {
266270
$weight = $this->args['packaging'][ "$packaging_id" ]['weight_in_kg'];
267271
}
268272
} elseif ( isset( $this->args['countries'][ $country ], $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ] ) ) {
269-
$weight = $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ]['weight_in_kg'];
273+
$weight = $this->args['countries'][ $country ]['packaging'][ "$packaging_id" ]['weight_in_kg'];
270274
}
271275

272276
$weight = wc_get_weight( $weight, $unit, 'kg' );
@@ -275,6 +279,10 @@ public function get_packaging_weight( $packaging_id, $country = '', $round = tru
275279
}
276280

277281
public function get_total_packaging_weight_by_country( $country, $round = true, $unit = '' ) {
282+
if ( '' === $unit ) {
283+
$unit = wc_gzd_get_packaging_weight_unit();
284+
}
285+
278286
$weight = 0.0;
279287

280288
if ( isset( $this->args['countries'][ $country ] ) ) {

0 commit comments

Comments
 (0)