<?php

/**
 * Fired during plugin activation.
 *
 * This class defines all code necessary to run during the plugin's activation.
 *
 * @since      1.0.0
 * @package    Mojito_Shipping
 * @author     Mojito Team <support@mojitowp.com>
 */

namespace Mojito_Shipping;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Desactivator class
 */
class Mojito_Shipping_Deactivator {

	/**
	 * Plugin deactivate.
	 *
	 * @since    1.0.0
	 */
	public static function deactivate() {

		mojito_shipping_debug( 'Plugin deactivated' );


		if ( ! class_exists( 'Mojito_Shipping\Mojito_Shipping_Address' ) ) {
			require_once MOJITO_SHIPPING_DIR . 'includes/class-mojito-shipping-address.php';
		}
		// Set CR as a default country/region on deactivation.
		update_option( 'woocommerce_default_country', 'CR' );

		
		if ( mojito_shipping_fs()->is__premium_only() && mojito_shipping_fs()->can_use_premium_code() ) {
			/**
			 * Clear cron jobs
			 */
			wp_clear_scheduled_hook( 'mojito-shipping-pymexpress-cron-control-check-ip' );
			wp_clear_scheduled_hook( 'mojito-shipping-pymexpress-cron-control-check-api' );
			wp_clear_scheduled_hook( 'mojito-shipping-pymexpress-cron-control-complete-orders' );
			wp_clear_scheduled_hook( 'mojito-shipping-pymexpress-cron-control-update-exchange-rate' );
			wp_clear_scheduled_hook( 'mojito-shipping-cron-ccr' );
			wp_clear_scheduled_hook( 'mojito-shipping-cron-pymexpress' );
			wp_clear_scheduled_hook( 'mojito-shipping-cron-mojito-proxy-ip-check' );
			wp_clear_scheduled_hook( 'mojito-shipping-cron-complete-orders' );
			wp_clear_scheduled_hook( 'mojito-shipping-cron-update-exchange-rate' );
		}

		// Clear data
		$address = new Mojito_Shipping_Address();
		$address->clear_pymexpress_locations();
	}

}
