Automattic\WooCommerce\Blocks
Installer::maybe_create_tables()
Set up the database tables which the plugin needs to function.
Method of the class: Installer{}
No Hooks.
Return
null
. Nothing (null).
Usage
$Installer = new Installer(); $Installer->maybe_create_tables();
Installer::maybe_create_tables() Installer::maybe create tables code WC 9.4.2
public function maybe_create_tables() { global $wpdb; $schema_version = 260; $db_schema_version = (int) get_option( 'wc_blocks_db_schema_version', 0 ); if ( $db_schema_version >= $schema_version && 0 !== $db_schema_version ) { return; } $show_errors = $wpdb->hide_errors(); $table_name = $wpdb->prefix . 'wc_reserved_stock'; $collate = $wpdb->has_cap( 'collation' ) ? $wpdb->get_charset_collate() : ''; $exists = $this->maybe_create_table( $wpdb->prefix . 'wc_reserved_stock', " CREATE TABLE {$wpdb->prefix}wc_reserved_stock ( `order_id` bigint(20) NOT NULL, `product_id` bigint(20) NOT NULL, `stock_quantity` double NOT NULL DEFAULT 0, `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`order_id`, `product_id`) ) $collate; " ); if ( $show_errors ) { $wpdb->show_errors(); } if ( ! $exists ) { return $this->add_create_table_notice( $table_name ); } // Update succeeded. This is only updated when successful and validated. // $schema_version should be incremented when changes to schema are made within this method. update_option( 'wc_blocks_db_schema_version', $schema_version ); }