slince / shopify-api-php

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

Order model does not contain customer object/property #38

Closed phena109 closed 5 years ago

phena109 commented 5 years ago

I have used the OrderManager to get an order and in the API doc it says we will have the customer property but there is no function called getCustomer in the Order model I retrieved.

In the end I have fallback to use the basic CRUD to get the order detail again and extract the customer information.

Can you please add the customer bit in? Thanks so much D.

slince commented 5 years ago

This will be added in the next release

phena109 commented 5 years ago

Just an update.

For some reason I have cleaned up my vendor folder and redownload everything as well as the cache folder the library created. I then keep getting exception You must define a type for Slince\Shopify\Manager\Order\Order::$customer. when I use the library.

After extensive check, I realised that no exception was thrown was just because I have been naughty and changed some of the config file. But as I load up everything from scratch, I get the issue. Later I found out what I have changed is the YAML file at slince/shopify-api-php/config/serializer/Manager.Order.Order.yml. All I need is to append the following and the customer property and customer property will at least show up as plain array with the right information.

        customer:
            type: array

This is just a quick info for you to put in the code so you can at least avoid some unwanted exceptions as well as sort of serve the customer content in the order object.

Hope this help, D

slince commented 5 years ago

fixed; you can access customer $order->getCustomer(); // instance of Slince\Shopify\Manager\Customer\Customer