PluginProbe
Sendy / 3.0
Sendy v3.0
3.4.6 3.4.7 trunk 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 All 32 releases
sendy / src / Repositories / Shops.php

Shops.php in Sendy 3.0, at src/Repositories/Shops.php

36 lines 844 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sendy\WooCommerce\Repositories;
4
5 class Shops extends Repository
6 {
7 /**
8 * Returns a map of shops
9 *
10 * The shops are stored in the transient for the duration of one hour. The results from the API are transformed to
11 * a map of shops with the UUID as key and the name as value.
12 *
13 * @return array
14 * @throws \GuzzleHttp\Exception\GuzzleException
15 * @throws \Sendy\Api\ApiException
16 */
17 public function list(): array
18 {
19 $shops = get_transient('sendy_shops');
20
21 if (! $shops) {
22 $result = $this->connection->shop->list();
23
24 $shops = [];
25
26 foreach ($result as $shop) {
27 $shops[$shop['uuid']] = $shop['name'];
28 }
29
30 set_transient('sendy_shops', $shops, 3600);
31 }
32
33 return $shops;
34 }
35 }
36