Example #1
0
    /**
     * Post deleted
     * 
     * @access public
     * @param int $post_id
     * @return void
     */
    public function post_deleted($post_id)
    {
        global $post_type;

        if ($post_type != 'subscription') {
            return;
        }

        // Unschedule all events
        Subscriptio_Scheduler::unschedule_all($post_id);

        // Write to transaction log
        $transaction = new Subscriptio_Transaction(null, 'subscription_deleted', $post_id);
        $transaction->update_result('success');
        $transaction->update_note(__('Subscription manually deleted by administrator.', 'subscriptio'));
    }
    /**
     * Expire subscription
     * 
     * @access public
     * @return void
     */
    public function expire()
    {
        $old_status = $this->status;

        // Change subscription status
        $this->update_subscription_details(array(
            'status'            => 'expired',
            'expired_since'     => time(),
        ));

        // Clear payment due and expires dates
        $this->clear_subscription_details(array(
            'payment_due',
            'payment_due_readable',
            'expires',
            'expires_readable',
            'overdue_since',
            'pre_paused_status',
            'pre_paused_events',
            'paused_since',
            'suspended_since',
        ));

        // Clear any other scheduled events
        Subscriptio_Scheduler::unschedule_all($this->id);

        // Fire actions hooks
        $this->on_status_change($old_status, 'expired');

        // Send notifications
        Subscriptio_Mailer::send('expired', $this);
    }