prefix . 'aihello_inventory_countries';
$wpdb->query("DROP TABLE IF EXISTS $table_name");
unset ($_SESSION["aihello_usercountry"]);
unset ($_SESSION["aihello_currency_rate"]);
unset ($_SESSION["aihello_currency"]);
delete_option('wc_settings_aihello_enable');
delete_option('wc_settings_aihello_geolocationsapi');
delete_option('wc_settings_aihello_currency_switcher');
delete_option('wc_settings_aihello_currency_switcher_pos');
delete_option('wc_settings_aihello_specific_currencies');
delete_option('wc_settings_aihello_inventory_country');
}
//call activation
public function aihello_plugin_activate(){
global $wpdb;
//(sku, country, lat, lon, quantity, label)
$table_name = $wpdb->prefix . 'aihello_inventory_countries';
#Check to see if the table exists already, if not, then create it
$settings_aihello_api = sanitize_text_field('yes');
update_option('wc_settings_aihello_api',$settings_aihello_api);
if($wpdb->get_var( "show tables like '$table_name'" ) != $table_name)
{
$sql = "CREATE TABLE `". $table_name . "` (
`ID` INT(11) NOT NULL AUTO_INCREMENT ,
`sku` VARCHAR(128) NOT NULL ,
`label` VARCHAR(255) NOT NULL default '',
`country` VARCHAR(255) NOT NULL default '',
`quantity` INT(11) NOT NULL default '0',
`latitude` VARCHAR(255) NOT NULL ,
`longitude` VARCHAR(255) NOT NULL ,
PRIMARY KEY (`ID`))";
require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
dbDelta($sql);
}
}
/* Add a new settings tab to the WooCommerce settings tabs array. */
public function add_aihello_tab( $settings_tabs ) {
$settings_tabs['settings_tab_aihello'] = __( 'AiHello Settings', 'aihello-smart-ecommerce' );
return $settings_tabs;
}
/* Uses the WooCommerce admin fields API to output settings via the @see woocommerce_admin_fields() function.
*
* @uses woocommerce_admin_fields()
* @uses self::get_settings()
*/
public function aihello_tab() {
woocommerce_admin_fields( self::get_aihello_settings() );
}
/**
* Uses the WooCommerce options API to save settings via the @see woocommerce_update_options() function.
*
* @uses woocommerce_update_options()
* @uses self::get_aihello_settings()
*/
public function update_aihello_settings() {
woocommerce_update_options( self::get_aihello_settings() );
}
function AiHello_menu(){
global $submenu;
$page_title = 'AiHello Smart Ecommerce';
$menu_title = 'AiHello';
$capability = 'manage_options';
$menu_slug = 'aihello';
$function = 'aihello_iframe';
$icon_url = AIHELLO_PLUGIN_ASSETS .'aihelloicon.png';
$position = 4;
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
}
public function get_aihello_settings() {
$settings = array(
'section_title' => array(
'name' => esc_html( 'AiHello Currency', 'aihello-smart-ecommerce' ),
'type' => 'title',
'desc' => esc_html('AiHello Smart Fulfillment settings. You can use shortcode to display currency switcher on desired position.','aihello-smart-ecommerce').'
[aihello-choose-shipping-country]',
'id' => 'wc_settings_aihello_section_title'
),
array(
'name' => esc_html( 'Enable', 'aihello-smart-ecommerce' ),
'type' => 'checkbox',
'desc' => esc_html('Enable currency switcher','aihello-smart-ecommerce'),
'id' => 'wc_settings_aihello_enable'
),
array(
'name' => esc_html( 'Currency Switcher', 'aihello-smart-ecommerce' ),
'desc' => esc_html( 'This controls the visibility of the currency switcher on top of the header.', 'aihello-smart-ecommerce' ),
'id' => 'wc_settings_aihello_currency_switcher',
'std' => 'left', // WooCommerce < 2.0
'default' => 'left', // WooCommerce >= 2.0
'type' => 'select',
'options' => array(
'show' => esc_html( 'Show', 'aihello-smart-ecommerce' ),
'hide' => esc_html( 'Hide', 'aihello-smart-ecommerce' ),
),
'desc_tip' => true,
),
array(
'name' => esc_html( 'Currency Switcher Position', 'aihello-smart-ecommerce' ),
'desc' => esc_html( 'This controls the position of the currency switcher.', 'aihello-smart-ecommerce' ),
'id' => 'wc_settings_aihello_currency_switcher_pos',
'type' => 'select',
'options' => array(
'float-left' => esc_html( 'Left', 'aihello-smart-ecommerce' ),
'float-right' => esc_html( 'Right', 'aihello-smart-ecommerce' )
),
'desc_tip' => true,
),
array(
'name' => esc_html( 'Select specific currencies', 'aihello-smart-ecommerce'),
'desc' => esc_html( 'This option let you limit which currencies you are willing to show.', 'aihello-smart-ecommerce' ),
'id' => 'wc_settings_aihello_specific_currencies',
'placeholder' => 'Select currencies',
'type' => 'multi_select_countries',
'multiple' => 'multiple',
'options' => aihello_currencies(),
'desc_tip' => true,
),
array(
'name' => esc_html( 'Enable', 'aihello-smart-ecommerce' ),
'type' => 'checkbox',
'desc' => esc_html('Inventory by Country (Connect aihello.com first)','aihello-smart-ecommerce'),
'id' => 'wc_settings_aihello_inventory_country'
),
array(
'name' => esc_html( 'API', 'aihello-smart-ecommerce'),
'type' => 'checkbox',
'desc' => esc_html('Enable Inventory API','aihello-smart-ecommerce'),
'id' => 'wc_settings_aihello_api'
),
'section_end' => array(
'type' => 'sectionend',
'id' => 'wc_settings_aihello_section_end'
)
);
return apply_filters( 'wc_settings_aihello_settings', $settings );
}
}
function aihello_iframe() {
echo "
'.esc_html('Install woocommerce to Use AiHello Smart Fulfillment','aihello-smart-ecommerce').'