Skip to content

Update fork from upstream #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PHP Shopify SDK

[![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)
[![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)

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

Expand Down Expand Up @@ -171,7 +171,7 @@ $shopify->Order($orderID)->put($updateInfo);
```php
$webHookID = 453487303;

$shopify->Webhook($webHookID)->delete());
$shopify->Webhook($webHookID)->delete();
```


Expand Down Expand Up @@ -255,6 +255,36 @@ Query;

$data = $shopify->GraphQL->post($graphQL);
```
##### Variables
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:

```php
$graphQL = <<<Query
mutation ($input: CustomerInput!) {
customerCreate(input: $input)
{
customer {
id
displayName
}
userErrors {
field
message
}
}
}
Query;

$variables = [
"input" => [
"firstName" => "Greg",
"lastName" => "Variables",
"email" => "[email protected]"
]
]
$shopify->GraphQL->post($graphQL, null, null, $variables);
```


##### GraphQL Builder
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)
Expand Down Expand Up @@ -456,10 +486,10 @@ The custom methods are specific to some resources which may not be available for
## Reference
- [Shopify API Reference](https://help.shopify.com/api/reference/)

## Donation
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.
## Paid Support
You can hire the author of this SDK for setting up your project with PHPShopify SDK.

[![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)
[Hire at Upwork](https://www.upwork.com/fl/tareqmahmood?s=1110580755107926016)

## Backers

Expand Down
3 changes: 2 additions & 1 deletion lib/ShopifyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,12 @@ public function processResponse($responseArray, $dataKey = null)
//Something went wrong, Checking HTTP Codes
$httpOK = 200; //Request Successful, OK.
$httpCreated = 201; //Create Successful.
$httpDeleted = 204; //Delete Successful

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

if ($httpCode != null && $httpCode != $httpOK && $httpCode != $httpCreated) {
if ($httpCode != null && $httpCode != $httpOK && $httpCode != $httpCreated && $httpCode != $httpDeleted) {
throw new Exception\CurlException("Request failed with HTTP Code $httpCode.");
}
}
Expand Down