PHPackages                             concretecms-community-store/community\_store\_api\_client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. concretecms-community-store/community\_store\_api\_client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

concretecms-community-store/community\_store\_api\_client
=========================================================

A client for Community Store API

1.0.0(2y ago)11791MITPHPPHP &gt;= 7.4

Since Jan 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/concretecms-community-store/community_store_api_client)[ Packagist](https://packagist.org/packages/concretecms-community-store/community_store_api_client)[ Docs](https://github.com/concretecms-community-store/community_store_api_client)[ RSS](/packages/concretecms-community-store-community-store-api-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Community Store API Client
==========================

[](#community-store-api-client)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

This project contains a library that makes it easy to use the [Community Store API](https://github.com/concretecms-community-store/community_store_api).

You can use it in concrete5 v8 and in ConcreteCMS v9+ projects, as well as in custom (non concrete) projects.

Installation
------------

[](#installation)

### With [Composer](https://getcomposer.org)

[](#with-composer)

Simply add the `concretecms-community-store/community_store_api_client` dependency:

```
composer require concretecms-community-store/community_store_api_client
```

### Without [Composer](https://getcomposer.org)

[](#without-composer)

Download this repository somewhere and include the `register.php` file.

For example, if your local copy of this project is available at `/path/to/community_store_api_client`, add this line in your PHP files:

```
require_once '/path/to/community_store_api_client/register.php';
```

Usage
-----

[](#usage)

### Creating the Client instance

[](#creating-the-client-instance)

You need the base URL of your website, as well as the client ID and client secret.

```
$baseURL = 'http://www.yoursite.com';
$clientID = 'your-client-id';
$clientSecret = 'your-client-secret';
```

You also need to tell the client the scopes you need:

```
use CommunityStore\APIClient\Scope;

$scopes = [
    Scope::CONFIG_READ,
    Scope::PRODUCTS_READ,
    Scope::PRODUCTS_WRITE,
    Scope::ORDERS_READ,
    Scope::ORDERS_WRITE,
];
```

#### In a concrete5/ConcreteCMS environment

[](#in-a-concrete5concretecms-environment)

```
use CommunityStore\APIClient\Client;

$app = app();

$client = new Client(
    $baseURL
    $clientID,
    $clientSecret,
    $scopes,
    $app->make('http/client'),
    $app->make('cache/expensive')
);
```

#### Not in a concrete5/ConcreteCMS environment

[](#not-in-a-concrete5concretecms-environment)

In this case, you need the [Guzzle HTTP Client library](https://docs.guzzlephp.org):

```
use CommunityStore\APIClient\Client;
use GuzzleHttp\Client as GuzzleClient;

$client = new Client(
    $baseURL
    $clientID,
    $clientSecret,
    $scopes,
    new GuzzleClient()
);
```

### Retrieving the Community Store configuration

[](#retrieving-the-community-store-configuration)

```
$configuration = $client->getConfiguration();

echo 'Currency code: ', $configuration->currency->code, "\n";
echo 'Currency symbol: ', $configuration->currency->symbol, "\n";
echo 'Currency decimal digits: ', $configuration->currency->decimalDigits, "\n";
```

Sample output:

```
Currency code: EUR
Currency symbol: €
Currency decimal digits: 2

```

### Retrieving the defined fulfilment satuses

[](#retrieving-the-defined-fulfilment-satuses)

```
$statuses = $client->getFulfilmentStatuses();

echo 'Number of statuses: ', count($statuses), "\n";
echo 'ID of first status: ', $statuses[0]->id, "\n";
echo 'Handle of first status: ', $statuses[0]->handle, "\n";
echo 'Name of first status: ', $statuses[0]->name, "\n";
```

Sample output:

```
Number of statuses: 6
ID of first status: 1
Handle of first status: incomplete
Name of first status: Awaiting Processing

```

### Retrieving an order given its ID

[](#retrieving-an-order-given-its-id)

```
foreach ([123456, 11] as $id) {
    $order = $client->getOrder($id);
    if ($order === null) {
        echo "Order with ID {$id} could not be found\n\n";
        continue;
    }
    echo 'Order ID: ', $order->id, "\n";
    echo 'Date placed: ', $order->datePlaced->format('c'), "\n";
    echo 'Total: ', $order->total, "\n";
    echo 'Payment method: ', $order->paymentMethodName, "\n";
    echo 'Payment date: ', $order->paymentDate === null ? 'n/a' : $order->paymentDate->format('c'), "\n";
    echo 'Payment reference: ', $order->paymentReference, "\n";
    echo 'Shipping method: ', $order->shippingMethodName, "\n";
    echo 'Fulfilment status name: ', $order->fulfilment->statusName, "\n";
    echo 'Fulfilment status handle: ', $order->fulfilment->statusHandle, "\n";
    echo 'Tracking ID: ', $order->fulfilment->trackingID, "\n";
    echo 'Tracking code: ', $order->fulfilment->trackingCode, "\n";
    echo 'Tracking url: ', $order->fulfilment->trackingURL, "\n";
    echo 'Language: ', $order->locale, "\n";
    echo 'Customer email: ', $order->customer->email, "\n";
    echo 'Customer user name: ', $order->customer->username, "\n";
    echo 'Billing first name: ', $order->customer->billing->firstName, "\n";
    echo 'Billing last name: ', $order->customer->billing->lastName, "\n";
    echo 'Billing company: ', $order->customer->billing->company, "\n";
    echo 'Billing address line 1: ', $order->customer->billing->address->address1, "\n";
    echo 'Billing city: ', $order->customer->billing->address->city, "\n";
    echo 'Billing state/province: ', $order->customer->billing->address->stateProvince, "\n";
    echo 'Billing country code: ', $order->customer->billing->address->country, "\n";
    echo 'Billing postal code: ', $order->customer->billing->address->postalCode, "\n";
    echo 'Billing phone: ', $order->customer->billing->phone, "\n";
    echo 'Billing VAT: ', $order->customer->billing->vatNumber, "\n";
    echo 'Shipping first name: ', $order->customer->shipping->firstName, "\n";
    echo 'Shipping last name: ', $order->customer->shipping->lastName, "\n";
    echo 'Shipping company: ', $order->customer->shipping->company, "\n";
    echo 'Shipping address line 1: ', $order->customer->shipping->address->address1, "\n";
    echo 'Shipping city: ', $order->customer->shipping->address->city, "\n";
    echo 'Shipping state/province: ', $order->customer->shipping->address->stateProvince, "\n";
    echo 'Shipping country code: ', $order->customer->shipping->address->country, "\n";
    echo 'Shipping postal code: ', $order->customer->shipping->address->postalCode, "\n";
    echo 'Number of custom attributes: ', count($order->attributes), "\n";
    echo 'Refunded: ', $order->refunded === null ? 'no' : ('on ' . $order->refunded->date->format('c') . " ({$order->refunded->reason})"), "\n";
    echo 'Number of items: ', count($order->items), "\n";
    echo 'First item - ID: ', $order->items[0]->id, "\n";
    echo 'First item - name: ', $order->items[0]->name, "\n";
    echo 'First item - SKU: ', $order->items[0]->sku, "\n";
    echo 'First item - quantity: ', $order->items[0]->quantity, "\n";
    echo 'First item - price: ', $order->items[0]->price, "\n";
    echo 'First item - number of options: ', count($order->items[0]->options), "\n";
    echo 'First item - number of digital uploads: ', count($order->items[0]->uploads), "\n";
    echo "\n";
}
```

Sample output:

```
Order with ID 123456 could not be found

Order ID: 11
Date placed: 2024-01-23T16:34:42+01:00
Total: 123
Payment method: Invoice
Payment date: 2024-01-23T16:37:16+01:00
Payment reference:
Shipping method:
Fulfilment status name: Awaiting Processing
Fulfilment status handle: incomplete
Tracking ID:
Tracking code:
Tracking url:
Language: en_US
Customer email: john@doe.com
Customer user name: john
Billing first name: John
Billing last name: Doe
Billing company: JoeCo
Billing address line 1: 20, Ocrean Street
Billing city: New York
Billing state/province: NY
Billing country code: US
Billing postal code: 10001
Billing phone: +1234567
Billing VAT: US12345678
Shipping first name: Jane
Shipping last name: Doe
Shipping company: JaneDo
Shipping address line 1: 30, Lake Street
Shipping city: San Francisco
Shipping state/province: CA
Shipping country code: US
Shipping postal code: 94016
Number of custom attributes: 2
Refunded: no
Number of items: 1
First item - ID: 321
First item - name: Stormtrooper armor
First item - SKU: SW-ST-A
First item - quantity: 1
First item - price: 123
First item - number of options: 0
First item - number of digital uploads: 0

```

### Listing orders

[](#listing-orders)

Look for orders placed in the last 7 days, which are updaid and are awaiting processing:

```
use CommunityStore\APIClient\Entity\FulfilmentStatus;
use CommunityStore\APIClient\Query;
use CommunityStore\APIClient\Query\Orders\PaymentStatus;

$query = new Query\Orders();
$query->fromDate = new \DateTimeImmutable('-7 days');
$query->paymentStatus = PaymentStatus::INCOMPLETE;
$query->status = FulfilmentStatus::AWAITING_PROCESSING;

$orders = $client->getOrders($query, $pagination);
/** @var \CommunityStore\APIClient\Entity\Pagination $pagination */
while (true) {
    echo 'Found ', count($orders), ' orders in page ', $pagination->currentPage, "\n";
    $orders = $client->getNextOrders($pagination, $newPagination);
    if ($orders === []) {
        break;
    }
    $pagination = $newPagination;
}
```

Sample output:

```
Found 20 orders in page 1
Found 5 orders in page 2

```

### Updating an order

[](#updating-an-order)

Update the order with ID 5:

```
use CommunityStore\APIClient\Entity\FulfilmentStatus;
use CommunityStore\APIClient\Query\OrderPatch;

$patch = new OrderPatch(5);
$patch->fulfilment->trackingID = 'TRK-ID-001';
$patch->fulfilment->trackingCode = 'TRK-CODE-001';
$patch->fulfilment->trackingURL = 'https://www.carrier.com/?foo=bar';
$patch->fulfilment->status = FulfilmentStatus::SHIPPED;

$order = $client->updateOrder($patch);

echo "Order with ID {$order->id} has been updated.\n";
echo "Its status is now {$order->fulfilment->statusName}.\n";
```

Sample output:

```
Order with ID 5 has been updated.
Its status is now Shipped.

```

### Product related operations

[](#product-related-operations)

Still to be implemented.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

835d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e9d7ece045fc89575e083ee4852edf31218df403c84f41a0de01863dae982f5?d=identicon)[mlocati](/maintainers/mlocati)

![](https://www.gravatar.com/avatar/e535a56a22133af1f2a459534bfdddc57863a5df0d5fd833374eceff563ac2e2?d=identicon)[Mesuva](/maintainers/Mesuva)

---

Top Contributors

[![mlocati](https://avatars.githubusercontent.com/u/928116?v=4)](https://github.com/mlocati "mlocati (4 commits)")

---

Tags

apiclientrestconcrete5concreteCMSstoreconcreteCommunity Store

### Embed Badge

![Health badge](/badges/concretecms-community-store-community-store-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/concretecms-community-store-community-store-api-client/health.svg)](https://phpackages.com/packages/concretecms-community-store-community-store-api-client)
```

###  Alternatives

[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69114.3k](/packages/serpapi-google-search-results-php)[artesaos/laravel-linkedin

Linkedin API integration for Laravel and Lumen 5

5666.5k](/packages/artesaos-laravel-linkedin)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)[romanpitak/dotmailer-api-v2-client

Client library for the dotMailer v2 (REST) API.

21101.0k2](/packages/romanpitak-dotmailer-api-v2-client)[jsor/hal-client

A lightweight client for consuming and manipulating Hypertext Application Language (HAL) resources.

2425.9k1](/packages/jsor-hal-client)[jonathanraftery/bullhorn-rest-client

Simple REST client for the Bullhorn API, including automated OAuth2 login

1142.7k](/packages/jonathanraftery-bullhorn-rest-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
