Last active
March 17, 2023 02:56
-
-
Save imanispatel/345c219111ba46ae63a7e1546b6c7bfe to your computer and use it in GitHub Desktop.
Replace display name with first name & last name in name value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set custom user variable for WooCommerce Wave Connector | |
* Replace display name with first name & last name in name value | |
* | |
* @param array $variables get variables. | |
* @param array $user_ids get user's id. | |
* @return array | |
*/ | |
function custom_customer_variable( $variables, $user_ids ) { | |
foreach ( $variables as $key => $variable ) { | |
$fname = isset( $variable['firstName'] ) ? $variable['firstName'] : ''; | |
$lname = isset( $variable['lastName'] ) ? $variable['lastName'] : ''; | |
$name = $fname . ' ' . $lname; | |
if ( ' ' !== $name ) { | |
$variable['name'] = $name; | |
$variables[ $key ] = $variable; | |
} | |
} | |
return $variables; | |
} | |
add_filter( 'venus_wc_export_customer_variables', 'custom_customer_variable', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment