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 / Preferences.php

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

36 lines 987 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 Preferences extends Repository
6 {
7 /**
8 * Returns a map of shipping preferences
9 *
10 * The preferences are stored in the transient for the duration of one hour. The results from the API are
11 * transformed to map of preferences with the UUID as key and the name as value.
12 *
13 * @return array<string,string>
14 * @throws \GuzzleHttp\Exception\GuzzleException
15 * @throws \Sendy\Api\ApiException
16 */
17 public function get(): array
18 {
19 $preferences = get_transient('sendy_shipping_preferences');
20
21 if (! $preferences) {
22 $result = $this->connection->shippingPreference->list();
23
24 $preferences = [];
25
26 foreach ($result as $preference) {
27 $preferences[$preference['uuid']] = $preference['name'];
28 }
29
30 set_transient('sendy_shipping_preferences', $preferences, 3600);
31 }
32
33 return $preferences;
34 }
35 }
36