-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti-currency-switcher.php
More file actions
89 lines (77 loc) · 2.83 KB
/
multi-currency-switcher.php
File metadata and controls
89 lines (77 loc) · 2.83 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* Plugin Name: Multi Currency Switcher
* Plugin URI: https://www.xfinitysoft.com
* Description: WooCommerce add on for multi currency.
* Author: Xfinity Soft
* Author URI: https://www.xfinitysoft.com/
*
* Version: 0.0.6
* Requires at least: 4.4.0
* Tested up to: 6.0
* WC requires at least: 4.0
* WC tested up to: 6.0
*
* Text Domain: xs-mcs
* Prefix xs-mcs
* Domain Path: /languages/
*
* @category Plugin
* @author Xfinity Soft
* @package xs-multi-currency-switcher
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; //Exit if accessed directly.
}
function xs_mcs_activation_hook(){
if ( !class_exists( 'WooCommerce' ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) );
wp_die( esc_html__( 'Multi Currency Switcher requires WooCommerce to run. Please install WooCommerce and activate before attempting to activate Advance WooCommerce Multi-Currency - Currency Switcher again.', 'xs-mcs' ) );
}
// Let the $wpdb global
global $wpdb;
$charset_collate = '';
$order_currencies_table = $wpdb->prefix . "xsmcs_order_currencies";
//Set Character Set
if(!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
}
// if not empty
if(!empty($wpdb->collate)) {
$charset_collate .= " COLLATE $wpdb->collate";
}
// Building the query. Creating table for Donations
if($wpdb->get_var("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA='{$wpdb->dbname}' AND TABLE_NAME = '{$order_currencies_table}'")!=$order_currencies_table){
$order_currencies_table_query = "CREATE TABLE $order_currencies_table (
id int(10) NOT NULL AUTO_INCREMENT,
order_id int(10) NOT NULL,
order_currency varchar(4) NOT NULL,
currency_value float(10) NOT NULL,
order_total_exc_fee float(10) NOT NULL,
order_total_inc_fee float(10) NOT NULL,
exchange_fee float(10) NULL,
order_total_1_exc_fee float(10) NULL,
order_total_1_inc_fee float(10) NULL,
exchange_fee_1 float(10) NULL,
PRIMARY KEY (id)
) $charset_collate;";
// Executing the query
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
// Execute the query one by one
dbDelta($order_currencies_table_query);
}
}
register_activation_hook(__FILE__, 'xs_mcs_activation_hook');
// Defining Constants
define('XSMCS_ROOT_FILE', __FILE__);
define('XSMCS_ROOT_PATH', dirname(__FILE__));
define('XSMCS_ROOT_URL', plugins_url('', __FILE__));
define('XSMCS_PLUGIN_VERSION', '0.0.1');
define('XSMCS_PLUGIN_SLUG', basename(dirname(__FILE__)));
define('XSMCS_PLUGIN_BASE', plugin_basename(__FILE__));
// including plugin main file
if ( ! class_exists( 'XSMultiCurrency' ) ) {
require XSMCS_ROOT_PATH . '/includes/class.xs-multi-currency.php';
}
$XSMultiCurrency = new XSMultiCurrency();
?>