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

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

53 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 FluentCart\App\Events;
4
5 use FluentCart\App\Events\EventDispatcher;
6 use FluentCart\App\Listeners;
7 use FluentCart\App\Models\Order;
8 use FluentCart\App\Models\ProductVariation;
9
10 class PlanChanged extends EventDispatcher
11 {
12
13 public string $hook = 'fluent_cart/plan_changed';
14 protected array $listeners = [];
15
16 public Order $order;
17 public ProductVariation $newVariation;
18 public ProductVariation $oldVariation;
19 public array $otherInfo = [];
20
21
22 public function __construct(Order $order, ProductVariation $newVariation, ProductVariation $oldVariation, $otherInfo = null)
23 {
24 $this->order = $order;
25 $this->newVariation = $newVariation;
26 $this->oldVariation = $oldVariation;
27 $this->otherInfo = is_array($otherInfo) ? $otherInfo : [];
28
29 // Load necessary relationships
30 $this->order->load('customer', 'shipping_address', 'billing_address');
31 }
32
33 public function toArray(): array
34 {
35 return [
36 'order' => $this->order->toArray(),
37 'customer' => $this->order->customer ? $this->order->customer->toArray() : [],
38 'new_variation' => $this->newVariation->toArray(),
39 'old_variation' => $this->oldVariation->toArray(),
40 'other_info' => $this->otherInfo
41 ];
42 }
43
44 public function getActivityEventModel()
45 {
46 return null;
47 }
48
49 public function shouldCreateActivity(): bool
50 {
51 return false;
52 }
53 }