Skip to content

Error when create a customer #170

Closed
Closed
@diahai

Description

@diahai

Hi,
Please help me to resolve this error. Thanks!

Fatal error: Uncaught PHPShopify\Exception\ApiException: base - Customer must have a name, phone number or email address in C:\xampp\htdocs\test\shopify\vendor\phpclassic\php-shopify\lib\ShopifyResource.php:543 Stack trace: #0 C:\xampp\htdocs\test\shopify\vendor\phpclassic\php-shopify\lib\ShopifyResource.php(413): PHPShopify\ShopifyResource->processResponse(Array, 'customer') #1 C:\xampp\htdocs\test\shopify\index.php(89): PHPShopify\ShopifyResource->post(Array) #2 {main} thrown in C:\xampp\htdocs\test\shopify\vendor\phpclassic\php-shopify\lib\ShopifyResource.php on line 543

My code:

$shopify = new PHPShopify\ShopifySDK($config);
$customerData = array
        (
            "customer" => array(
                "first_name"    =>  "Steve",
                "last_name"     =>  "Lastnameson",
                "email"         =>  "steve.lastnameson10@test.com",
                "verified_email"=>  true,
                "addresses"     =>  array(
                    0 => array(
                        "address1"  =>  "123 Oak St",
                        "city"      =>  "Ottawa",
                        "country"   =>  "CA",
                        "first_name"=>  "Mother",
                        "last_name" =>  "Lastnameson",
                        "phone"     =>  "555-1212",
                        "province"  =>  "ON",
                        "zip"       =>  "123 AB"
                    )
                )
            )
        );
$response = $shopify->Customer->post($customerData);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions