From 2deb2ba6072c4f773f1d8d4df313688dc3556c71 Mon Sep 17 00:00:00 2001 From: vendidero Date: Wed, 22 May 2024 15:38:49 +0200 Subject: [PATCH] Use a more general export reference number approach instead of the (EU-specific) master reference number. --- src/DataStores/Label.php | 2 +- src/Interfaces/ShipmentLabel.php | 2 +- src/Labels/Label.php | 12 ++++++------ src/Package.php | 4 ++-- src/ShippingProvider/Auto.php | 12 ++++++++---- src/ShippingProvider/Service.php | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/DataStores/Label.php b/src/DataStores/Label.php index 6d2b5e8e..05fa55a8 100644 --- a/src/DataStores/Label.php +++ b/src/DataStores/Label.php @@ -52,7 +52,7 @@ class Label extends WC_Data_Store_WP implements WC_Object_Data_Store_Interface { '_height', '_created_via', '_print_format', - '_master_reference_number', + '_export_reference_number', ); /* diff --git a/src/Interfaces/ShipmentLabel.php b/src/Interfaces/ShipmentLabel.php index cc2b347d..4e41306f 100644 --- a/src/Interfaces/ShipmentLabel.php +++ b/src/Interfaces/ShipmentLabel.php @@ -58,7 +58,7 @@ public function get_services(); public function get_print_format(); - public function get_master_reference_number(); + public function get_export_reference_number(); /** * Returns the label shipment type, e.g. simple or return. diff --git a/src/Labels/Label.php b/src/Labels/Label.php index 4529fe27..95f1cac1 100644 --- a/src/Labels/Label.php +++ b/src/Labels/Label.php @@ -68,7 +68,7 @@ class Label extends WC_Data implements ShipmentLabel { 'created_via' => '', 'services' => array(), 'print_format' => '', - 'master_reference_number' => '', + 'export_reference_number' => '', ); public function __construct( $data = 0 ) { @@ -196,8 +196,8 @@ public function get_print_format( $context = 'view' ) { return $this->get_prop( 'print_format', $context ); } - public function get_master_reference_number( $context = 'view' ) { - return $this->get_prop( 'master_reference_number', $context ); + public function get_export_reference_number( $context = 'view' ) { + return $this->get_prop( 'export_reference_number', $context ); } public function has_number() { @@ -344,8 +344,8 @@ public function set_print_format( $format ) { $this->set_prop( 'print_format', $format ); } - public function set_master_reference_number( $ref_number ) { - $this->set_prop( 'master_reference_number', $ref_number ); + public function set_export_reference_number( $ref_number ) { + $this->set_prop( 'export_reference_number', $ref_number ); } public function set_shipping_provider( $slug ) { @@ -858,7 +858,7 @@ public function get_customs_data( $max_desc_length = 255 ) { 'shipment_id' => $shipment->get_id(), 'additional_fee' => wc_format_decimal( $shipment->get_additional_total(), 2 ), 'place_of_commital' => $shipment->get_sender_city(), - 'master_reference_number' => $this->get_master_reference_number(), + 'export_reference_number' => $this->get_export_reference_number(), // e.g. EORI number 'sender_customs_ref_number' => $shipment->get_sender_customs_reference_number(), 'receiver_customs_ref_number' => $shipment->get_customs_reference_number(), diff --git a/src/Package.php b/src/Package.php index 3b464508..a950a01d 100644 --- a/src/Package.php +++ b/src/Package.php @@ -336,10 +336,10 @@ public static function country_belongs_to_eu_customs_area( $country, $postcode = return apply_filters( 'woocommerce_gzd_country_belongs_to_eu_customs_area', $belongs, $country, $postcode ); } - public static function base_country_supports_master_reference_number() { + public static function base_country_supports_export_reference_number() { $base_country = self::get_base_country(); - return apply_filters( 'woocommerce_gzd_base_country_supports_master_reference_number', self::country_belongs_to_eu_customs_area( $base_country ) ); + return apply_filters( 'woocommerce_gzd_base_country_supports_export_reference_number', self::country_belongs_to_eu_customs_area( $base_country ) ); } public static function is_shipping_international( $country, $args = array() ) { diff --git a/src/ShippingProvider/Auto.php b/src/ShippingProvider/Auto.php index c096f1fc..6dd7fa45 100644 --- a/src/ShippingProvider/Auto.php +++ b/src/ShippingProvider/Auto.php @@ -804,14 +804,14 @@ protected function get_simple_label_fields( $shipment ) { ); } - if ( $shipment->is_shipping_international() && Package::base_country_supports_master_reference_number() ) { + if ( $this->label_supports_export_reference_number( $shipment ) ) { $settings = array_merge( $settings, array( array( - 'id' => 'master_reference_number', - 'label' => _x( 'Master Reference Number', 'shipments', 'woocommerce-germanized-shipments' ), - 'description' => _x( 'In case of a shipment with an export declaration (e.g. value of goods > 1000 EUR) - provide the assigned Master Reference Number (MRN) for customs purposes.', 'shipments', 'woocommerce-germanized-shipments' ), + 'id' => 'export_reference_number', + 'label' => _x( 'Export Reference Number', 'shipments', 'woocommerce-germanized-shipments' ), + 'description' => _x( 'In case of a shipment with an export declaration - provide the assigned Export Reference Number for customs purposes.', 'shipments', 'woocommerce-germanized-shipments' ), 'value' => '', 'type' => 'text', 'desc_tip' => true, @@ -823,6 +823,10 @@ protected function get_simple_label_fields( $shipment ) { return $settings; } + protected function label_supports_export_reference_number( $shipment ) { + return apply_filters( "{$this->get_general_hook_prefix()}supports_export_reference_number", false, $shipment, $this ); + } + /** * @param \Vendidero\Germanized\Shipments\Shipment $shipment */ diff --git a/src/ShippingProvider/Service.php b/src/ShippingProvider/Service.php index 553f36f9..376c6b86 100644 --- a/src/ShippingProvider/Service.php +++ b/src/ShippingProvider/Service.php @@ -341,7 +341,7 @@ public function get_setting_fields( $configuration_set ) { array( array( 'title' => $this->get_label(), - 'desc' => $this->get_description() . ( ! empty( $this->get_long_description() ) ? ' ' . $this->get_long_description() : '' ), + 'desc' => $this->get_description() . ( ! empty( $this->get_long_description() ) ? '
' . $this->get_long_description() . '
' : '' ), 'id' => $setting_id, 'value' => $value, 'default' => $this->get_default_value(),