PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.0.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.0.0
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
← All changes | includes/Installer.php +123 -1 1.11.22.0.0 View file →
@@ -15,9 +15,9 @@
15 15 * Database schema version. Bump whenever a custom table changes.
16 16 *
17 17 * @var string
18 18 */
19 - const DB_VERSION = '1.2.0';
19 + const DB_VERSION = '1.3.0';
20 20
21 21 /**
22 22 * Run the installer
23 23 *
@@ -83,8 +83,11 @@
83 83
84 84 $this->create_histories_table();
85 85 $this->create_stats_snapshot_table();
86 86 $this->create_cancellation_feedback_table();
87 + $this->create_plan_group_table();
88 + $this->create_plan_table();
89 + $this->create_plan_relation_table();
87 90 PaypalDB::maybe_create_tables();
88 91
89 92 update_option( 'subscrpt_db_version', self::DB_VERSION );
90 93 }
@@ -150,8 +153,127 @@
150 153 `created_at` DATETIME NOT NULL,
151 154 PRIMARY KEY (`id`),
152 155 KEY `subscription_id` (`subscription_id`),
153 156 KEY `created_at` (`created_at`)
157 + ) $charset_collate";
158 +
159 + dbDelta( $schema );
160 + }
161 +
162 + /**
163 + * Create the subscription plan group table.
164 + *
165 + * A plan group is a named, reusable subscription plan (e.g. "Premium
166 + * Membership") attached to one or more products. This is the free base
167 + * schema; Pro adds columns on top via versioned migrations keyed on
168 + * `subscrpt_db_version`.
169 + *
170 + * type: 1 = Subscribe & Save, 2 = Recurring, 3 = Installment (free writes 2).
171 + * product_type: 1 = specific products, 2 = taxonomy (free writes 1).
172 + * data: JSON (group-level settings).
173 + *
174 + * @return void
175 + */
176 + public function create_plan_group_table() {
177 + global $wpdb;
178 +
179 + $charset_collate = $wpdb->get_charset_collate();
180 + $table_name = $wpdb->prefix . 'subscrpt_plan_group';
181 +
182 + $schema = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
183 + `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
184 + `type` TINYINT(2) NOT NULL DEFAULT 2,
185 + `product_type` TINYINT(2) NOT NULL DEFAULT 1,
186 + `title` VARCHAR(255) NOT NULL DEFAULT '',
187 + `status` VARCHAR(20) NOT NULL DEFAULT 'active',
188 + `data` LONGTEXT NULL,
189 + `created_at` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
190 + `updated_at` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
191 + PRIMARY KEY (`id`),
192 + KEY `type` (`type`),
193 + KEY `status` (`status`)
194 + ) $charset_collate";
195 +
196 + dbDelta( $schema );
197 + }
198 +
199 + /**
200 + * Create the subscription plan (term) table.
201 + *
202 + * A plan is one billing term inside a group (e.g. "every 1 month"). There is
203 + * no price column — pricing lives per product on the relation.
204 + *
205 + * billing_interval: 1 = day, 2 = week, 3 = month, 4 = year.
206 + * billing_length: expiry in cycles, 0 = unlimited.
207 + * price_mode: snapshot (default) | live (free always snapshot).
208 + *
209 + * @return void
210 + */
211 + public function create_plan_table() {
212 + global $wpdb;
213 +
214 + $charset_collate = $wpdb->get_charset_collate();
215 + $table_name = $wpdb->prefix . 'subscrpt_plan';
216 +
217 + $schema = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
218 + `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
219 + `plan_group_id` BIGINT(20) UNSIGNED NOT NULL,
220 + `title` VARCHAR(255) NOT NULL DEFAULT '',
221 + `type` TINYINT(2) NOT NULL DEFAULT 2,
222 + `billing_frequency` INT(11) NOT NULL DEFAULT 1,
223 + `billing_interval` TINYINT(2) NOT NULL DEFAULT 3,
224 + `billing_length` INT(11) NOT NULL DEFAULT 0,
225 + `signup_fee` LONGTEXT NULL,
226 + `free_trial` VARCHAR(50) NOT NULL DEFAULT '',
227 + `prepaid` TINYINT(1) NOT NULL DEFAULT 0,
228 + `offer` LONGTEXT NULL,
229 + `price_mode` VARCHAR(20) NOT NULL DEFAULT 'snapshot',
230 + `status` VARCHAR(20) NOT NULL DEFAULT 'active',
231 + `data` LONGTEXT NULL,
232 + `created_at` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
233 + `updated_at` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
234 + PRIMARY KEY (`id`),
235 + KEY `plan_group_id` (`plan_group_id`),
236 + KEY `status` (`status`)
237 + ) $charset_collate";
238 +
239 + dbDelta( $schema );
240 + }
241 +
242 + /**
243 + * Create the subscription plan relation table.
244 + *
245 + * The many-to-many join between a plan term and a product, carrying the
246 + * per-product price in its `data` JSON.
247 + *
248 + * oid: product id (type 1) or term id (type 2).
249 + * vid: variation id; 0 for simple products (free always 0).
250 + * type: 1 = product, 2 = taxonomy.
251 + * data: JSON price override (regular_price, sale_price, discount_type,
252 + * discount_value).
253 + * exclude: per-row toggle to hide one term for one product.
254 + *
255 + * @return void
256 + */
257 + public function create_plan_relation_table() {
258 + global $wpdb;
259 +
260 + $charset_collate = $wpdb->get_charset_collate();
261 + $table_name = $wpdb->prefix . 'subscrpt_plan_relation';
262 +
263 + $schema = "CREATE TABLE IF NOT EXISTS `{$table_name}` (
264 + `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
265 + `plan_id` BIGINT(20) UNSIGNED NOT NULL,
266 + `oid` BIGINT(20) UNSIGNED NOT NULL,
267 + `vid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
268 + `type` TINYINT(2) NOT NULL DEFAULT 1,
269 + `data` LONGTEXT NULL,
270 + `exclude` TINYINT(1) NOT NULL DEFAULT 0,
271 + `status` VARCHAR(20) NOT NULL DEFAULT 'active',
272 + PRIMARY KEY (`id`),
273 + KEY `plan_id` (`plan_id`),
274 + KEY `plan_lookup` (`plan_id`,`type`,`oid`,`vid`),
275 + KEY `product_lookup` (`type`,`oid`,`vid`)
154 276 ) $charset_collate";
155 277
156 278 dbDelta( $schema );
157 279 }