phpclassic / php-shopify

PHP SDK for Shopify API
Apache License 2.0
568 stars 211 forks source link

Gift Card Adjustment Resource #299

Closed whobutsb closed 1 year ago

whobutsb commented 1 year ago

Added the Gift Card Adjustment Resource to list adjustments and increment and decrement amounts on gift cards.

This is a Shopify Plus only feature and requires you to contact Shopify Support to enable the gift_card_adjustments access scope.

API Documentation - https://shopify.dev/docs/api/admin-rest/2023-01/resources/gift-card-adjustment

Usage

$config = array(
    'ShopUrl' => 'my-store.myshopify.com',
    'AccessToken' => 'shpat_999999999999999999999'
);

$shopify = \PHPShopify\ShopifySDK::config($config);

$gift_card_id = 88888888888;

$gift_card_adjustment_id = 999999999999;

// Get all gift card adjustments
$shopify->GiftCard($gift_card_id)->Adjustment()->get();

// Get a single gift card adjustment
$shopify->GiftCard($gift_card_id)->Adjustment($gift_card_adjustment_id)->get();

// Create a gift card adjustment
$shopify->GiftCard($gift_card_id)->Adjustment()->post([
    'amount' => 5,
    'note' => 'Add $5 to gift card'
]);

PS - Could you also please consider - https://github.com/phpclassic/php-shopify/pull/276 😃

tareqtms commented 1 year ago

@whobutsb Regarding #276, Pls check my review comments.