Ad

How To Output The A Shopify Customer's Full Name On A Mailchimp List

- 1 answer

I have Mailchimp app and setup the integration, everything seems to work, except that it doesn't output the full name of the customer. I can output first name and last name, but the concatenation is outputting 0.

if($verified) {

  $customer_data = json_decode($data);
  $customer_email = $customer_data->email;
  $customer_fname = $customer_data->first_name;
  $customer_lname = $customer_data->last_name;
  $customer_name = $customer_fname + " " + $customer_lname;

  mc_subscribe($customer_email, $customer_name, $m_apikey, '$listid', 'us7');

}

function mc_subscribe($email, $name, $apikey, $listid, $server) {
  $auth = base64_encode( 'user:'.$apikey );
  $data = array(
    'apikey'        => $apikey,
    'email_address' => $email,
    'status'        => 'subscribed',
    'merge_fields'  => array(
      'MMERGE5' => $name
    )
  );
Ad

Answer

The PHP concatenation operator is (.) not (+) so try this:

$customer_name = $customer_fname. " ".$customer_lname;

Ad
source: stackoverflow.com
Ad