From 13154b24f2ac41c9cdcd2ccfc4dbc5382eb7fd32 Mon Sep 17 00:00:00 2001 From: Shohei Tanaka Date: Tue, 17 Aug 2021 09:59:28 +0900 Subject: [PATCH] Add hook to formatted name I want you to add a hook to the formatted name. I want a hook that can handle first and last name formats. --- .../class-wc-amazon-payments-advanced-api-abstract.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/class-wc-amazon-payments-advanced-api-abstract.php b/includes/class-wc-amazon-payments-advanced-api-abstract.php index 58a85267..a9153b38 100644 --- a/includes/class-wc-amazon-payments-advanced-api-abstract.php +++ b/includes/class-wc-amazon-payments-advanced-api-abstract.php @@ -382,9 +382,13 @@ public static function format_name( $name ) { // Use fallback value for the last name to avoid field required errors. $last_name_fallback = '.'; $names = explode( ' ', $name ); - return array( - 'first_name' => array_shift( $names ), - 'last_name' => empty( $names ) ? $last_name_fallback : implode( ' ', $names ), + return apply_filters( + 'woocommerce_amazon_pa_format_name', + array( + 'first_name' => array_shift( $names ), + 'last_name' => empty( $names ) ? $last_name_fallback : implode( ' ', $names ), + ), + $name ); }