# subscription/1.4.0/includes/Installer.php

Subscriptions for WooCommerce with Stripe Recurring Payments, version 1.4.0. 89 lines.

- Page: https://pluginprobe.com/plugins/subscription/1.4.0/code/includes/Installer.php
- Raw: https://pluginprobe.com/plugins/subscription/1.4.0/raw/includes/Installer.php
- Modified: 2025-05-13T13:45:08+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/subscription/1.4.0/code/includes/Installer.php#L10-L20`.

```php
<?php

namespace SpringDevs\Subscription;

/**
 * Class Installer
 *
 * @package SpringDevs\Subscription
 */
class Installer {

    /**
     * Run the installer
     *
     * @return void
     */
    public function run() {
        $this->add_version();
        $this->register_schedules();
        $this->create_tables();
    }

    /**
     * Add time and version on DB
     */
    public function add_version() {
        $installed = get_option( 'subscrpt_installed' );

        if ( ! $installed ) {
            update_option( 'subscrpt_installed', time() );
        }

        update_option( 'subscrpt_version', WP_SUBSCRIPTION_VERSION );

        update_option( 'subscrpt_manual_renew_cart_notice', 'Subscriptional product added to cart. Please complete the checkout to renew subscription.' );
    }

    /**
     * Register cron events.
     *
     * @return void
     */
    public function register_schedules() {
        if ( ! wp_next_scheduled( 'subscrpt_daily_cron' ) ) {
            wp_schedule_event( time(), 'daily', 'subscrpt_daily_cron' );
        }

        if ( ! wp_next_scheduled( 'subscrpt_renew_reminder_cron' ) ) {
            wp_schedule_event( time(), 'daily', 'subscrpt_renew_reminder_cron' );
        }
    }

    /**
     * Create necessary database tables
     *
     * @return void
     */
    public function create_tables() {
        if ( ! function_exists( 'dbDelta' ) ) {
            require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        }

        $this->create_histories_table();
    }

    /**
     * Create histories table
     *
     * @return void
     */
    public function create_histories_table() {
        global $wpdb;

        $charset_collate = $wpdb->get_charset_collate();
        $table_name      = $wpdb->prefix . 'subscrpt_order_relation';

        $schema = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
                      `id` INT(255) NOT NULL AUTO_INCREMENT,
                      `subscription_id` INT(100) NOT NULL,
                      `order_id` INT(100) NOT NULL,
                      `order_item_id` INT(100) NOT NULL,
                      `type` VARCHAR(50) NOT NULL,
                      PRIMARY KEY (`id`)
                    ) $charset_collate";

        dbDelta( $schema );
    }
}

```
