/**
  * change_labels.
  *
  * @version 2.5.7
  * @since   2.5.7
  */
 function change_labels()
 {
     if (function_exists('is_cart') && is_cart()) {
         wp_enqueue_style('wcj-shipping-calculator', wcj_plugin_url() . '/includes/css/wcj-shipping-calculator.css', array(), WCJ()->version);
         wp_enqueue_script('wcj-shipping-calculator-js', wcj_plugin_url() . '/includes/js/wcj-shipping-calculator.js', array('jquery'), WCJ()->version, true);
         wp_localize_script('wcj-shipping-calculator-js', 'alg_object', array('calculate_shipping_label' => get_option('wcj_shipping_calculator_label_calculate_shipping', ''), 'update_totals_label' => get_option('wcj_shipping_calculator_label_update_totals', '')));
     }
 }
 /**
  * enqueue_scripts.
  */
 function enqueue_scripts()
 {
     if ('yes' === get_option('wcj_eu_vat_number_validate', 'yes')) {
         wp_enqueue_script('wcj-eu-vat-number', wcj_plugin_url() . '/includes/js/eu-vat-number.js', array(), false, true);
     }
 }
 /**
  * register_frontend_scripts.
  *
  * @version 2.3.0
  * @since   2.3.0
  */
 public function register_frontend_scripts()
 {
     wp_register_script('jquery-ui-timepicker', wcj_plugin_url() . '/includes/js/jquery.timepicker.min.js', array('jquery'), false, true);
 }
 /**
  * enqueue_scripts.
  *
  * @version 2.5.2
  * @since   2.5.2
  */
 function enqueue_scripts()
 {
     wp_enqueue_script('wcj-pdf-invoicing', wcj_plugin_url() . '/includes/js/wcj-pdf-invoicing.js', array(), false, true);
 }
 /**
  * create_meta_box.
  *
  * @since 2.5.7
  */
 function create_meta_box()
 {
     $current_post_id = get_the_ID();
     $html = '';
     $html .= '<table>';
     foreach ($this->get_meta_box_options() as $option) {
         $is_enabled = isset($option['enabled']) && 'no' === $option['enabled'] ? false : true;
         if ($is_enabled) {
             if ('title' === $option['type']) {
                 $html .= '<tr>';
                 $html .= '<th colspan="2" style="text-align:left;">' . $option['title'] . '</th>';
                 $html .= '</tr>';
             } else {
                 $custom_attributes = '';
                 $the_post_id = isset($option['product_id']) ? $option['product_id'] : $current_post_id;
                 // todo: maybe also order_id?
                 $the_meta_name = isset($option['meta_name']) ? $option['meta_name'] : '_' . $option['name'];
                 if (get_post_meta($the_post_id, $the_meta_name)) {
                     $option_value = get_post_meta($the_post_id, $the_meta_name, true);
                 } else {
                     $option_value = isset($option['default']) ? $option['default'] : '';
                 }
                 $input_ending = '';
                 if ('select' === $option['type']) {
                     if (isset($option['multiple'])) {
                         $custom_attributes = ' multiple';
                         $option_name = $option['name'] . '[]';
                     } else {
                         $option_name = $option['name'];
                     }
                     $options = '';
                     foreach ($option['options'] as $select_option_key => $select_option_value) {
                         $selected = '';
                         if (is_array($option_value)) {
                             foreach ($option_value as $single_option_value) {
                                 $selected .= selected($single_option_value, $select_option_key, false);
                             }
                         } else {
                             $selected = selected($option_value, $select_option_key, false);
                         }
                         $options .= '<option value="' . $select_option_key . '" ' . $selected . '>' . $select_option_value . '</option>';
                     }
                 } else {
                     $input_ending = ' id="' . $option['name'] . '" name="' . $option['name'] . '" value="' . $option_value . '">';
                     if (isset($option['custom_attributes'])) {
                         $input_ending = ' ' . $option['custom_attributes'] . $input_ending;
                     }
                 }
                 switch ($option['type']) {
                     case 'price':
                         $field_html = '<input class="short wc_input_price" type="number" step="' . apply_filters('wcj_get_meta_box_options_type_price_step', '0.0001') . '"' . $input_ending;
                         break;
                     case 'date':
                         $field_html = '<input class="input-text" display="date" type="text"' . $input_ending;
                         break;
                     case 'textarea':
                         $field_html = '<textarea style="min-width:300px;"' . ' id="' . $option['name'] . '" name="' . $option['name'] . '">' . $option_value . '</textarea>';
                         break;
                     case 'select':
                         $field_html = '<select' . $custom_attributes . ' id="' . $option['name'] . '" name="' . $option_name . '">' . $options . '</select>';
                         break;
                     default:
                         $field_html = '<input class="short" type="' . $option['type'] . '"' . $input_ending;
                         break;
                 }
                 $html .= '<tr>';
                 $maybe_tooltip = isset($option['tooltip']) && '' != $option['tooltip'] ? ' <img style="display:inline;" class="wcj-question-icon" src="' . wcj_plugin_url() . '/assets/images/question-icon.png' . '" title="' . $option['tooltip'] . '">' : '';
                 $html .= '<th style="text-align:left;">' . $option['title'] . $maybe_tooltip . '</th>';
                 if (isset($option['desc']) && '' != $option['desc']) {
                     $html .= '<td style="font-style:italic;">' . $option['desc'] . '</td>';
                 }
                 $html .= '<td>' . $field_html . '</td>';
                 $html .= '</tr>';
             }
         }
     }
     $html .= '</table>';
     $html .= '<input type="hidden" name="woojetpack_' . $this->id . '_save_post" value="woojetpack_' . $this->id . '_save_post">';
     echo $html;
 }
 /**
  * maybe_enqueue_timepicker_style.
  *
  * @version 2.4.0
  * @since   2.4.0
  */
 function maybe_enqueue_timepicker_style()
 {
     if (!wcj_is_module_enabled('general') || wcj_is_module_enabled('general') && 'no' === get_option('wcj_general_advanced_disable_timepicker_css', 'no')) {
         wp_enqueue_style('wcj-timepicker-css', wcj_plugin_url() . '/includes/css/jquery.timepicker.min.css');
     }
 }
 /**
  * add_addons_to_frontend.
  *
  * @version 2.5.6
  * @since   2.5.3
  */
 function add_addons_to_frontend()
 {
     $html = '';
     $addons = $this->get_product_addons(get_the_ID());
     $_product = wc_get_product(get_the_ID());
     foreach ($addons as $addon) {
         $is_required = 'yes' === $addon['is_required'] ? ' required' : '';
         if ('checkbox' === $addon['type'] || '' == $addon['type']) {
             $is_checked = '';
             if (isset($_POST[$addon['checkbox_key']])) {
                 $is_checked = ' checked';
             } elseif ('checked' === $addon['default']) {
                 $is_checked = ' checked';
             }
             $maybe_tooltip = '' != $addon['tooltip'] ? ' <img style="display:inline;" class="wcj-question-icon" src="' . wcj_plugin_url() . '/assets/images/question-icon.png' . '" title="' . $addon['tooltip'] . '">' : '';
             $html .= '<p>' . '<input type="checkbox" id="' . $addon['checkbox_key'] . '" name="' . $addon['checkbox_key'] . '"' . $is_checked . $is_required . '>' . ' ' . '<label for="' . $addon['checkbox_key'] . '">' . $addon['label_value'] . ' (' . wc_price($_product->get_display_price($addon['price_value'])) . ')' . '</label>' . $maybe_tooltip . '</p>';
         } elseif ('radio' === $addon['type']) {
             $prices = explode(PHP_EOL, $addon['price_value']);
             $labels = explode(PHP_EOL, $addon['label_value']);
             $tooltips = explode(PHP_EOL, $addon['tooltip']);
             if (count($labels) === count($prices)) {
                 foreach ($labels as $i => $label) {
                     $label = sanitize_title($label);
                     $is_checked = '';
                     if (isset($_POST[$addon['checkbox_key']])) {
                         $is_checked = $label === $_POST[$addon['checkbox_key']] ? ' checked' : '';
                     } elseif ('' != $addon['default']) {
                         $is_checked = $label === sanitize_title($addon['default']) ? ' checked' : '';
                     }
                     $maybe_tooltip = isset($tooltips[$i]) && '' != $tooltips[$i] ? ' <img style="display:inline;" class="wcj-question-icon" src="' . wcj_plugin_url() . '/assets/images/question-icon.png' . '" title="' . $tooltips[$i] . '">' : '';
                     $html .= '<p>' . '<input type="radio" id="' . $addon['checkbox_key'] . '-' . $label . '" name="' . $addon['checkbox_key'] . '" value="' . $label . '"' . $is_checked . $is_required . '>' . ' ' . '<label for="' . $addon['checkbox_key'] . '-' . $label . '">' . $labels[$i] . ' (' . wc_price($_product->get_display_price($prices[$i])) . ')' . '</label>' . $maybe_tooltip . '</p>';
                 }
             }
         }
     }
     // Output
     if (!empty($html)) {
         echo '<div id="wcj_product_addons">' . $html . '</div>';
     }
 }
 /**
  * wcj_get_5_rocket_image.
  *
  * @version 2.5.5
  * @since   2.5.3
  */
 function wcj_get_5_rocket_image()
 {
     return '<img class="wcj-rocket-icon" src="' . wcj_plugin_url() . '/assets/images/5-rockets.png' . '" title="">';
 }
 /**
  * enqueue_scripts.
  *
  * @version 2.5.4
  */
 function enqueue_scripts()
 {
     if ('yes' === get_option('wcj_eu_vat_number_validate', 'yes')) {
         wp_enqueue_script('wcj-eu-vat-number', wcj_plugin_url() . '/includes/js/eu-vat-number.js', array(), false, true);
         wp_localize_script('wcj-eu-vat-number', 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php')));
     }
 }
 /**
  * wcj_country_select_drop_down_list.
  *
  * @version 2.5.9
  */
 function wcj_country_select_drop_down_list($atts, $content)
 {
     $html = '';
     $form_method = $atts['form_method'];
     // get_option( 'wcj_price_by_country_country_selection_box_method', 'get' );
     $select_class = $atts['class'];
     // get_option( 'wcj_price_by_country_country_selection_box_class', '' );
     $select_style = $atts['style'];
     // get_option( 'wcj_price_by_country_country_selection_box_style', '' );
     $html .= '<form action="" method="' . $form_method . '">';
     $html .= '<select name="wcj-country" id="wcj-country" style="' . $select_style . '" class="' . $select_class . '" onchange="this.form.submit()">';
     $countries = wcj_get_countries();
     /* $shortcode_countries = get_option( 'wcj_price_by_country_shortcode_countries', array() );
     		if ( '' == $shortcode_countries ) $shortcode_countries = array(); */
     $shortcode_countries = $atts['countries'];
     if ('' == $shortcode_countries) {
         $shortcode_countries = array();
     } else {
         $shortcode_countries = str_replace(' ', '', $shortcode_countries);
         $shortcode_countries = trim($shortcode_countries, ',');
         $shortcode_countries = explode(',', $shortcode_countries);
     }
     /* if ( 'get' == $form_method ) {
     			$selected_country = ( isset( $_GET[ 'wcj-country' ] ) ) ? $_GET[ 'wcj-country' ] : '';
     		} else {
     			$selected_country = ( isset( $_POST[ 'wcj-country' ] ) ) ? $_POST[ 'wcj-country' ] : '';
     		} */
     $selected_country = isset($_SESSION['wcj-country']) ? $_SESSION['wcj-country'] : '';
     if ('yes' === $atts['replace_with_currency']) {
         $currencies_names_and_symbols = wcj_get_currencies_names_and_symbols();
     }
     if (empty($shortcode_countries)) {
         foreach ($countries as $country_code => $country_name) {
             $data_icon = '';
             if ('yes' === get_option('wcj_price_by_country_jquery_wselect_enabled', 'no')) {
                 $data_icon = ' data-icon="' . wcj_plugin_url() . '/assets/images/flag-icons/' . strtolower($country_code) . '.png"';
             }
             $option_label = 'yes' === $atts['replace_with_currency'] ? $currencies_names_and_symbols[wcj_get_currency_by_country($country_code)] : $country_name;
             $html .= '<option' . $data_icon . ' value="' . $country_code . '" ' . selected($country_code, $selected_country, false) . '>' . $option_label . '</option>';
         }
     } else {
         foreach ($shortcode_countries as $country_code) {
             if (isset($countries[$country_code])) {
                 $data_icon = '';
                 if ('yes' === get_option('wcj_price_by_country_jquery_wselect_enabled', 'no')) {
                     $data_icon = ' data-icon="' . wcj_plugin_url() . '/assets/images/flag-icons/' . strtolower($country_code) . '.png"';
                 }
                 $option_label = 'yes' === $atts['replace_with_currency'] ? $currencies_names_and_symbols[wcj_get_currency_by_country($country_code)] : $countries[$country_code];
                 $html .= '<option' . $data_icon . ' value="' . $country_code . '" ' . selected($country_code, $selected_country, false) . '>' . $option_label . '</option>';
             }
         }
     }
     $html .= '</select>';
     $html .= '</form>';
     return $html;
 }
 /**
  * enqueue_wselect_scripts.
  *
  * @version 2.5.4
  * @since   2.5.4
  */
 function enqueue_wselect_scripts()
 {
     wp_enqueue_style('wcj-wSelect-style', wcj_plugin_url() . '/includes/lib/wSelect/wSelect.css');
     wp_enqueue_script('wcj-wSelect', wcj_plugin_url() . '/includes/lib/wSelect/wSelect.min.js', array(), false, true);
     wp_enqueue_script('wcj-wcj-wSelect', wcj_plugin_url() . '/includes/js/wcj-wSelect.js', array(), false, true);
 }
 /**
  * enqueue_scripts.
  *
  * @version 2.5.2
  * @since   2.5.0
  */
 function enqueue_scripts()
 {
     if (is_product()) {
         $the_product = wc_get_product();
         if ($this->is_bookings_product($the_product)) {
             wp_enqueue_script('wcj-bookings', wcj_plugin_url() . '/includes/js/wcj-bookings.js', array(), false, true);
             wp_localize_script('wcj-bookings', 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php'), 'product_id' => get_the_ID(), 'wrong_dates_message' => get_option('wcj_product_bookings_message_date_to_before_date_from', __('"Date to" must be after "Date from"', 'woocommerce-jetpack')), 'original_price_html' => $the_product->get_price_html()));
         }
     }
 }
 /**
  * enqueue_variable_add_to_cart_scripts.
  *
  * @version 2.4.8
  * @since   2.4.8
  */
 function enqueue_variable_add_to_cart_scripts()
 {
     wp_enqueue_script('wcj-variations', wcj_plugin_url() . '/includes/js/wcj-variations-frontend.js', array('jquery'));
 }