slince / shopify-api-php

:rocket: Shopify API Client for PHP
MIT License
128 stars 48 forks source link

Convert shopify object to array #78

Closed larsjanssen6 closed 4 years ago

larsjanssen6 commented 4 years ago

Hi,

Awesome work thanks! Got a question/issue. A couple of days ago I updated to a new version now the $serializer->toArray(); does not work anymore.

My code:

$serializer = SerializerBuilder::create()->build();

$manager = Shopify::getManager();

$customer = new Customer();

$customer->setFirstName($this->novaCustomer->first_name);
$customer->setLastName($this->novaCustomer->last_name);
$customer->setEmail($this->novaCustomer->email);
$customer->setVerifiedEmail(true);

$shopifyCustomer = $manager->getCustomerManager()->create(
    $serializer->toArray($customer)
);

Error:

TypeError: unserialize() expects parameter 1 to be string, array given

I know I'm using the jms serializer here but do you maybe have an Idea how I can fix this?

larsjanssen6 commented 4 years ago

Never mind had to remove the cache.