Skip to content

Instantly share code, notes, and snippets.

@imanispatel
Last active March 17, 2023 02:56
Show Gist options
  • Save imanispatel/345c219111ba46ae63a7e1546b6c7bfe to your computer and use it in GitHub Desktop.
Save imanispatel/345c219111ba46ae63a7e1546b6c7bfe to your computer and use it in GitHub Desktop.
Replace display name with first name & last name in name value
<?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