Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c0103f9

Browse files
Merge pull request #299 from whobutsb/feature/giftcard-adjustments
Gift Card Adjustment Resource
2 parents eb26e68 + 589ebb8 commit c0103f9

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ Some resources are available directly, some resources are only available through
357357
- FulfillmentOrder -> [FulfillmentRequest](https://shopify.dev/api/admin-rest/2023-01/resources/fulfillmentrequest)
358358
- FulfillmentOrder -> [Fulfillment](https://shopify.dev/api/admin-rest/2023-01/resources/fulfillment)
359359
- [GiftCard](https://help.shopify.com/api/reference/gift_card) _(Shopify Plus Only)_
360+
- GiftCard -> [Adjustment](https://shopify.dev/docs/api/admin-rest/2023-01/resources/gift-card-adjustment) _(Shopify Plus Only)_
360361
- [InventoryItem](https://help.shopify.com/api/reference/inventoryitem)
361362
- [InventoryLevel](https://help.shopify.com/api/reference/inventorylevel)
362363
- [Location](https://help.shopify.com/api/reference/location/) _(read only)_

‎lib/GiftCard.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,11 @@ public function disable()
4545

4646
return $this->post($dataArray, $url);
4747
}
48-
}
48+
49+
/**
50+
* @inheritDoc
51+
*/
52+
protected $childResource = array(
53+
'GiftCardAdjustment' => 'Adjustment'
54+
);
55+
}

‎lib/GiftCardAdjustment.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 Tareq Mahmood <tareqtms@yahoo.com>
5+
* Created at: 8/21/16 8:39 AM UTC+06:00
6+
*
7+
* @see https://shopify.dev/docs/api/admin-rest/2023-01/resources/gift-card-adjustment Shopify API Reference for Gift Card Adjustment
8+
* @note - requires gift_card_adjustments access scope enabled by Shopify Support
9+
*
10+
* @usage:
11+
*
12+
$shopify = \PHPShopify\ShopifySDK::config($config);
13+
14+
$gift_card_id = 88888888888;
15+
16+
$gift_card_adjustment_id = 999999999999;
17+
18+
// Get all gift card adjustments
19+
$shopify->GiftCard($gift_card_id)->Adjustment()->get();
20+
21+
// Get a single gift card adjustment
22+
$shopify->GiftCard($gift_card_id)->Adjustment($gift_card_adjustment_id)->get();
23+
24+
// Create a gift card adjustment
25+
$shopify->GiftCard($gift_card_id)->Adjustment()->post([
26+
'amount' => 5,
27+
'note' => 'Add 5ドル to gift card'
28+
]);
29+
*/
30+
31+
namespace PHPShopify;
32+
33+
34+
class GiftCardAdjustment extends ShopifyResource
35+
{
36+
/**
37+
* @inheritDoc
38+
*/
39+
protected $resourceKey = 'adjustment';
40+
}

‎lib/ShopifySDK.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
* @property-read Fulfillment $Fulfillment
9191
* @property-read FulfillmentService $FulfillmentService
9292
* @property-read GiftCard $GiftCard
93+
* @property-read GiftCardAdjustment $GiftCardAdjustment
9394
* @property-read InventoryItem $InventoryItem
9495
* @property-read InventoryLevel $InventoryLevel
9596
* @property-read Location $Location
@@ -140,6 +141,7 @@
140141
* @method FulfillmentService FulfillmentService(integer $id = null)
141142
* @method FulfillmentOrder FulfillmentOrder(integer $id = null)
142143
* @method GiftCard GiftCard(integer $id = null)
144+
* @method GiftCardAdjustment GiftCardAdjustment(integer $id = null)
143145
* @method InventoryItem InventoryItem(integer $id = null)
144146
* @method InventoryLevel InventoryLevel(integer $id = null)
145147
* @method Location Location(integer $id = null)
@@ -261,6 +263,7 @@ class ShopifySDK
261263
'Dispute' => 'ShopifyPayment',
262264
'Fulfillment' => 'Order',
263265
'FulfillmentEvent' => 'Fulfillment',
266+
'GiftCardAdjustment'=> 'GiftCard',
264267
'OrderRisk' => 'Order',
265268
'Payouts' => 'ShopifyPayment',
266269
'ProductImage' => 'Product',

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /