1
votes

I am trying to create new customer with shipping address and then want them to redirect to a page to show "Thank You" or "Error" message. I have used:


    $createFields = array(
            'first_name'=>$first_name,
            'last_name'=>$last_name,
            'email'=>$email, 
            'company'=>$company,
            'phone'=>$phone,
            'addresses'=>array(
                'first_name'=>$first_name,
                'last_name'=>$last_name,
                'phone'=>$phone,
                'street_1'=>$street_1,
                'city'=>'',
                'state'=>'',
                'zip'=>'',
                'country'=>''
            )
    );

$customers = Bigcommerce::createCustomer($createFields);

to create customer but it's not working at all. Once I remove 'addresses' field, new customer get created.

Can anyone help me telling how can I add address with customer? Also how can I check whether customer has been created properly or not? It may happen customer tries to re-register himself - the system should show error "email already exists".

I am new to Bigcommerce API - any help will be appreciated.

Thanks

1

1 Answers

0
votes

In the Bigcommerce class Client.php, you can find that exist a method named: createCustomerAddress. You just need to pass it the customer id and the address single array that you want to add. An example of this could be:

$address = array(
   'country'=>'United States',
   'first_name'=>'First',
   'last_name'=>'Last',
   'street_1'=>'5543 Ave34',
   'city'=>'Miami',
   'state'=>'Florida',
   'zip'=>'54023',
   'phone'=>'783 000 0000'
);
Bigcommerce::createCustomerAddress($customer_id, $address);