Skip to content

Commit

Permalink
Do only format address in case not disabled via filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed May 17, 2024
1 parent cb3d912 commit afcacb3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/PickupDelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 ) ) {
Expand Down Expand Up @@ -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'];
}
Expand Down

0 comments on commit afcacb3

Please sign in to comment.