From afcacb3f4b410be090b64ace4eba1aedd5a80b28 Mon Sep 17 00:00:00 2001 From: vendidero Date: Fri, 17 May 2024 13:12:56 +0200 Subject: [PATCH] Do only format address in case not disabled via filter. --- src/PickupDelivery.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/PickupDelivery.php b/src/PickupDelivery.php index e9572a05..e57d9208 100644 --- a/src/PickupDelivery.php +++ b/src/PickupDelivery.php @@ -860,6 +860,10 @@ public static function register_classic_checkout_fields( $fields ) { * @return mixed */ public static function set_formatted_shipping_address( $fields, $order ) { + if ( ! self::is_enabled() ) { + return $fields; + } + if ( ! empty( $fields ) && is_array( $fields ) ) { $shipment_order = wc_gzd_get_shipment_order( $order ); $customer_number = $shipment_order->get_pickup_location_customer_number(); @@ -873,6 +877,10 @@ public static function set_formatted_shipping_address( $fields, $order ) { } public static function set_formatted_customer_shipping_address( $address, $customer_id, $name ) { + if ( ! self::is_enabled() ) { + return $address; + } + if ( 'shipping' === $name ) { if ( self::is_pickup_location_delivery_available_for_customer( $customer_id ) ) { if ( $customer_number = self::get_pickup_location_customer_number_by_customer( $customer_id ) ) { @@ -977,6 +985,10 @@ public static function register_order_address_customer_number( $address, $addres } public static function formatted_shipping_replacements( $fields, $args ) { + if ( ! self::is_enabled() ) { + return $fields; + } + if ( isset( $args['pickup_location_customer_number'] ) && ! empty( $args['pickup_location_customer_number'] ) ) { $fields['{name}'] = $fields['{name}'] . "\n" . $args['pickup_location_customer_number']; }