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, 'effective_from' => 'immediately', ]); 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; } }