Skip to content
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

Added some sales channel resources #114

Open
wants to merge 123 commits into
base: v2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
eeacfc6
added additional endpoints
Sep 7, 2019
882a18a
Delete .DS_Store
Sep 7, 2019
718ed55
Delete .DS_Store
Sep 7, 2019
4a48a40
added checkout endpoints
Sep 7, 2019
0db069b
added checkout endpoints
Sep 7, 2019
c180ae1
Merge branch 'master' of https://github.com/TuunStudio/php-shopify
Sep 7, 2019
da95575
added sales channel sdk endpoints
Sep 7, 2019
184894e
Delete .DS_Store
Sep 7, 2019
4a9ca6f
Delete .DS_Store
Sep 7, 2019
f470422
added sales channel sdk endpoints
Sep 7, 2019
6aeee19
Merge branch 'master' of https://github.com/TuunStudio/php-shopify
Sep 7, 2019
9b361f6
removed customer order
Sep 7, 2019
8560d2d
added support for cursor based pagination
Dec 21, 2019
91c0ad5
added additional endpoints
Sep 7, 2019
1417d23
Delete .DS_Store
Sep 7, 2019
79c1366
Delete .DS_Store
Sep 7, 2019
2d424c5
added checkout endpoints
Sep 7, 2019
928df36
added checkout endpoints
Sep 7, 2019
e577d9a
added sales channel sdk endpoints
Sep 7, 2019
d23e51b
Delete .DS_Store
Sep 7, 2019
da78ce9
Delete .DS_Store
Sep 7, 2019
65f27b8
added sales channel sdk endpoints
Sep 7, 2019
d332736
removed customer order
Sep 7, 2019
c5bfe0e
added support for cursor based pagination
Dec 21, 2019
4e13a2a
fixed get access token request
Jan 27, 2020
56925b0
Merge branch 'master' of ssh://github.com/TuunStudio/php-shopify
Jan 27, 2020
dd3b467
merge with upstream
Apr 15, 2020
8d3f529
Merge branch 'master' of https://github.com/TuunStudio/php-shopify
Apr 15, 2020
304761d
fixed conflicts
Apr 15, 2020
ddf9bce
fixed shopify resource
Apr 15, 2020
01ddc1b
added json_decode
Apr 15, 2020
5bdf347
paging
Apr 15, 2020
c512120
remove extra Parentheses
saifulapm Apr 16, 2020
e71baca
fixed auth helper
Apr 21, 2020
eebe407
updated to current version
Apr 23, 2020
bac953f
Merge pull request #154 from saifulapm/patch-1
tareqtms Apr 25, 2020
6eaa205
price rule endpoint supports count
n3o77 May 5, 2020
37ff9aa
Merge pull request #158 from n3o77/master
tareqtms May 5, 2020
989d7b3
Update ShopifySDK.php
victorlap May 14, 2020
d66b266
Merge pull request #159 from victorlap/patch-1
tareqtms May 15, 2020
270b7dd
added ShopifyPayment Dispute resource
vkislichenko Jun 1, 2020
a233b8d
Merge pull request #162 from vkislichenko/feature/payments-disputes
tareqtms Jun 2, 2020
d4c9467
Add Shopify API headers as a config to the SDK
wissem Jun 17, 2020
764fa9d
added discount code location
Jul 3, 2020
e49925f
added discount code location
Jul 3, 2020
dfeee2b
Initial Commit
MCriggerXroadz Jul 14, 2020
6c464e3
Update ShopifyPayment.php
MCriggerXroadz Jul 17, 2020
6a114af
Author and Links
MCriggerXroadz Jul 17, 2020
279d521
Update Customer.php
Erdou Aug 23, 2020
d0e7fe7
Created function to generate account_activation_link
saumil122 Aug 24, 2020
da9cc98
Fix bug introduced by #143 by lowercasing key in getHeader
andyexeter Oct 12, 2020
f6fb339
Use Retry-After header as value to sleep for before retrying request
andyexeter Oct 12, 2020
32e6782
added application credit endpoint
Oct 14, 2020
473a3fc
Support DiscountCode batch Action
n3o77 Oct 25, 2020
478382a
Fix Issue No. 189
ratzkeeper Nov 17, 2020
9f47fb1
calculate() takes an optional array as a parameter.
TonyDeStefano Nov 19, 2020
75c0f4f
Merge pull request #191 from TonyDeStefano/patch-1
tareqtms Dec 5, 2020
da955a9
Merge branch 'master' into fix-issue-number-189
tareqtms Dec 5, 2020
b1b162b
Merge pull request #190 from howard-mintus/fix-issue-number-189
tareqtms Dec 5, 2020
979965a
Merge pull request #165 from wissem/shopify-api-features-header
tareqtms Dec 5, 2020
71f49b3
Merge pull request #171 from MCriggerXroadz/dev-shopifypayments
tareqtms Dec 5, 2020
d83f6d7
Merge pull request #176 from Erdou/patch-1
tareqtms Dec 5, 2020
24ff4e4
Merge branch 'master' into master
tareqtms Dec 5, 2020
1c554af
Merge pull request #178 from saumil122/master
tareqtms Dec 5, 2020
cdcb8dc
Merge pull request #184 from andyexeter/dynamic-retry-after
tareqtms Dec 5, 2020
d06cb86
Merge pull request #183 from andyexeter/fix-143
tareqtms Dec 5, 2020
79df85f
Merge pull request #188 from n3o77/master
tareqtms Dec 5, 2020
b182f7a
Resolves #198, Missing TenderTransaction endpoint
lhilton Dec 17, 2020
1d1c3e8
Merge pull request #199 from ComplYantCo/master
tareqtms Dec 17, 2020
a421436
Added the Cart Resource
whobutsb Jan 19, 2021
b81b405
Update Default API Version
tareqtms Mar 21, 2021
05eb123
Update CountryTest.php
tareqtms Mar 21, 2021
90c329d
Throw an exception if the request failed (bad auth code, invalid shop)
liamjcooper Apr 14, 2021
c70bd52
Slight change in vocabulary
liamjcooper Apr 14, 2021
fe7e971
Follow string quote convention
liamjcooper Apr 14, 2021
c2e1441
Return location header as array if response is 303
liamjcooper Apr 20, 2021
6ecbaf9
updated generate url to support numeric indexed arrays
May 5, 2021
96cfdc3
Remove query params from current url
waleev May 13, 2021
ccbe6e7
Adding Fulfillment Order
marxolly May 21, 2021
27ccacf
Merge pull request #204 from whobutsb/master
tareqtms Jun 15, 2021
b7dc4b7
Merge pull request #219 from liamjcooper/fix/access-token-exception
tareqtms Jun 15, 2021
0d86fc5
Merge pull request #221 from liamjcooper/fix/discount-lookup
tareqtms Jun 15, 2021
cdcd5c4
Merge pull request #227 from waleev/patch-1
tareqtms Jun 15, 2021
6c80502
Merge pull request #228 from marxolly/add-get-fulfillment-orders
tareqtms Jun 15, 2021
19693b0
Add additional curl configuration
npabisz Aug 27, 2021
00b6142
Merge pull request #238 from Yorkii/feature/curl-config
tareqtms Sep 13, 2021
9ae8623
Merge pull request #1 from phpclassic/master
fabio-sassi-spotview Sep 14, 2021
74ec175
add retry request callback
fabio-sassi-spotview Sep 14, 2021
ae81bdf
FulfillmentOrder hold and relase_hold methods
npabisz Oct 12, 2021
0f42110
feat: AccessScope resource
seka19 Oct 17, 2021
921d83d
added http code to shopify resource
Nov 1, 2021
4ef5170
Merge pull request #246 from automit2021/access-scope-resource
tareqtms Dec 18, 2021
1729aa0
Merge pull request #245 from Yorkii/feature/fulfillment-order
tareqtms Dec 18, 2021
32ec82a
[Fixes #251] Update Default API Version to 2021-10
tareqtms Dec 18, 2021
7233f96
$config updated(added AccessToken for running graphql test)
anikghosh256 Dec 21, 2021
65f64f1
test case added for GraphQL Query
anikghosh256 Dec 21, 2021
fa79086
config array updated - for private api
anikghosh256 Jan 3, 2022
a6b22e4
Merge pull request #254 from anikghosh256/master
tareqtms Feb 23, 2022
3609f49
Merge pull request #240 from fabio-sassi-spotview/fault_tollerant_req
tareqtms Feb 23, 2022
034a88d
Update README.md
tareqtms Feb 23, 2022
59e6f8c
Update API Version
tareqtms Feb 23, 2022
75cdc9c
Migrating from value_type to type
anikghosh256 Feb 23, 2022
6f56675
Merge pull request #255 from anikghosh256/master
tareqtms Jul 14, 2022
5bc3d3a
Update API Version
tareqtms Jul 14, 2022
5e63d97
Add Metafield property and method to docblock
ricog Jul 18, 2022
2f1595a
Merge pull request #259 from ricog/patch-1
tareqtms Jul 19, 2022
9c5a528
Rollback API Version (Breaking changes)
tareqtms Sep 29, 2022
81e6cc8
Update API Version to 2022-07
tareqtms Sep 29, 2022
3b6b023
Custom API Version in $config
tareqtms Sep 29, 2022
1816de4
Metafield as a child resource of Collection & DraftOrder
Oct 3, 2022
f931765
Merge pull request #267 from nVuln/master
tareqtms Oct 3, 2022
8b2c2a0
added fulfillment update_tracking action
Oct 6, 2022
4d49e3b
make fulfillment api as parent resource
Oct 6, 2022
f2e1428
Merge pull request #269 from nVuln/fulfillment-api
tareqtms Oct 9, 2022
44dadde
#266 - PHP Deprecated: explode(): Passing null to parameter #2 ($stri…
itsrexb Oct 21, 2022
b815f08
Merge pull request #273 from itsrexb/master
tareqtms Oct 24, 2022
30bb0f9
combined resources from upstream, and removed url option from post re…
Dec 7, 2022
34066f6
fixed response array issues
Dec 7, 2022
98b357d
added httpcode to resource
Dec 8, 2022
f266b2e
Added gift card adjustment functionality
justin-gist-apps Feb 28, 2023
a9c22b1
added last httpCode
tuun Jun 8, 2023
2d4f380
fixed http code
tuun Dec 8, 2023
bf36ab2
fixed content type header
tuun Dec 8, 2023
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor
/nbproject/private/
.idea/
.idea/
.DS_Store
46 changes: 42 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@ composer require phpclassic/php-shopify
PHPShopify uses curl extension for handling http calls. So you need to have the curl extension installed and enabled with PHP.
>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\HttpRequestJson` class.

You can pass additional curl configuration to `ShopifySDK`
```php
$config = array(
'ShopUrl' => 'yourshop.myshopify.com',
'ApiKey' => '***YOUR-PRIVATE-API-KEY***',
'Password' => '***YOUR-PRIVATE-API-PASSWORD***',
'Curl' => array(
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true
)
);

PHPShopify\ShopifySDK::config($config);
```
## Usage

You can use PHPShopify in a pretty simple object oriented way.

#### Configure ShopifySDK
If you are using your own private API, provide the ApiKey and Password.
If you are using your own private API (except GraphQL), provide the ApiKey and Password.

```php
$config = array(
Expand All @@ -31,14 +45,26 @@ $config = array(
PHPShopify\ShopifySDK::config($config);
```

For Third party apps, use the permanent access token.
For Third party apps, use the permanent access token.
> For GraphQL, AccessToken is required. If you are using private API for GraphQL, use your password as AccessToken here.

```php
$config = array(
'ShopUrl' => 'yourshop.myshopify.com',
'AccessToken' => '***ACCESS-TOKEN-FOR-THIRD-PARTY-APP***',
);

PHPShopify\ShopifySDK::config($config);
```
You can use specific Shopify API Version by adding in the config array

```php
$config = array(
'ShopUrl' => 'yourshop.myshopify.com',
'AccessToken' => '***ACCESS-TOKEN-FOR-THIRD-PARTY-APP***',
'ApiVersion' => '2022-07',
);

PHPShopify\ShopifySDK::config($config);
```
##### How to get the permanent access token for a shop?
Expand Down Expand Up @@ -171,7 +197,7 @@ $shopify->Order($orderID)->put($updateInfo);
```php
$webHookID = 453487303;

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


Expand Down Expand Up @@ -302,7 +328,8 @@ Some resources are available directly, some resources are only available through
- Blog -> Article -> [Metafield](https://help.shopify.com/api/reference/metafield)
- Blog -> [Event](https://help.shopify.com/api/reference/event/)
- Blog -> [Metafield](https://help.shopify.com/api/reference/metafield)
- [CarrierService](https://help.shopify.com/api/reference/carrierservice/)
- [CarrierService](https://help.shopify.com/api/reference/carrierservice/)-
- [Cart](https://shopify.dev/docs/themes/ajax-api/reference/cart) (read only)
- [Collect](https://help.shopify.com/api/reference/collect/)
- [Comment](https://help.shopify.com/api/reference/comment/)
- Comment -> [Event](https://help.shopify.com/api/reference/event/)
Expand Down Expand Up @@ -359,6 +386,8 @@ Some resources are available directly, some resources are only available through
- [Shop](https://help.shopify.com/api/reference/shop) _(read only)_
- [SmartCollection](https://help.shopify.com/api/reference/smartcollection)
- SmartCollection -> [Event](https://help.shopify.com/api/reference/event/)
- [ShopifyPayment](https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/)
- ShopifyPayment -> [Dispute](https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/dispute/) _(read only)_
- [Theme](https://help.shopify.com/api/reference/theme)
- Theme -> [Asset](https://help.shopify.com/api/reference/asset/)
- [User](https://help.shopify.com/api/reference/user) _(read only, Shopify Plus Only)_
Expand Down Expand Up @@ -483,6 +512,15 @@ The custom methods are specific to some resources which may not be available for
- [current()](https://help.shopify.com/api/reference/user#current)
Get the current logged-in user

### Shopify API features headers
To send `X-Shopify-Api-Features` headers while using the SDK, you can use the following:

```
$config['ShopifyApiFeatures'] = ['include-presentment-prices'];
$shopify = new PHPShopify\ShopifySDK($config);
```


## Reference
- [Shopify API Reference](https://help.shopify.com/api/reference/)

Expand Down
36 changes: 36 additions & 0 deletions lib/AccessScope.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace PHPShopify;

/**
* Class AccessScope
* @package PHPShopify
* @author Alexey Sinkevich
*/
class AccessScope extends ShopifyResource
{
/**
* @inheritDoc
*/
protected $resourceKey = 'access_scope';

/**
* @inheritDoc
*/
public $countEnabled = true;

/**
* @inheritDoc
*/
public $readOnly = true;

/**
* @param array $urlParams
* @param null $customAction
* @return string
*/
public function generateUrl($urlParams = array(), $customAction = null)
{
return ShopifySDK::$config['AdminUrl'] . 'oauth/' . $this->getResourcePath() . '.json';
}
}
26 changes: 26 additions & 0 deletions lib/ApplicationCredit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Created by PhpStorm.
* @author Tareq Mahmood <tareqtms@yahoo.com>
* Created at 8/18/16 9:50 AM UTC+06:00
*
* @see https://help.shopify.com/api/reference/applicationcharge Shopify API Reference for ApplicationCharge
*/

namespace PHPShopify;


class ApplicationCredit extends ShopifyResource
{
/**
* @inheritDoc
*/
protected $resourceKey = 'application_credit';

/**
* @inheritDoc
*/
public $countEnabled = false;


}
9 changes: 8 additions & 1 deletion lib/AuthHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public static function getCurrentUrl()
$protocol = 'http';
}

return "$protocol://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url = $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$url = false !== ($qsPos = strpos($url, '?')) ? substr($url, 0, $qsPos) : $url; // remove query params

return $url;
}

/**
Expand Down Expand Up @@ -170,6 +173,10 @@ public static function getAccessToken()

$response = HttpRequestJson::post($config['AdminUrl'] . 'oauth/access_token', $data);

if (CurlRequest::$lastHttpCode >= 400) {
throw new SdkException("The shop is invalid or the authorization code has already been used.");
}

return isset($response['access_token']) ? $response['access_token'] : null;
} else {
throw new SdkException("This request is not initiated from a valid shopify shop!");
Expand Down
51 changes: 51 additions & 0 deletions lib/Balance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Created by PhpStorm.
* @author Robert Jacobson <rjacobson@thexroadz.com>
* @author Matthew Crigger <mcrigger@thexroadz.com>
*
* @see https://help.shopify.com/en/api/reference/shopify_payments/balance Shopify API Reference for Shopify Payment Balance
*/

namespace PHPShopify;

/**
* --------------------------------------------------------------------------
* ShopifyPayment -> Child Resources
* --------------------------------------------------------------------------
*
*
*/
class Balance extends ShopifyResource
{
/**
* @inheritDoc
*/
protected $resourceKey = 'balance';

/**
* Get the pluralized version of the resource key
*
* Normally its the same as $resourceKey appended with 's', when it's different, the specific resource class will override this function
*
* @return string
*/
protected function pluralizeKey()
{
return $this->resourceKey;
}

/**
* If the resource is read only. (No POST / PUT / DELETE actions)
*
* @var boolean
*/
public $readOnly = true;

/**
* @inheritDoc
*/
protected $childResource = array(
'Transactions'
);
}
33 changes: 33 additions & 0 deletions lib/Batch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* @see https://help.shopify.com/api/reference/discounts/discountcode Shopify API Reference for PriceRule
*/

namespace PHPShopify;


/**
* --------------------------------------------------------------------------
* DiscountCode -> Batch action
* --------------------------------------------------------------------------
*
*/

class Batch extends ShopifyResource
{
/**
* @inheritDoc
*/
protected $resourceKey = 'batch';

protected function getResourcePath()
{
return $this->resourceKey;
}

protected function wrapData($dataArray, $dataKey = null)
{
return ['discount_codes' => $dataArray];
}

}
24 changes: 24 additions & 0 deletions lib/Cart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace PHPShopify;

/* @see https://shopify.dev/docs/themes/ajax-api/reference/cart */
use PHPShopify\ShopifyResource;

class Cart extends ShopifyResource {

/**
* @inheritDoc
*/
protected $resourceKey ='cart';

/**
* @inheritDoc
*/
public $searchEnabled = false;

/**
* @inheritDoc
*/
public $readOnly = true;
}
53 changes: 53 additions & 0 deletions lib/Checkout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Created by PhpStorm.
* @author Tareq Mahmood <tareqtms@yahoo.com>
* Created at 8/19/16 2:59 PM UTC+06:00
*
* @see https://help.shopify.com/api/reference/sales-channels/checkout Shopify API Reference for Checkout
*/

namespace PHPShopify;


/**
* --------------------------------------------------------------------------
* Order -> Child Resources
* --------------------------------------------------------------------------
* @property-read ShippingRate $ShippingRate
*
* @method ShippingRate ShippingRate(integer $id = null)
*

* --------------------------------------------------------------------------
* Checkout -> Custom actions
* --------------------------------------------------------------------------
* @method array complete() Completes Checkout without payment
*
*/
class Checkout extends ShopifyResource
{
/**
* @inheritDoc
*/
protected $resourceKey = 'checkout';

/**
* @inheritDoc
*/
public $countEnabled = false;

/**
* @inheritDoc
*/
protected $childResource = array (
'ShippingRate',
);
/**
* @inheritDoc
*/
protected $customPostActions = array(
'complete',
'payments'
);
}
5 changes: 4 additions & 1 deletion lib/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
* --------------------------------------------------------------------------
*
* @property-read Product $Product
* @property-read Metafield $Metafield
*
* @method Product Product(integer $id = null)
* @method Metafield Metafield(integer $id = null)
*
* @see https://shopify.dev/docs/admin-api/rest/reference/products/collection
*
Expand All @@ -31,5 +33,6 @@ class Collection extends ShopifyResource
*/
protected $childResource = array(
'Product',
'Metafield',
);
}
}
Loading