/**
  * Outputs the content of the widget
  *
  * @version 2.5.5
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     // outputs the content of the widget
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     if (!wcj_is_module_enabled('price_by_country')) {
         echo __('Prices and Currencies by Country module not enabled!', 'woocommerce-jetpack');
     } elseif ('by_ip' === get_option('wcj_price_by_country_customer_country_detection_method', 'by_ip')) {
         echo __('Customer Country Detection Method must include "by user selection"!', 'woocommerce-jetpack');
     } else {
         if (!isset($instance['replace_with_currency'])) {
             $instance['replace_with_currency'] = 'no';
         }
         echo do_shortcode('[wcj_country_select_drop_down_list countries="' . $instance['countries'] . '" replace_with_currency="' . $instance['replace_with_currency'] . '"]');
         /* switch ( $instance['switcher_type'] ) {
         				case 'link_list':
         					echo do_shortcode( '[wcj_currency_select_link_list]' );
         					break;
         				case 'radio_list':
         					echo do_shortcode( '[wcj_currency_select_radio_list]' );
         					break;
         				default:
         					echo do_shortcode( '[wcj_currency_select_drop_down_list]' );
         					break;
         			} */
     }
     echo $args['after_widget'];
 }
 /**
  * Constructor.
  *
  * @version 2.4.8
  */
 function __construct()
 {
     $this->id = 'pdf_invoicing_emails';
     $this->parent_id = 'pdf_invoicing';
     $this->short_desc = __('Email Options', 'woocommerce-jetpack');
     $this->desc = '';
     parent::__construct('submodule');
     add_filter('init', array($this, 'add_hooks'));
     if ($this->is_enabled()) {
         if (!wcj_is_module_enabled('general') || 'no' === get_option('wcj_general_advanced_disable_save_sys_temp_dir', 'no')) {
             add_filter('woocommerce_email_attachments', array($this, 'add_pdf_invoice_email_attachment'), PHP_INT_MAX, 3);
         }
     }
 }
 /**
  * add_reports_currency_to_admin_bar.
  *
  * @version 2.5.2
  */
 function add_reports_currency_to_admin_bar($wp_admin_bar)
 {
     if (isset($_GET['page']) && 'wc-reports' === $_GET['page']) {
         $the_current_code = isset($_GET['currency']) ? $_GET['currency'] : get_woocommerce_currency();
         $parent = 'reports_currency_select';
         $args = array('parent' => false, 'id' => $parent, 'title' => __('Reports currency:', 'woocommerce-jetpack') . ' ' . $the_current_code, 'href' => false, 'meta' => array('title' => __('Show reports only in', 'woocommerce-jetpack') . ' ' . $the_current_code));
         $wp_admin_bar->add_node($args);
         $currency_symbols = array();
         $currency_symbols[$the_current_code] = $the_current_code;
         $currency_symbols[get_woocommerce_currency()] = get_woocommerce_currency();
         if (wcj_is_module_enabled('price_by_country')) {
             for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_price_by_country_total_groups_number', 1)); $i++) {
                 $the_code = get_option('wcj_price_by_country_exchange_rate_currency_group_' . $i);
                 $currency_symbols[$the_code] = $the_code;
             }
         }
         if (wcj_is_module_enabled('multicurrency')) {
             for ($i = 1; $i <= apply_filters('booster_get_option', 2, get_option('wcj_multicurrency_total_number', 2)); $i++) {
                 $the_code = get_option('wcj_multicurrency_currency_' . $i);
                 $currency_symbols[$the_code] = $the_code;
             }
         }
         /* if ( wcj_is_module_enabled( 'multicurrency_base_price' ) ) {
         				for ( $i = 1; $i <= apply_filters( 'booster_get_option', 1, get_option( 'wcj_multicurrency_base_price_total_number', 1 ) ); $i++ ) {
         					$the_code = get_option( 'wcj_multicurrency_base_price_currency_' . $i );
         					$currency_symbols[ $the_code ] = $the_code;
         				}
         			} */
         if (wcj_is_module_enabled('payment_gateways_currency')) {
             global $woocommerce;
             $available_gateways = $woocommerce->payment_gateways->payment_gateways();
             foreach ($available_gateways as $key => $gateway) {
                 $the_code = get_option('wcj_gateways_currency_' . $key);
                 if ('no_changes' != $the_code) {
                     $currency_symbols[$the_code] = $the_code;
                 }
             }
         }
         sort($currency_symbols);
         $currency_symbols['merge'] = 'merge';
         foreach ($currency_symbols as $code) {
             $args = array('parent' => $parent, 'id' => $parent . '_' . $code, 'title' => $code, 'href' => add_query_arg('currency', $code), 'meta' => array('title' => __('Show reports only in', 'woocommerce-jetpack') . ' ' . $code));
             $wp_admin_bar->add_node($args);
         }
     }
 }
 /**
  * generate_report_zip.
  *
  * @version 2.5.0
  * @since   2.3.10
  */
 function generate_report_zip()
 {
     if (isset($_POST['get_invoices_report_zip'])) {
         if (wcj_is_module_enabled('general') && 'yes' === get_option('wcj_general_advanced_disable_save_sys_temp_dir', 'no')) {
             $this->notice = '<div class="error"><p><strong>' . __('This option is disabled in WooCommerce > Settings > Booster > Emails & Misc. > General > Advanced Options > Disable Saving PDFs in PHP directory for temporary files', 'woocommerce-jetpack') . '</strong></p></div>';
         } else {
             if (!empty($_POST['report_year']) && !empty($_POST['report_month']) && !empty($_POST['invoice_type'])) {
                 if (wcj_is_user_role('administrator') || is_shop_manager()) {
                     if (false === $this->get_invoices_report_zip($_POST['report_year'], $_POST['report_month'], $_POST['invoice_type'])) {
                         $this->notice = '<div class="error"><p><strong>' . __('Sorry, but something went wrong...', 'woocommerce-jetpack') . '</strong></p></div>';
                     }
                 }
             } else {
                 $this->notice = '<div class="error"><p><strong>' . __('Please fill year and month values.', 'woocommerce-jetpack') . '</strong></p></div>';
             }
         }
     }
 }
 /**
  * Outputs the content of the widget
  *
  * @version 2.5.0
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     // outputs the content of the widget
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     if (!wcj_is_module_enabled('multicurrency')) {
         echo __('Multicurrency module not enabled!', 'woocommerce-jetpack');
     } else {
         switch ($instance['switcher_type']) {
             case 'link_list':
                 echo do_shortcode('[wcj_currency_select_link_list]');
                 break;
             case 'radio_list':
                 echo do_shortcode('[wcj_currency_select_radio_list]');
                 break;
             default:
                 echo do_shortcode('[wcj_currency_select_drop_down_list]');
                 break;
         }
     }
     echo $args['after_widget'];
 }
 /**
  * get_pdf.
  *
  * @version 2.4.8
  */
 function get_pdf($dest)
 {
     // Get invoice content HTML
     $_GET['order_id'] = $this->order_id;
     $the_order = wc_get_order($this->order_id);
     if (!isset($_GET['billing_country'])) {
         $_GET['billing_country'] = $the_order->billing_country;
     }
     $html = do_shortcode(get_option('wcj_invoicing_' . $this->invoice_type . '_template'));
     $html = force_balance_tags($html);
     //$html = apply_filters( 'the_content', get_option( 'wcj_invoicing_' . $this->invoice_type . '_template' ) );
     $styling = '<style>' . get_option('wcj_invoicing_' . $this->invoice_type . '_css') . '</style>';
     $pdf = $this->prepare_pdf();
     // Print text using writeHTMLCell()
     $pdf->writeHTMLCell(0, 0, '', '', $styling . $html, 0, 1, 0, true, '', true);
     /*
     		// set style for barcode
     		$style = array(
     			'border' => true,
     			'vpadding' => 'auto',
     			'hpadding' => 'auto',
     			'fgcolor' => array(0,0,0),
     			'bgcolor' => false, //array(255,255,255)
     			'module_width' => 1, // width of a single module in points
     			'module_height' => 1 // height of a single module in points
     		);
     // -------------------------------------------------------------------
     		// PDF417 (ISO/IEC 15438:2006)
     /*
      The $type parameter can be simple 'PDF417' or 'PDF417' followed by a
     		 number of comma-separated options:
      'PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6'
      Possible options are:
     	 a  = aspect ratio (width/height);
     			 e  = error correction level (0-8);
     	 Macro Control Block options:
     	 t  = total number of macro segments;
     			 s  = macro segment index (0-99998);
     			 f  = file ID;
     			 o0 = File Name (text);
     			 o1 = Segment Count (numeric);
     			 o2 = Time Stamp (numeric);
     			 o3 = Sender (text);
     			 o4 = Addressee (text);
     			 o5 = File Size (numeric);
     			 o6 = Checksum (numeric).
      Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional.
     		 To use a comma character ',' on text options, replace it with the character 255: "\xff".
     */
     /*
     
     		$pdf->write2DBarcode( 'www.woojetpack.com', 'PDF417', 0, 200, 0, 30, $style, 'T');
     		//$pdf->Text(80, 85, 'PDF417 (ISO/IEC 15438:2006)');
     
     		// -------------------------------------------------------------------
     		/**
     		require_once( wcj_plugin_path() .'/includes/lib/tcpdf_min/tcpdf_barcodes_2d.php');
     		$barcodeobj = new TCPDF2DBarcode('http://www.tcpdf.org', 'PDF417');
     		// output the barcode as PNG image
     		//$barcodeobj->getBarcodePNG(4, 4, array(0,0,0));
     		$html = $barcodeobj->getBarcodeHTML(4, 4, 'black');
     		//$pdf->writeHTMLCell( 0, 0, '', '', $html, 0, 1, 0, true, '', true );
     		/**/
     // Close and output PDF document
     $result_pdf = $pdf->Output('', 'S');
     $file_name = $this->get_file_name();
     if ('F' === $dest) {
         $file_path = sys_get_temp_dir() . '/' . $file_name;
         if (!file_put_contents($file_path, $result_pdf)) {
             return null;
         }
         return $file_path;
     } elseif ('D' === $dest || 'I' === $dest) {
         if ('D' === $dest) {
             header("Content-Type: application/octet-stream");
             header("Content-Disposition: attachment; filename=" . urlencode($file_name));
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Description: File Transfer");
         } elseif ('I' === $dest) {
             header("Content-type: application/pdf");
             header("Content-Disposition: inline; filename=" . urlencode($file_name));
         }
         if (wcj_is_module_enabled('general') && 'yes' === get_option('wcj_general_advanced_disable_save_sys_temp_dir', 'no')) {
             header("Content-Length: " . strlen($result_pdf));
             echo $result_pdf;
         } else {
             $file_path = sys_get_temp_dir() . '/' . $file_name;
             if (!file_put_contents($file_path, $result_pdf)) {
                 return null;
             }
             header("Content-Length: " . filesize($file_path));
             flush();
             // this doesn't really matter.
             if (false !== ($fp = fopen($file_path, "r"))) {
                 while (!feof($fp)) {
                     echo fread($fp, 65536);
                     flush();
                     // this is essential for large downloads
                 }
                 fclose($fp);
             } else {
                 die(__('Unexpected error', 'woocommerce-jetpack'));
             }
         }
     }
     return null;
 }
 /**
  * wcj_shortcode.
  *
  * @version 2.5.7
  */
 function wcj_shortcode($atts, $content, $shortcode)
 {
     // Init
     if (empty($atts)) {
         $atts = array();
     }
     // Add child class specific atts
     $atts = $this->add_extra_atts($atts);
     // Merge atts with global defaults
     $global_defaults = array('before' => '', 'after' => '', 'visibility' => '', 'site_visibility' => '', 'location' => '', 'not_location' => '', 'wpml_language' => '', 'wpml_not_language' => '', 'billing_country' => '', 'not_billing_country' => '', 'module' => '', 'find' => '', 'replace' => '');
     $atts = array_merge($global_defaults, $atts);
     // Check for required atts
     if (false === ($atts = $this->init_atts($atts))) {
         return '';
     }
     // Check for module enabled
     if ('' != $atts['module'] && !wcj_is_module_enabled($atts['module'])) {
         return '<p>' . sprintf(__('%s module not enabled!', 'woocommerce-jetpack'), $atts['module_name']) . '</p>';
     }
     // Check if privileges are ok
     if ('' != $atts['visibility']) {
         $visibilities = str_replace(' ', '', $atts['visibility']);
         $visibilities = explode(',', $visibilities);
         $is_iser_visibility_ok = false;
         foreach ($visibilities as $visibility) {
             if ('admin' === $visibility) {
                 $visibility = 'administrator';
             }
             if (wcj_is_user_role($visibility)) {
                 $is_iser_visibility_ok = true;
                 break;
             }
         }
         if (!$is_iser_visibility_ok) {
             //				return '<p><a href="' . wp_login_url( get_permalink() ) . '" title="' . $atts['login_text'] . '">' . $atts['login_text'] . '</a></p>';
             if (!is_user_logged_in()) {
                 ob_start();
                 woocommerce_login_form();
                 return ob_get_clean();
             } else {
                 return '<p>' . __('Wrong user role!', 'woocommerce-jetpack') . '</p>';
             }
         }
     }
     // Check if site visibility is ok
     if ('' != $atts['site_visibility']) {
         if ('single' === $atts['site_visibility'] && !is_single() || 'page' === $atts['site_visibility'] && !is_page() || 'archive' === $atts['site_visibility'] && !is_archive()) {
             return '';
         }
     }
     // Check if location is ok
     if ('' != $atts['location'] && 'all' != $atts['location'] && $atts['location'] != $this->wcj_get_user_location()) {
         return '';
     }
     if ('' != $atts['not_location'] && $atts['not_location'] === $this->wcj_get_user_location()) {
         return '';
     }
     // Check if language is ok
     if ('wcj_wpml' === $shortcode || 'wcj_wpml_translate' === $shortcode) {
         $atts['wpml_language'] = isset($atts['lang']) ? $atts['lang'] : '';
     }
     if ('wcj_wpml' === $shortcode || 'wcj_wpml_translate' === $shortcode) {
         $atts['wpml_not_language'] = isset($atts['not_lang']) ? $atts['not_lang'] : '';
     }
     if ('' != $atts['wpml_language']) {
         if (!defined('ICL_LANGUAGE_CODE')) {
             return '';
         }
         if (!in_array(ICL_LANGUAGE_CODE, $this->custom_explode($atts['wpml_language']))) {
             return '';
         }
     }
     // Check if language is ok (not in...)
     if ('' != $atts['wpml_not_language']) {
         if (defined('ICL_LANGUAGE_CODE')) {
             if (in_array(ICL_LANGUAGE_CODE, $this->custom_explode($atts['wpml_not_language']))) {
                 return '';
             }
         }
     }
     // Check if billing country by arg is ok
     if ('' != $atts['billing_country']) {
         if (!isset($_GET['billing_country'])) {
             return '';
         }
         if (!in_array($_GET['billing_country'], $this->custom_explode($atts['billing_country']))) {
             return '';
         }
     }
     // Check if billing country by arg is ok (not in...)
     if ('' != $atts['not_billing_country']) {
         if (isset($_GET['billing_country'])) {
             if (in_array($_GET['billing_country'], $this->custom_explode($atts['not_billing_country']))) {
                 return '';
             }
         }
     }
     // Run the shortcode function
     $shortcode_function = $shortcode;
     if ('' !== ($result = $this->{$shortcode_function}($atts, $content))) {
         if ('' != $atts['find']) {
             $result = str_replace($atts['find'], $atts['replace'], $result);
         }
         return $atts['before'] . $result . $atts['after'];
     }
     return '';
 }
 /**
  * update_products_price_by_country_module_saved.
  *
  * @version 2.5.3
  * @since   2.5.3
  */
 function update_products_price_by_country_module_saved($all_sections, $current_section)
 {
     if ('price_by_country' === $current_section && wcj_is_module_enabled('price_by_country')) {
         wcj_update_products_price_by_country();
     }
 }
 /**
  * add_currency_exchange_rates_settings.
  *
  * @version 2.5.5
  */
 function add_currency_exchange_rates_settings()
 {
     $settings = array();
     $desc = '';
     if ($this->is_enabled()) {
         if ('' != get_option('wcj_currency_exchange_rate_cron_time', '')) {
             $scheduled_time_diff = get_option('wcj_currency_exchange_rate_cron_time', '') - time();
             if ($scheduled_time_diff > 0) {
                 $desc = '<br><em>' . sprintf(__('%s seconds till next update.', 'woocommerce-jetpack'), $scheduled_time_diff) . '</em>';
             }
         }
     }
     $settings[] = array('title' => __('Exchange Rates', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => __('All currencies from all <strong>enabled</strong> modules will be automatically added to the list.', 'woocommerce-jetpack') . $desc, 'id' => 'wcj_currency_exchange_rates_options');
     $settings[] = array('title' => __('Exchange Rates Updates', 'woocommerce-jetpack'), 'id' => 'wcj_currency_exchange_rates_auto', 'default' => 'daily', 'type' => 'select', 'options' => array('minutely' => __('Update Every Minute', 'woocommerce-jetpack'), 'hourly' => __('Update Hourly', 'woocommerce-jetpack'), 'twicedaily' => __('Update Twice Daily', 'woocommerce-jetpack'), 'daily' => __('Update Daily', 'woocommerce-jetpack'), 'weekly' => __('Update Weekly', 'woocommerce-jetpack')));
     $currency_from = get_option('woocommerce_currency');
     if (wcj_is_module_enabled('price_by_country')) {
         // Currency Pairs - Price by Country
         for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_price_by_country_total_groups_number', 1)); $i++) {
             $currency_to = get_option('wcj_price_by_country_exchange_rate_currency_group_' . $i);
             $settings = $this->add_currency_pair_setting($currency_from, $currency_to, $settings);
         }
     }
     if (wcj_is_module_enabled('multicurrency')) {
         // Currency Pairs - Multicurrency
         for ($i = 1; $i <= apply_filters('booster_get_option', 2, get_option('wcj_multicurrency_total_number', 2)); $i++) {
             $currency_to = get_option('wcj_multicurrency_currency_' . $i);
             $settings = $this->add_currency_pair_setting($currency_from, $currency_to, $settings);
         }
     }
     if (wcj_is_module_enabled('multicurrency_base_price')) {
         // Currency Pairs - Multicurrency Product Base Price
         for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_multicurrency_base_price_total_number', 1)); $i++) {
             $currency_to = get_option('wcj_multicurrency_base_price_currency_' . $i);
             $settings = $this->add_currency_pair_setting($currency_from, $currency_to, $settings);
         }
     }
     if (wcj_is_module_enabled('currency_per_product')) {
         // Currency Pairs - Currency per Product
         for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_currency_per_product_total_number', 1)); $i++) {
             $currency_to = get_option('wcj_currency_per_product_currency_' . $i);
             $settings = $this->add_currency_pair_setting($currency_from, $currency_to, $settings);
         }
     }
     if (wcj_is_module_enabled('payment_gateways_currency')) {
         // Currency Pairs - Gateway Currency
         global $woocommerce;
         $available_gateways = $woocommerce->payment_gateways->payment_gateways();
         foreach ($available_gateways as $key => $gateway) {
             $currency_to = get_option('wcj_gateways_currency_' . $key);
             if ('no_changes' != $currency_to) {
                 $settings = $this->add_currency_pair_setting($currency_from, $currency_to, $settings);
             }
         }
     }
     /* $settings[] = array(
     			'title'    => __( 'Logging', 'woocommerce-jetpack' ),
     			'desc'     => __( 'Enable', 'woocommerce-jetpack' ),
     			'id'       => 'wcj_currency_exchange_logging_enabled',
     			'default'  => 'no',
     			'type'     => 'checkbox',
     		); */
     $settings[] = array('type' => 'sectionend', 'id' => 'wcj_currency_exchange_rates_options');
     return $settings;
 }
 /**
  * include_shortcodes.
  *
  * @version 2.5.4
  */
 private function include_shortcodes()
 {
     if (!wcj_is_module_enabled('general') || wcj_is_module_enabled('general') && 'no' === get_option('wcj_general_shortcodes_disable_booster_shortcodes', 'no')) {
         include_once 'includes/shortcodes/class-wcj-shortcodes.php';
         include_once 'includes/shortcodes/class-wcj-general-shortcodes.php';
         include_once 'includes/shortcodes/class-wcj-invoices-shortcodes.php';
         include_once 'includes/shortcodes/class-wcj-orders-shortcodes.php';
         include_once 'includes/shortcodes/class-wcj-order-items-shortcodes.php';
         include_once 'includes/shortcodes/class-wcj-products-shortcodes.php';
         include_once 'includes/shortcodes/class-wcj-products-crowdfunding-shortcodes.php';
         include_once 'includes/shortcodes/class-wcj-products-add-form-shortcodes.php';
         include_once 'includes/shortcodes/class-wcj-input-field-shortcodes.php';
     }
 }
 /**
  * On the scheduled action hook, run a function.
  *
  * @version 2.5.3
  */
 function update_the_exchange_rates($interval)
 {
     $currency_pairs[] = array();
     if (wcj_is_module_enabled('price_by_country')) {
         // Currency Pairs - Preparation - Price by Country
         if ('manual' != apply_filters('booster_get_option', 'manual', get_option('wcj_price_by_country_auto_exchange_rates', 'manual'))) {
             for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_price_by_country_total_groups_number', 1)); $i++) {
                 $currency_to = get_option('wcj_price_by_country_exchange_rate_currency_group_' . $i);
                 $currency_pairs = $this->get_currency_pair($currency_pairs, $currency_to, 'wcj_price_by_country_exchange_rate_group_' . $i);
             }
         }
     }
     if (wcj_is_module_enabled('multicurrency')) {
         // Currency Pairs - Preparation - Multicurrency
         if ('manual' != apply_filters('booster_get_option', 'manual', get_option('wcj_multicurrency_exchange_rate_update_auto', 'manual'))) {
             for ($i = 1; $i <= apply_filters('booster_get_option', 2, get_option('wcj_multicurrency_total_number', 2)); $i++) {
                 $currency_to = get_option('wcj_multicurrency_currency_' . $i);
                 $currency_pairs = $this->get_currency_pair($currency_pairs, $currency_to, 'wcj_multicurrency_exchange_rate_' . $i);
             }
         }
     }
     if (wcj_is_module_enabled('multicurrency_base_price')) {
         // Currency Pairs - Preparation - Multicurrency Product Base Price
         if ('manual' != apply_filters('booster_get_option', 'manual', get_option('wcj_multicurrency_base_price_exchange_rate_update', 'manual'))) {
             for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_multicurrency_base_price_total_number', 1)); $i++) {
                 $currency_to = get_option('wcj_multicurrency_base_price_currency_' . $i);
                 $currency_pairs = $this->get_currency_pair($currency_pairs, $currency_to, 'wcj_multicurrency_base_price_exchange_rate_' . $i);
             }
         }
     }
     if (wcj_is_module_enabled('currency_per_product')) {
         // Currency Pairs - Preparation - Currency per Product
         if ('manual' != apply_filters('booster_get_option', 'manual', get_option('wcj_currency_per_product_exchange_rate_update', 'manual'))) {
             for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_currency_per_product_total_number', 1)); $i++) {
                 $currency_to = get_option('wcj_currency_per_product_currency_' . $i);
                 $currency_pairs = $this->get_currency_pair($currency_pairs, $currency_to, 'wcj_currency_per_product_exchange_rate_' . $i);
             }
         }
     }
     if (wcj_is_module_enabled('payment_gateways_currency')) {
         // Currency Pairs - Preparation - Gateway Currency
         if ('manual' != apply_filters('booster_get_option', 'manual', get_option('wcj_gateways_currency_exchange_rate_update_auto', 'manual'))) {
             global $woocommerce;
             $available_gateways = $woocommerce->payment_gateways->payment_gateways();
             foreach ($available_gateways as $key => $gateway) {
                 $currency_to = get_option('wcj_gateways_currency_' . $key);
                 if ('no_changes' != $currency_to) {
                     $currency_pairs = $this->get_currency_pair($currency_pairs, $currency_to, 'wcj_gateways_currency_exchange_rate_' . $key);
                 }
             }
         }
     }
     // Currency Pairs - Final
     foreach ($currency_pairs as $currency_pair) {
         $currency_from = $currency_pair['currency_from'];
         $currency_to = $currency_pair['currency_to'];
         $the_rate = $this->get_exchange_rate($currency_from, $currency_to);
         if (0 != $the_rate) {
             if ($currency_from != $currency_to) {
                 foreach ($currency_pair['option_name'] as $option_name) {
                     update_option($option_name, $the_rate);
                 }
                 $field_id = 'wcj_currency_exchange_rates_' . sanitize_title($currency_from . $currency_to);
                 update_option($field_id, $the_rate);
                 $result_message = __('Cron job: exchange rates successfully updated', 'woocommerce-jetpack');
             } else {
                 $result_message = __('Cron job: exchange rates not updated, as currency_from == currency_to', 'woocommerce-jetpack');
             }
         } else {
             $result_message = __('Cron job: exchange rates update failed', 'woocommerce-jetpack');
         }
         /* if ( 'yes' === get_option( 'wcj_currency_exchange_logging_enabled', 'no' ) ) {
         				wcj_log( $result_message . ': ' . $currency_from . $currency_to . ': ' . $the_rate . ': ' . 'update_the_exchange_rates: ' . $interval );
         			} */
     }
     if (wcj_is_module_enabled('price_by_country')) {
         if ('yes' === get_option('wcj_price_by_country_price_filter_widget_support_enabled', 'no')) {
             wcj_update_products_price_by_country();
         }
     }
 }
 function wcj_get_currency_symbol($currency_code)
 {
     $return = '';
     $currencies = wcj_get_currencies_names_and_symbols('symbols', 'no_custom');
     if (isset($currencies[$currency_code])) {
         if (wcj_is_module_enabled('currency')) {
             $return = apply_filters('booster_get_option', $currencies[$currency_code], get_option('wcj_currency_' . $currency_code, $currencies[$currency_code]));
         } else {
             $return = $currencies[$currency_code];
         }
     } else {
         $currencies = wcj_get_currencies_names_and_symbols('symbols', 'custom_only');
         $return = isset($currencies[$currency_code]) ? $currencies[$currency_code] : '';
     }
     return '' != $return ? $return : false;
 }
 /**
  * wcj_wholesale_price_table (global only).
  *
  * @version 2.5.7
  * @since   2.4.8
  */
 function wcj_wholesale_price_table($atts)
 {
     if (!wcj_is_module_enabled('wholesale_price')) {
         return '';
     }
     // Check for user role options
     $role_option_name_addon = '';
     $user_roles = get_option('wcj_wholesale_price_by_user_role_roles', '');
     if (!empty($user_roles)) {
         $current_user_role = wcj_get_current_user_first_role();
         foreach ($user_roles as $user_role_key) {
             if ($current_user_role === $user_role_key) {
                 $role_option_name_addon = '_' . $user_role_key;
                 break;
             }
         }
     }
     $wholesale_price_levels = array();
     for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_wholesale_price_levels_number' . $role_option_name_addon, 1)); $i++) {
         $level_qty = get_option('wcj_wholesale_price_level_min_qty' . $role_option_name_addon . '_' . $i, PHP_INT_MAX);
         $discount = get_option('wcj_wholesale_price_level_discount_percent' . $role_option_name_addon . '_' . $i, 0);
         $wholesale_price_levels[] = array('quantity' => $level_qty, 'discount' => $discount);
     }
     $data_qty = array();
     $data_discount = array();
     $columns_styles = array();
     $i = -1;
     foreach ($wholesale_price_levels as $wholesale_price_level) {
         $i++;
         if (0 == $wholesale_price_level['quantity'] && 'yes' === $atts['hide_if_zero_quantity']) {
             continue;
         }
         $level_max_qty = isset($wholesale_price_levels[$i + 1]['quantity']) ? $atts['before_level_max_qty'] . ($wholesale_price_levels[$i + 1]['quantity'] - 1) : $atts['last_level_max_qty'];
         $data_qty[] = str_replace(array('%level_qty%', '%level_min_qty%', '%level_max_qty%'), array($wholesale_price_level['quantity'], $wholesale_price_level['quantity'], $level_max_qty), $atts['heading_format']);
         $data_discount[] = 'fixed' === get_option('wcj_wholesale_price_discount_type', 'percent') ? '-' . wc_price($wholesale_price_level['discount']) : '-' . $wholesale_price_level['discount'] . '%';
         $columns_styles[] = 'text-align: center;';
     }
     $table_rows = array($data_qty, $data_discount);
     if ('vertical' === $atts['table_format']) {
         $table_rows_modified = array();
         foreach ($table_rows as $row_number => $table_row) {
             foreach ($table_row as $column_number => $cell) {
                 $table_rows_modified[$column_number][$row_number] = $cell;
             }
         }
         $table_rows = $table_rows_modified;
     }
     return wcj_get_table_html($table_rows, array('table_class' => 'wcj_wholesale_price_table', 'columns_styles' => $columns_styles, 'table_heading_type' => $atts['table_format']));
 }