# fluent-cart/1.3.20/app/Events/Subscription/SubscriptionEOT.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.3.20. 74 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.3.20/code/app/Events/Subscription/SubscriptionEOT.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.3.20/raw/app/Events/Subscription/SubscriptionEOT.php
- Modified: 2026-04-07T13:41:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.3.20/code/app/Events/Subscription/SubscriptionEOT.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Events\Subscription;

use FluentCart\App\Events\EventDispatcher;
use FluentCart\App\Models\Order;
use FluentCart\App\Models\Subscription;

class SubscriptionEOT extends EventDispatcher
{

    public string $hook = 'fluent_cart/subscription_eot';
    protected array $listeners = [];

    /**
     * @var Subscription
     */
    public Subscription $subscription;

    /**
     * @var Order
     */
    public Order $order;

    public function __construct(Subscription $subscription, Order $order)
    {
        $this->subscription = $subscription;
        $this->order = $order;
        $this->order->load('customer');
    }


    public function toArray(): array
    {
        return [
            'subscription' => $this->subscription,
            'order'        => $this->order,
            'customer'     => $this->order->customer ?? [],
        ];
    }

    public function beforeDispatch()
    {
        $result = $this->subscription->cancelRemoteSubscription([
            'reason'     => 'end_of_term',
            'fire_hooks' => false
        ]);

        if (is_wp_error($result)) {
            fluent_cart_add_log(
                'Remote subscription cancellation failed on EOT',
                'Subscription #' . $this->subscription->id . ': ' . $result->get_error_message(),
                'error',
                [
                    'module' => 'subscription',
                    'module_id' => $this->subscription->id
                ]
            );
        }
    }

    public function getActivityEventModel()
    {
        return $this->subscription;
    }

    public function shouldCreateActivity(): bool
    {
        return true;
    }

}


```
