diff --git a/src/DataStores/Shipment.php b/src/DataStores/Shipment.php index 9618689..482e4de 100644 --- a/src/DataStores/Shipment.php +++ b/src/DataStores/Shipment.php @@ -39,6 +39,7 @@ class Shipment extends WC_Data_Store_WP implements WC_Object_Data_Store_Interfac '_height', '_weight', '_packaging_weight', + '_packaging_title', '_address', '_total', '_subtotal', diff --git a/src/Shipment.php b/src/Shipment.php index 714792e..b7ca8ed 100644 --- a/src/Shipment.php +++ b/src/Shipment.php @@ -147,6 +147,7 @@ abstract class Shipment extends WC_Data { 'height' => '', 'length' => '', 'packaging_weight' => '', + 'packaging_title' => '', 'weight_unit' => '', 'dimension_unit' => '', 'country' => '', @@ -486,6 +487,18 @@ public function get_packaging_weight( $context = 'view' ) { return $weight; } + public function get_packaging_title( $context = 'view' ) { + $title = $this->get_prop( 'packaging_title', $context ); + + if ( 'view' === $context && '' === $title ) { + if ( $packaging = $this->get_packaging() ) { + $title = $packaging->get_title(); + } + } + + return $title; + } + /** * @return ShipmentItem[]|ItemList */ @@ -1863,6 +1876,10 @@ public function set_packaging_weight( $weight ) { $this->set_prop( 'packaging_weight', '' === $weight ? '' : wc_format_decimal( $weight ) ); } + public function set_packaging_title( $title ) { + $this->set_prop( 'packaging_title', $title ); + } + /** * Set shipment total weight. * @@ -2092,11 +2109,15 @@ public function update_packaging() { 'length' => wc_get_dimension( $packaging->get_length( 'edit' ), $this->get_dimension_unit(), $packaging_dimension ), 'height' => wc_get_dimension( $packaging->get_height( 'edit' ), $this->get_dimension_unit(), $packaging_dimension ), 'packaging_weight' => wc_get_weight( $packaging->get_weight( 'edit' ), $this->get_weight_unit(), wc_gzd_get_packaging_weight_unit() ), + 'packaging_title' => $packaging->get_title(), ); $this->set_props( $props ); } else { - $props = array( 'packaging_weight' => '' ); + $props = array( + 'packaging_weight' => '', + 'packaging_title' => '', + ); $changes = $this->get_changes(); /**