user3323476
user3323476

Reputation:

Shopify API - get discount codes in the store with PHP

With a Shopify API call I am able to get the product data, but I need a way to get the discount codes available in the store.

I need the script in PHP. Does anyone have an idea of how I can achieve this?

Upvotes: 1

Views: 2470

Answers (1)

Steph Sharp
Steph Sharp

Reputation: 11682

Maybe these similar questions will help you get started:

The first 2 links above mention this project on GitHub. It provides an example you might be able to use:

require 'shopify.php';
$api = new \Shopify\PrivateAPI('username', 'password', 'https://mystore.myshopify.com/admin');

...

$discounts = $api->doRequest('GET', 'discounts.json', $params);
if (isset($discounts->discounts)) {
    $coupons = $discounts->discounts;
    foreach ($coupons as $coupon) {
        print_r($coupon);
    }
}

Upvotes: 0

Related Questions