PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.3.1
Subscriptions for WooCommerce with Stripe Recurring Payments v1.3.1
2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
subscription / includes / Installer.php

Installer.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.3.1, at includes/Installer.php

77 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SpringDevs\Subscription;
4
5 /**
6 * Class Installer
7 *
8 * @package SpringDevs\Subscription
9 */
10 class Installer {
11
12 /**
13 * Run the installer
14 *
15 * @return void
16 */
17 public function run() {
18 $this->add_version();
19 $this->create_tables();
20 }
21
22 /**
23 * Add time and version on DB
24 */
25 public function add_version() {
26 $installed = get_option( 'subscrpt_installed' );
27
28 if ( ! $installed ) {
29 update_option( 'subscrpt_installed', time() );
30 }
31
32 update_option( 'subscrpt_version', SUBSCRPT_VERSION );
33
34 if ( ! wp_next_scheduled( 'subscrpt_daily_cron' ) ) {
35 wp_schedule_event( time(), 'daily', 'subscrpt_daily_cron' );
36 }
37
38 update_option( 'subscrpt_manual_renew_cart_notice', 'Subscriptional product added to cart. Please complete the checkout to renew subscription.' );
39 }
40
41 /**
42 * Create necessary database tables
43 *
44 * @return void
45 */
46 public function create_tables() {
47 if ( ! function_exists( 'dbDelta' ) ) {
48 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
49 }
50
51 $this->create_histories_table();
52 }
53
54 /**
55 * Create histories table
56 *
57 * @return void
58 */
59 public function create_histories_table() {
60 global $wpdb;
61
62 $charset_collate = $wpdb->get_charset_collate();
63 $table_name = $wpdb->prefix . 'subscrpt_order_relation';
64
65 $schema = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
66 `id` INT(255) NOT NULL AUTO_INCREMENT,
67 `subscription_id` INT(100) NOT NULL,
68 `order_id` INT(100) NOT NULL,
69 `order_item_id` INT(100) NOT NULL,
70 `type` VARCHAR(50) NOT NULL,
71 PRIMARY KEY (`id`)
72 ) $charset_collate";
73
74 dbDelta( $schema );
75 }
76 }
77