PluginProbe
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / 4.17.3
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress v4.17.3
4.17.3 4.17.2 4.17.1 4.17.0 4.16.19 4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 All 220 releases
wp-user-avatar / src / Membership / Models / Order / OrderFactory.php
OrderFactory.php
61 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ProfilePress\Core\Membership\Models\Order;
4
5 use ProfilePress\Core\Membership\Models\FactoryInterface;
6 use ProfilePress\Core\Membership\Repositories\OrderRepository;
7
8 class OrderFactory implements FactoryInterface
9 {
10 /**
11 * @param $data
12 *
13 * @return OrderEntity
14 */
15 public static function make($data)
16 {
17 return new OrderEntity($data);
18 }
19
20 /**
21 * @param $id
22 *
23 * @return OrderEntity
24 */
25 public static function fromId($id)
26 {
27 return ppress_cache_transform('order_factory_from_id_' . $id, function () use ($id) {
28 return OrderRepository::init()->retrieve(absint($id));
29 });
30 }
31
32 /**
33 * @param $id
34 *
35 * @return OrderEntity|false
36 */
37 public static function fromTransactionId($id)
38 {
39 $orders = OrderRepository::init()->retrieveBy([
40 'transaction_id' => $id
41 ]);
42
43 if ( ! empty($orders)) return $orders[0];
44
45 return false;
46 }
47
48 /**
49 * @param $order_key
50 *
51 * @return OrderEntity
52 */
53 public static function fromOrderKey($order_key)
54 {
55 $order_key = sanitize_text_field($order_key);
56
57 return ppress_cache_transform('order_factory_from_order_key_' . $order_key, function () use ($order_key) {
58 return OrderRepository::init()->retrieveByOrderKey($order_key);
59 });
60 }
61 }