Skip to content

Commit 0b361d4

Browse files
committed
README - Detail Reference
1 parent a8511a4 commit 0b361d4

File tree

1 file changed

+195
-26
lines changed

1 file changed

+195
-26
lines changed

README.md

Lines changed: 195 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Install with Composer
77
composer require phpclassic/php-shopify
88
```
99

10-
>You may not be able to download until a stable version is available. For the time being you can download and put this into `vendor/phpclassic` folder and add the following code into your root `composer.json` file:
10+
>You may not be able to install using composer until a stable version is available. For the time being you can download the zip file and put the extracted folder into `vendor/phpclassic` folder and add the following code into your root `composer.json` file:
1111
1212
```
1313
"autoload": {
@@ -18,17 +18,17 @@ composer require phpclassic/php-shopify
1818
```
1919

2020
### Requirements
21-
PHPShopify uses CURL extension for handling http calls to the API. So you need to be have enabled the curl extension.
21+
PHPShopify uses curl extension for handling http calls to the API. So you need to be have enabled the curl extension.
22+
>However if you prefer to use any other available package library for handling HTTP calls, you can easily do so by modifying 1 line in each of the `get()`, `post()`, `put()`, `delete()` methods in `PHPShopify\ShopifyAPI` class.
2223
2324
## Usage
2425

25-
PHPShopify is developed in a fully object oriented way. Usage is very simple.
26+
You can use PHPShopify in a pretty simple object oriented way.
2627

27-
#### Configure
28+
#### Configure ShopifyClient
2829
If you are using your own private API, provide the ApiKey and Password. For Third party apps, use the permanent access token which you have got from the app.
2930

3031
```php
31-
<?php
3232
$config = array(
3333
'ShopUrl' => 'yourshop.myshopify.com',
3434
'ApiKey' => '***YOUR-PRIVATE-API-KEY***',
@@ -39,7 +39,6 @@ $config = array(
3939
Or
4040

4141
```php
42-
<?php
4342
$config = array(
4443
'ShopUrl' => 'yourshop.myshopify.com',
4544
'AccessToken' => '***ACCESS-TOKEN-FOR-THIRD-PARTY-APP***',
@@ -52,34 +51,33 @@ $config = array(
5251
$shopify = new PHPShopify\ShopifyClient($config);
5352
```
5453

55-
##### Now just have fun using the SDK using the object oriented way. All objects are named as same as it is named in shopify API reference and you can GET, POST, PUT, DELETE accordingly.
54+
##### Now you can do `get()`, `post()`, `put()`, `delete()` calling the resources in the object oriented way. All resources are named as same as it is named in shopify API reference. (See the resource map below.)
55+
> All the requests returns an array (which can be single resource or an array of multiple resources) if succeeded. When no result is expected (for example a DELETE request), an empty array will be returned.
5656
57-
For example getting all product list:
57+
Get all product list (GET request)
5858

5959
```php
6060
$products = $shopify->Product->get();
6161
```
6262

63-
GET any specific product with ID
63+
Get any specific product with ID (GET request)
6464

6565
```php
6666
$productID = 23564666666;
6767
$product = $shopify->Product($productID)->get();
6868
```
6969

70-
The child resources can be used in a nested way. For example, get the images of a product
70+
You can also filter the results by using the url parameters (as specified by Shopify API Reference for each specific resource).
71+
For example get the list of cancelled orders after a specified date and time (and `fields` specifies the data columns for each row to be rendered) :
7172

7273
```php
73-
$productID = 23564666666;
74-
$productImages = $shopify->Product($productID)->Image->get();
75-
```
76-
77-
Or GET any specific article from a specific blog like this
74+
$params = array(
75+
'status' => 'cancelled',
76+
'created_at_min' => '2016-06-25T16:15:47-04:00',
77+
'fields' => 'id,line_items,name,total_price'
78+
);
7879

79-
```php
80-
$blogID = 23564666666;
81-
$articleID = 125336666;
82-
$blogArticle = $shopify->Blog($blogID)->Article($articleID)->get();
80+
$orders = $shopify->Order->get($params);
8381
```
8482

8583
Create a new order (POST Request)
@@ -99,10 +97,38 @@ $order = array (
9997
$shopify->Order->post($order);
10098
```
10199

102-
Update a customer address (PUT Request)
100+
Update an order (PUT Request)
101+
102+
```php
103+
$updateInfo = array (
104+
"fulfillment_status" => "fulfilled",
105+
);
106+
107+
$shopify->Order($orderID)->put($order);
108+
```
109+
110+
Remove a WebHook (DELETE request)
111+
112+
```php
113+
$webHookID = 453487303;
114+
115+
$shopify->WebHook($webHookID)->delete());
116+
```
117+
118+
119+
###The child resources can be used in a nested way.
120+
> You must provide the ID of the parent resource when trying to get any child resource
121+
For example, get the images of a product (GET request)
103122

104123
```php
105-
$updatedAddress = array(
124+
$productID = 23564666666;
125+
$productImages = $shopify->Product($productID)->Image->get();
126+
```
127+
128+
Add a new address for a customer (POST Request)
129+
130+
```php
131+
$address = array(
106132
"address1" => "129 Oak St",
107133
"city" => "Ottawa",
108134
"province" => "ON",
@@ -114,18 +140,161 @@ $updatedAddress = array(
114140
);
115141

116142
$customerID = 4425749127;
117-
$addressID = 225663355;
118143

119-
$shopify->Customer($customerID)->Address($addressID)->put($updatedAddress);
144+
$shopify->Customer($customerID)->Address->post($address);
120145
```
121146

122-
DELETE a WebHook
147+
Create a fulfillment event (POST request)
123148

124149
```php
125-
$webHookID = 453487303;
150+
$fulfillmentEvent = array(
151+
"status" => "in_transit"
152+
);
126153

127-
$shopify->WebHook($webHookID)->delete());
154+
$shopify->Order($orderID)->Fulfillment($fulfillmentID)->Event->post($fulfillmentEvent);
128155
```
129156

157+
Update a Blog article (PUT request)
158+
159+
```php
160+
$blogID = 23564666666;
161+
$articleID = 125336666;
162+
$updateArtilceInfo = array(
163+
"title" => "My new Title",
164+
"author" => "Your name",
165+
"tags" => "Tags, Will Be, Updated",
166+
"body_html" => "<p>Look, I can even update through a web service.<\/p>",
167+
);
168+
$shopify->Blog($blogID)->Article($articleID)->put($updateArtilceInfo);
169+
```
170+
171+
Delete any specific article from a specific blog (DELETE request)
172+
173+
```php
174+
$blogArticle = $shopify->Blog($blogID)->Article($articleID)->delete();
175+
```
176+
177+
### Available Resource Mapping
178+
Some resources are available directly, some resources are only available through parent resources and a few resources can be accessed both ways. It is recommended that you see the details in the related Shopify API Reference page about each resource. Each resource name here is linked to related Shopify API Reference page.
179+
> Use the resources only by listed resource map. Trying to get a resource directly which is only available through parent resource may end up with errors.
180+
181+
- [AbandonedCheckout](https://help.shopify.com/api/reference/abandoned_checkouts)
182+
- [ApplicationCharge](https://help.shopify.com/api/reference/applicationcharge)
183+
- [Blog](https://help.shopify.com/api/reference/blog/)
184+
- Blog -> [Article](https://help.shopify.com/api/reference/article/)
185+
- Blog -> Article -> [Event](https://help.shopify.com/api/reference/event/)
186+
- Blog -> [Event](https://help.shopify.com/api/reference/event/)
187+
- Blog -> [Metafield](https://help.shopify.com/api/reference/metafield)
188+
- [CarrierService](https://help.shopify.com/api/reference/carrierservice/)
189+
- [Collect](https://help.shopify.com/api/reference/collect/)
190+
- [Comment](https://help.shopify.com/api/reference/comment/)
191+
- Comment -> [Event](https://help.shopify.com/api/reference/event/)
192+
- [Country](https://help.shopify.com/api/reference/country/)
193+
- Country -> [Province](https://help.shopify.com/api/reference/province/)
194+
- [CustomCollection]()
195+
- CustomCollection -> [Event](https://help.shopify.com/api/reference/event/)
196+
- CustomCollection -> [Metafield](https://help.shopify.com/api/reference/metafield)
197+
- [Customer](https://help.shopify.com/api/reference/customer/)
198+
- Customer -> [Address](https://help.shopify.com/api/reference/customeraddress/)
199+
- Customer -> [Metafield](https://help.shopify.com/api/reference/metafield)
200+
- [CustomerSavedSearch](https://help.shopify.com/api/reference/customersavedsearch/)
201+
- CustomerSavedSearch -> [Customer](https://help.shopify.com/api/reference/customer/)
202+
- [Discount](https://help.shopify.com/api/reference/discount) _(Shopify Plus Only)_
203+
- [Event](https://help.shopify.com/api/reference/event/)
204+
- [FulfillmentService](https://help.shopify.com/api/reference/fulfillmentservice)
205+
- [GiftCard](https://help.shopify.com/api/reference/gift_card) _(Shopify Plus Only)_
206+
- [Location](https://help.shopify.com/api/reference/location/) _(read only)_
207+
- [Metafield](https://help.shopify.com/api/reference/metafield)
208+
- [Multipass](https://help.shopify.com/api/reference/multipass) _(Shopify Plus Only, API not available yet)_
209+
- [Order](https://help.shopify.com/api/reference/order)
210+
- Order -> [Fulfillment](https://help.shopify.com/api/reference/fulfillment)
211+
- Order -> Fulfillment -> [Event](https://help.shopify.com/api/reference/fulfillmentevent)
212+
- Order -> [Risk](https://help.shopify.com/api/reference/order_risks)
213+
- Order -> [Refund](https://help.shopify.com/api/reference/refund)
214+
- Order -> [Transaction](https://help.shopify.com/api/reference/transaction)
215+
- Order -> [Event](https://help.shopify.com/api/reference/event/)
216+
- Order -> [Metafield](https://help.shopify.com/api/reference/metafield)
217+
- [Page](https://help.shopify.com/api/reference/page)
218+
- Page -> [Event](https://help.shopify.com/api/reference/event/)
219+
- Page -> [Metafield](https://help.shopify.com/api/reference/metafield)
220+
- [Policy](https://help.shopify.com/api/reference/policy) _(read only)_
221+
- [Product](https://help.shopify.com/api/reference/product)
222+
- Product -> [Image](https://help.shopify.com/api/reference/product_image)
223+
- Product -> [Variant](https://help.shopify.com/api/reference/product_variant)
224+
- Product -> Variant -> [Metafield](https://help.shopify.com/api/reference/metafield)
225+
- Product -> [Event](https://help.shopify.com/api/reference/event/)
226+
- Product -> [Metafield](https://help.shopify.com/api/reference/metafield)
227+
- [RecurringApplicationCharge](https://help.shopify.com/api/reference/recurringapplicationcharge)
228+
- RecurringApplicationCharge -> [UsageCharge](https://help.shopify.com/api/reference/usagecharge)
229+
- [Redirect](https://help.shopify.com/api/reference/redirect)
230+
- [ScriptTag](https://help.shopify.com/api/reference/scripttag)
231+
- [ShippingZone](https://help.shopify.com/api/reference/shipping_zone) _(read only)_
232+
- [Shop](https://help.shopify.com/api/reference/shop) _(read only)_
233+
- [SmartCollection](https://help.shopify.com/api/reference/smartcollection)
234+
- SmartCollection -> [Event](https://help.shopify.com/api/reference/event/)
235+
- [Theme](https://help.shopify.com/api/reference/theme)
236+
- Theme -> [Asset](https://help.shopify.com/api/reference/asset/)
237+
- [User](https://help.shopify.com/api/reference/user) _(read only, Shopify Plus Only_
238+
- [Webhook](https://help.shopify.com/api/reference/webhook)
239+
- []()
240+
241+
### Custom actions
242+
There are several action methods which can be called without calling the `get()`, `post()`, `put()`, `delete()` methods directly, which eventually results in a custom call to one of the `get()`, `post()`, `put()`, `delete()` methods.
243+
The custom methods are specific to some resources which may not be available for other resources. It is recommended that you see the details in the related Shopify API Reference page about each action. We will just list the available actions here with some brief info.
244+
245+
- Comment ->
246+
- [spam()](https://help.shopify.com/api/reference/comment#spam)
247+
Mark a Comment as spam
248+
- [notSpam()](https://help.shopify.com/api/reference/comment#not_spam)
249+
Mark a Comment as not spam
250+
- [approve()](https://help.shopify.com/api/reference/comment#approve)
251+
Approve a Comment
252+
- [remove()](https://help.shopify.com/api/reference/comment#remove)
253+
Remove a Comment
254+
- [restore()](https://help.shopify.com/api/reference/comment#restore)
255+
Restore a Comment
256+
257+
- Customer -> Address ->
258+
- [makeDefault()](https://help.shopify.com/api/reference/customeraddress#default)
259+
Sets the address as default for the customer
260+
- [set()](https://help.shopify.com/api/reference/customeraddress#set)
261+
Perform bulk operations against a number of addresses
262+
263+
- Discount ->
264+
- [enable()]()
265+
Enable a discount
266+
- [disable()]()
267+
Disable a discount
268+
269+
- Fulfillment ->
270+
- [complete()](https://help.shopify.com/api/reference/fulfillment#complete)
271+
Complete a fulfillment
272+
- [open()](https://help.shopify.com/api/reference/fulfillment#open)
273+
Open a pending fulfillment
274+
- [cancel()](https://help.shopify.com/api/reference/fulfillment#cancel)
275+
Cancel a fulfillment
276+
277+
- GiftCard ->
278+
- [disable()](https://help.shopify.com/api/reference/gift_card#disable)
279+
Disable a gift card.
280+
281+
- Order -> Refund ->
282+
- [calculate()](https://help.shopify.com/api/reference/refund#calculate)
283+
Calculate a Refund.
284+
285+
- RecurringApplicationCharge ->
286+
- [activate()](https://help.shopify.com/api/reference/recurringapplicationcharge#activate)
287+
Activate a recurring application charge
288+
- [customize($data)](https://help.shopify.com/api/reference/recurringapplicationcharge#customize)
289+
Customize a recurring application charge
290+
291+
- SmartCollection ->
292+
- [sortOrder($params)](https://help.shopify.com/api/reference/smartcollection#order)
293+
Set the ordering type and/or the manual order of products in a smart collection
294+
295+
- User ->
296+
- [current()](https://help.shopify.com/api/reference/user#current)
297+
Get the current logged-in user
298+
130299
#Reference
131300
- [Shopify API Reference](https://help.shopify.com/api/reference/)

0 commit comments

Comments
 (0)