Skip to content

Commit 79df85f

Browse files
authored
Merge pull request #188 from n3o77/master
Support DiscountCode batch Action
2 parents d06cb86 + 473a3fc commit 79df85f

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

lib/Batch.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* @see https://help.shopify.com/api/reference/discounts/discountcode Shopify API Reference for PriceRule
4+
*/
5+
6+
namespace PHPShopify;
7+
8+
9+
/**
10+
* --------------------------------------------------------------------------
11+
* DiscountCode -> Batch action
12+
* --------------------------------------------------------------------------
13+
*
14+
*/
15+
16+
class Batch extends ShopifyResource
17+
{
18+
/**
19+
* @inheritDoc
20+
*/
21+
protected $resourceKey = 'batch';
22+
23+
protected function getResourcePath()
24+
{
25+
return $this->resourceKey;
26+
}
27+
28+
protected function wrapData($dataArray, $dataKey = null)
29+
{
30+
return ['discount_codes' => $dataArray];
31+
}
32+
33+
}

lib/PriceRule.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* @property-read ShopifyResource $DiscountCode
1818
*
1919
* @method ShopifyResource DiscountCode(integer $id = null)
20+
* @method ShopifyResource Batch()
2021
*
2122
*/
2223
class PriceRule extends ShopifyResource
@@ -30,6 +31,7 @@ class PriceRule extends ShopifyResource
3031
* @inheritDoc
3132
*/
3233
protected $childResource = array(
33-
'DiscountCode'
34+
'DiscountCode',
35+
'Batch',
3436
);
35-
}
37+
}

0 commit comments

Comments
 (0)