PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.10.2
Subscriptions for WooCommerce with Stripe Recurring Payments v1.10.2
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.10.2, at includes/Installer.php

88 lines 1.9 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 use SpringDevs\Subscription\Illuminate\Gateways\Paypal\PaypalDB;
6
7 /**
8 * Class Installer
9 *
10 * @package SpringDevs\Subscription
11 */
12 class Installer {
13
14 /**
15 * Run the installer
16 *
17 * @return void
18 */
19 public function run() {
20 $this->add_version();
21 $this->register_schedules();
22 $this->create_tables();
23 }
24
25 /**
26 * Add time and version on DB
27 */
28 public function add_version() {
29 $installed = get_option( 'subscrpt_installed' );
30
31 if ( ! $installed ) {
32 update_option( 'subscrpt_installed', time() );
33 }
34
35 update_option( 'subscrpt_version', SUBSCRPT_VERSION );
36
37 update_option( 'subscrpt_manual_renew_cart_notice', 'Subscriptional product added to cart. Please complete the checkout to renew subscription.' );
38 }
39
40 /**
41 * Register cron events.
42 *
43 * @return void
44 */
45 public function register_schedules() {
46 if ( ! wp_next_scheduled( 'subscrpt_hourly_cron' ) ) {
47 wp_schedule_event( strtotime( 'tomorrow midnight' ), 'hourly', 'subscrpt_hourly_cron' );
48 }
49 }
50
51 /**
52 * Create necessary database tables
53 *
54 * @return void
55 */
56 public function create_tables() {
57 if ( ! function_exists( 'dbDelta' ) ) {
58 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
59 }
60
61 $this->create_histories_table();
62 PaypalDB::maybe_create_tables();
63 }
64
65 /**
66 * Create histories table
67 *
68 * @return void
69 */
70 public function create_histories_table() {
71 global $wpdb;
72
73 $charset_collate = $wpdb->get_charset_collate();
74 $table_name = $wpdb->prefix . 'subscrpt_order_relation';
75
76 $schema = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
77 `id` INT(255) NOT NULL AUTO_INCREMENT,
78 `subscription_id` INT(100) NOT NULL,
79 `order_id` INT(100) NOT NULL,
80 `order_item_id` INT(100) NOT NULL,
81 `type` VARCHAR(50) NOT NULL,
82 PRIMARY KEY (`id`)
83 ) $charset_collate";
84
85 dbDelta( $schema );
86 }
87 }
88