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 / Subscription / SubscriptionCanceled.php

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

66 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
4 namespace FluentCart\App\Events\Subscription;
5
6 use FluentCart\App\Events\EventDispatcher;
7 use FluentCart\App\Listeners;
8 use FluentCart\App\Models\Customer;
9 use FluentCart\App\Models\Order;
10 use FluentCart\App\Models\Subscription;
11
12
13 class SubscriptionCanceled extends EventDispatcher
14 {
15 public string $hook = 'fluent_cart/subscription_canceled';
16 protected array $listeners = [
17
18 ];
19
20 /**
21 * @var Subscription $subscription
22 */
23 public Subscription $subscription;
24
25 /**
26 * @var Customer|null $customer
27 */
28 public ?Customer $customer;
29
30 /**
31 * @var Order|null $order
32 */
33 public ?Order $order;
34
35 public string $reason;
36
37 public function __construct($subscription, $order = null, $customer = null, $reason = '')
38 {
39 $this->subscription = $subscription;
40 $this->order = $order;
41 $this->customer = $customer;
42 $this->reason = $reason;
43 }
44
45
46 public function toArray(): array
47 {
48 return [
49 'subscription' => $this->subscription,
50 'order' => $this->order,
51 'customer' => $this->customer ?? [],
52 'reason' => $this->reason ?: __('canceled on customer request', 'fluent-cart'),
53 ];
54 }
55
56 public function getActivityEventModel(): Subscription
57 {
58 return $this->subscription;
59 }
60
61 public function shouldCreateActivity(): bool
62 {
63 return true;
64 }
65
66 }