1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
<?php
namespace Onlineforce\Woocommerce_Izettle;
use \Onlineforce\Woocommerce_Izettle\Woocommerce_Izettle_Cron;
class Woocommerce_Izettle_Activator {
public static function activate() {
Woocommerce_Izettle_Cron::init_cron_task();
self::create_tables();
}
public static function create_tables() {
global $wpdb;
$table_name = $wpdb->prefix . 'woocommerce_izettle_products';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
product_uuid varchar(48) NOT NULL,
variant_uuid varchar(48) NOT NULL,
woocommerce_id int NOT NULL,
PRIMARY KEY (product_uuid, variant_uuid)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
update_option( '_woocommerce_izettle_db_version', '1.0' );
}
}