php-shopify icon indicating copy to clipboard operation
php-shopify copied to clipboard

DiscountCode resource

Open BeerBelly opened this issue 3 years ago • 2 comments

Hi,

I'm trying to figure out what's the correct way of adding a discount code for a known Price Rule? Something like this doesn't work...

` $updateInfo = array( "code" => $code );

$response = $shopify->DiscountCode(PRICE_RULE_ID)->post($updateInfo);

`

Thanks for the help!

BeerBelly avatar Sep 22 '22 13:09 BeerBelly

DiscountCode is child resource of PriceRule, it's should be

$updateInfo = array(
    "code" => $code
);

$response = $shopify->PriceRule(PRICE_RULE_ID)->DiscountCode->post($updateInfo);

nVuln avatar Oct 03 '22 09:10 nVuln

It looks like Shopify is getting away from using Price Rules.

There's a note on this page about it. Does anybody know why the php-shopify is crashing with you added "write_discounts, read_discounts" scope?

https://shopify.dev/api/admin-rest/2023-01/resources/discountcode

We recommend using the GraphQL Admin API to manage discounts. The Discount types available in the GraphQL Admin API are intended to replace the GraphQL Admin PriceRule object and REST Admin PriceRule and DiscountCode resources.

brianruff avatar Jan 21 '23 17:01 brianruff