Skip to content

Commit 838ca0b

Browse files
authored
Merge pull request #27 from kilobyte2007/master
PriceRules and Discounts resources added
2 parents 9c6d4bf + e79edf3 commit 838ca0b

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

lib/DiscountCode.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* @author Sergiu Cazac <kilobyte2007@gmail.com>
5+
* Created at 5/06/19 2:09 AM UTC+03:00
6+
*
7+
* @see https://help.shopify.com/api/reference/discounts/discountcode Shopify API Reference for PriceRule
8+
*/
9+
10+
namespace PHPShopify;
11+
12+
13+
class DiscountCode extends ShopifyResource
14+
{
15+
/**
16+
* @inheritDoc
17+
*/
18+
protected $resourceKey = 'discount_code';
19+
}

lib/PriceRule.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* @author Sergiu Cazac <kilobyte2007@gmail.com>
5+
* Created at 5/06/19 2:06 AM UTC+03:00
6+
*
7+
* @see https://help.shopify.com/api/reference/discounts/pricerule Shopify API Reference for PriceRule
8+
*/
9+
10+
namespace PHPShopify;
11+
12+
13+
/*
14+
* --------------------------------------------------------------------------
15+
* PriceRule -> Child Resources
16+
* --------------------------------------------------------------------------
17+
* @property-read ShopifyResource $DiscountCode
18+
*
19+
* @method ShopifyResource DiscountCode(integer $id = null)
20+
*
21+
*/
22+
class PriceRule extends ShopifyResource
23+
{
24+
/**
25+
* @inheritDoc
26+
*/
27+
public $resourceKey = 'price_rule';
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
public $countEnabled = false;
33+
34+
/**
35+
* @inheritDoc
36+
*/
37+
protected $childResource = array(
38+
'DiscountCode'
39+
);
40+
}

lib/ShopifySDK.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class ShopifySDK
179179
'Policy',
180180
'Product',
181181
'ProductVariant',
182+
'PriceRule',
182183
'RecurringApplicationCharge',
183184
'Redirect',
184185
'Report',
@@ -205,6 +206,7 @@ class ShopifySDK
205206
'OrderRisk' => 'Order',
206207
'ProductImage' => 'Product',
207208
'ProductVariant' => 'Product',
209+
'DiscountCode' => 'PriceRule',
208210
'Province' => 'Country',
209211
'Refund' => 'Order',
210212
'Transaction' => 'Order',

0 commit comments

Comments
 (0)