Skip to content

Commit c2b4073

Browse files
authored
Merge pull request #6 from phpclassic/master
Update fork from upstream
2 parents 587fa24 + bac953f commit c2b4073

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

README.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PHP Shopify SDK
22

3-
[![Build Status](https://travis-ci.org/phpclassic/php-shopify.svg?branch=master)](https://travis-ci.org/phpclassic/php-shopify) [![Monthly Downloads](https://poser.pugx.org/phpclassic/php-shopify/d/monthly)](https://packagist.org/packages/phpclassic/php-shopify) [![Total Downloads](https://poser.pugx.org/phpclassic/php-shopify/downloads)](https://packagist.org/packages/phpclassic/php-shopify) [![Latest Stable Version](https://poser.pugx.org/phpclassic/php-shopify/v/stable)](https://packagist.org/packages/phpclassic/php-shopify) [![Latest Unstable Version](https://poser.pugx.org/phpclassic/php-shopify/v/unstable)](https://packagist.org/packages/phpclassic/php-shopify) [![License](https://poser.pugx.org/phpclassic/php-shopify/license)](https://packagist.org/packages/phpclassic/php-shopify) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ME9N6M2B87XT4&currency_code=USD&source=url)
3+
[![Build Status](https://travis-ci.org/phpclassic/php-shopify.svg?branch=master)](https://travis-ci.org/phpclassic/php-shopify) [![Monthly Downloads](https://poser.pugx.org/phpclassic/php-shopify/d/monthly)](https://packagist.org/packages/phpclassic/php-shopify) [![Total Downloads](https://poser.pugx.org/phpclassic/php-shopify/downloads)](https://packagist.org/packages/phpclassic/php-shopify) [![Latest Stable Version](https://poser.pugx.org/phpclassic/php-shopify/v/stable)](https://packagist.org/packages/phpclassic/php-shopify) [![Latest Unstable Version](https://poser.pugx.org/phpclassic/php-shopify/v/unstable)](https://packagist.org/packages/phpclassic/php-shopify) [![License](https://poser.pugx.org/phpclassic/php-shopify/license)](https://packagist.org/packages/phpclassic/php-shopify) [![Hire](https://img.shields.io/badge/Hire-Upwork-green.svg)](https://www.upwork.com/fl/tareqmahmood?s=1110580755107926016)
44

55
PHPShopify is a simple SDK implementation of Shopify API. It helps accessing the API in an object oriented way.
66

@@ -171,7 +171,7 @@ $shopify->Order($orderID)->put($updateInfo);
171171
```php
172172
$webHookID = 453487303;
173173

174-
$shopify->Webhook($webHookID)->delete());
174+
$shopify->Webhook($webHookID)->delete();
175175
```
176176

177177

@@ -255,6 +255,36 @@ Query;
255255

256256
$data = $shopify->GraphQL->post($graphQL);
257257
```
258+
##### Variables
259+
If you want to use [GraphQL variables](https://shopify.dev/concepts/graphql/variables), you need to put the variables in an array and give it as the 4th argument of the `post()` method. The 2nd and 3rd arguments don't have any use in GraphQL, but are there to keep similarity with other requests, you can just keep those as `null`. Here is an example:
260+
261+
```php
262+
$graphQL = <<<Query
263+
mutation ($input: CustomerInput!) {
264+
customerCreate(input: $input)
265+
{
266+
customer {
267+
id
268+
displayName
269+
}
270+
userErrors {
271+
field
272+
message
273+
}
274+
}
275+
}
276+
Query;
277+
278+
$variables = [
279+
"input" => [
280+
"firstName" => "Greg",
281+
"lastName" => "Variables",
282+
"email" => "gregvariables@teleworm.us"
283+
]
284+
]
285+
$shopify->GraphQL->post($graphQL, null, null, $variables);
286+
```
287+
258288

259289
##### GraphQL Builder
260290
This SDK only accepts a GraphQL string as input. You can build your GraphQL from [Shopify GraphQL Builder](https://help.shopify.com/en/api/graphql-admin-api/graphiql-builder)
@@ -456,10 +486,10 @@ The custom methods are specific to some resources which may not be available for
456486
## Reference
457487
- [Shopify API Reference](https://help.shopify.com/api/reference/)
458488

459-
## Donation
460-
If this project help you reduce time to develop, you can donate any amount, which will help us to devote more hours to this project and ensure more frequent updates.
489+
## Paid Support
490+
You can hire the author of this SDK for setting up your project with PHPShopify SDK.
461491

462-
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ME9N6M2B87XT4&currency_code=USD&source=url)
492+
[Hire at Upwork](https://www.upwork.com/fl/tareqmahmood?s=1110580755107926016)
463493

464494
## Backers
465495

lib/ShopifyResource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,12 @@ public function processResponse($responseArray, $dataKey = null)
524524
//Something went wrong, Checking HTTP Codes
525525
$httpOK = 200; //Request Successful, OK.
526526
$httpCreated = 201; //Create Successful.
527+
$httpDeleted = 204; //Delete Successful
527528

528529
//should be null if any other library used for http calls
529530
$httpCode = CurlRequest::$lastHttpCode;
530531

531-
if ($httpCode != null && $httpCode != $httpOK && $httpCode != $httpCreated) {
532+
if ($httpCode != null && $httpCode != $httpOK && $httpCode != $httpCreated && $httpCode != $httpDeleted) {
532533
throw new Exception\CurlException("Request failed with HTTP Code $httpCode.");
533534
}
534535
}

0 commit comments

Comments
 (0)