Skip to content

Commit

Permalink
Assume packaging weight unit as default unit when displaying reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Jan 2, 2025
1 parent cee706e commit 889d414
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Packaging/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,18 @@ 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 ) {
if ( isset( $this->args['packaging'][ "$packaging_id" ] ) ) {
$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' );
Expand All @@ -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 ] ) ) {
Expand Down

0 comments on commit 889d414

Please sign in to comment.