PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Events / Order / OrderCreated.php

OrderCreated.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Events/Order/OrderCreated.php

67 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Events\Order;
4
5 use FluentCart\App\Events\EventDispatcher;
6 use FluentCart\App\Listeners;
7 use FluentCart\App\Models\Customer;
8 use FluentCart\App\Models\Order;
9 use FluentCart\App\Models\OrderTransaction;
10 use FluentCart\Framework\Support\Str;
11 use ReflectionClass;
12
13 class OrderCreated extends EventDispatcher
14 {
15 public string $hook = 'fluent_cart/order_created';
16 protected array $listeners = [
17 Listeners\Order\OrderCreated::class,
18 // Listeners\UpdateStock::class,
19 ];
20
21 /**
22 * @var Order $order
23 */
24 public Order $order;
25
26 /**
27 * @var Order|null $prevOrder
28 */
29 public ?Order $prevOrder;
30
31 /**
32 * @var Customer|null $customer
33 */
34 public ?Customer $customer;
35
36 /**
37 * @var OrderTransaction|null $transaction
38 */
39 public ?OrderTransaction $transaction;
40
41 public function __construct($order, $prevOrder = null, $customer = null, $transaction = null)
42 {
43 $this->order = $order;
44 $this->prevOrder = $prevOrder;
45 $this->order->load('customer','shipping_address','billing_address');
46 $this->customer = $customer;
47 $this->transaction = $transaction;
48 }
49
50
51 public function toArray(): array
52 {
53 return [
54 'order' => $this->order,
55 'prev_order' => $this->prevOrder,
56 'customer' => $this->customer ?? [],
57 'transaction' => $this->transaction ?? []
58 ];
59 }
60
61 public function getActivityEventModel()
62 {
63 return $this->order;
64 }
65
66 }
67