Skip to content

Commit

Permalink
feat(mailchimp): parse contact name into merge fields (#1628)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelpeixe authored Sep 6, 2024
1 parent bd6fe39 commit aeba65a
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,15 @@ public function add_contact( $contact, $list_id = false, $tags = [], $interests
$this->get_status_for_payload( $contact )
);

// Parse full name into first + last.
if ( isset( $contact['name'] ) ) {
$name_fragments = explode( ' ', $contact['name'], 2 );
$contact['metadata']['First Name'] = $name_fragments[0];
if ( isset( $name_fragments[1] ) ) {
$contact['metadata']['Last Name'] = $name_fragments[1];
}
}

try {

$mc = new Mailchimp( $this->api_key() );
Expand Down

0 comments on commit aeba65a

Please sign in to comment.