woocommerce-arcavis-shop.php
## This function will run at the time of plugin activation set up cron, custom database tables..
This function will run at the time of plugin activation set up cron, custom database tables
This function will run at the time of plugin activation set up cron custom database tables
public function activation_tasks(){    	
		if ( ! wp_next_scheduled('arcavis_schedule_api_hook' )) {
			wp_schedule_event( time(), 'arcavis_minutes', 'arcavis_schedule_api_hook' );			
		}
		global $wpdb;
		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
		$table_name = $wpdb->prefix .'lastSyncTicks';
		$charset_collate = $wpdb->get_charset_collate();
		$sql = "CREATE TABLE $table_name (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			apiName varchar(255) NOT NULL,
			lastSync bigint(20) NOT NULL,
			updated timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
			UNIQUE KEY id (id)
		) $charset_collate;";
		dbDelta( $sql );
		$checkSyncApi = $wpdb->get_results("SELECT * FROM ".$table_name." WHERE apiName = 'articles' OR apiName = 'vouchers' OR apiName = 'articlestocks'",OBJECT);
		if(empty($checkSyncApi)){
			$wpdb->insert($table_name, array( 'apiName' => 'articles', 'lastSync' => '' , 'updated' => '' ));
			$wpdb->insert($table_name, array( 'apiName' => 'vouchers', 'lastSync' => '' , 'updated' => '' ));
			$wpdb->insert($table_name, array( 'apiName' => 'articlestocks', 'lastSync' => '' , 'updated' => '' ));
		}
		$table_name2 = $wpdb->prefix .'lastSyncPage';
		$sql2 = "CREATE TABLE $table_name2 (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			lastPage int(11) NOT NULL,
			UNIQUE KEY id (id)
		) $charset_collate;";
		dbDelta( $sql2 );
		$checkSyncPage = $wpdb->get_results("SELECT * FROM ".$table_name2,OBJECT);
		if(empty($checkSyncPage)){
			$wpdb->insert($table_name2, array( 'lastPage' => '1'));
		}
		$table_name3 = $wpdb->prefix .'applied_vouchers';
		$sql3 = "CREATE TABLE $table_name3 (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			session_id varchar(255) NOT NULL,
			voucher_code varchar(255) NOT NULL,
			discount_amount varchar(255) NOT NULL,
			discount_type varchar(255) NOT NULL,
			transaction_response longtext NOT NULL,
			UNIQUE KEY id (id)
		) $charset_collate;";
		dbDelta( $sql3 );
		$table_name4 = $wpdb->prefix .'arcavis_logs';
		$sql4 = "CREATE TABLE $table_name4 (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			date datetime NOT NULL,
			level varchar(10) NOT NULL,
			message longtext NULL,
			UNIQUE KEY id (id)
		) $charset_collate;";
		dbDelta( $sql4 );
	}
public function activation_tasks ( ) { if ( ! wp_next_scheduled ( 'arcavis_schedule_api_hook' ) ) { wp_schedule_event ( time ( ) , 'arcavis_minutes' , 'arcavis_schedule_api_hook' ) ; } global $ wpdb ; require_once ABSPATH . 'wp-admin/includes/upgrade.php' ; $ table_name = $ wpdb -> prefix . 'lastSyncTicks' ; $ charset_collate = $ wpdb -> get_charset_collate ( ) ; $ sql = " CREATE TABLE  $ table_name  (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			apiName varchar(255) NOT NULL,
			lastSync bigint(20) NOT NULL,
			updated timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
			UNIQUE KEY id (id)
		)  $ charset_collate ; " ; dbDelta ( $ sql ) ; $ checkSyncApi = $ wpdb -> get_results ( " SELECT * FROM  " . $ table_name . "  WHERE apiName = 'articles' OR apiName = 'vouchers' OR apiName = 'articlestocks' " , OBJECT ) ; if ( empty ( $ checkSyncApi ) ) { $ wpdb -> insert ( $ table_name , array ( 'apiName' => 'articles' , 'lastSync' => '' , 'updated' => '' ) ) ; $ wpdb -> insert ( $ table_name , array ( 'apiName' => 'vouchers' , 'lastSync' => '' , 'updated' => '' ) ) ; $ wpdb -> insert ( $ table_name , array ( 'apiName' => 'articlestocks' , 'lastSync' => '' , 'updated' => '' ) ) ; } $ table_name2 = $ wpdb -> prefix . 'lastSyncPage' ; $ sql2 = " CREATE TABLE  $ table_name2  (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			lastPage int(11) NOT NULL,
			UNIQUE KEY id (id)
		)  $ charset_collate ; " ; dbDelta ( $ sql2 ) ; $ checkSyncPage = $ wpdb -> get_results ( " SELECT * FROM  " . $ table_name2 , OBJECT ) ; if ( empty ( $ checkSyncPage ) ) { $ wpdb -> insert ( $ table_name2 , array ( 'lastPage' => '1' ) ) ; } $ table_name3 = $ wpdb -> prefix . 'applied_vouchers' ; $ sql3 = " CREATE TABLE  $ table_name3  (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			session_id varchar(255) NOT NULL,
			voucher_code varchar(255) NOT NULL,
			discount_amount varchar(255) NOT NULL,
			discount_type varchar(255) NOT NULL,
			transaction_response longtext NOT NULL,
			UNIQUE KEY id (id)
		)  $ charset_collate ; " ; dbDelta ( $ sql3 ) ; $ table_name4 = $ wpdb -> prefix . 'arcavis_logs' ; $ sql4 = " CREATE TABLE  $ table_name4  (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			date datetime NOT NULL,
			level varchar(10) NOT NULL,
			message longtext NULL,
			UNIQUE KEY id (id)
		)  $ charset_collate ; " ; dbDelta ( $ sql4 ) ; }
This function will run at the time of plugin activation set up cron, custom database tables..
This function will run at the time of plugin activation set up cron custom database tables ..
// Logger