/**
  * add_custom_checkout_fields.
  *
  * @version 2.4.8
  */
 public function add_custom_checkout_fields($fields)
 {
     for ($i = 1; $i <= apply_filters('booster_get_option', 1, get_option('wcj_checkout_custom_fields_total_number', 1)); $i++) {
         if ('yes' === get_option('wcj_checkout_custom_field_enabled_' . $i)) {
             $categories_in = get_option('wcj_checkout_custom_field_categories_in_' . $i);
             if (!empty($categories_in)) {
                 $do_skip = true;
                 foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
                     $product_categories = get_the_terms($values['product_id'], 'product_cat');
                     if (empty($product_categories)) {
                         continue;
                     }
                     foreach ($product_categories as $product_category) {
                         if (in_array($product_category->term_id, $categories_in)) {
                             $do_skip = false;
                             break;
                         }
                     }
                     if (!$do_skip) {
                         break;
                     }
                 }
                 if ($do_skip) {
                     continue;
                 }
             }
             $products_in = get_option('wcj_checkout_custom_field_products_in_' . $i);
             if (!empty($products_in)) {
                 $do_skip = true;
                 foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
                     if (in_array($values['product_id'], $products_in)) {
                         $do_skip = false;
                         break;
                     }
                 }
                 if ($do_skip) {
                     continue;
                 }
             }
             $the_type = get_option('wcj_checkout_custom_field_type_' . $i);
             $custom_attributes = array();
             if ('datepicker' === $the_type || 'weekpicker' === $the_type || 'timepicker' === $the_type || 'number' === $the_type) {
                 if ('datepicker' === $the_type || 'weekpicker' === $the_type) {
                     $datepicker_format_option = get_option('wcj_checkout_custom_field_datepicker_format_' . $i, '');
                     $datepicker_format = '' == $datepicker_format_option ? get_option('date_format') : $datepicker_format_option;
                     $datepicker_format = wcj_date_format_php_to_js_v2($datepicker_format);
                     $custom_attributes['dateformat'] = $datepicker_format;
                     $custom_attributes['mindate'] = get_option('wcj_checkout_custom_field_datepicker_mindate_' . $i, -365);
                     $custom_attributes['maxdate'] = get_option('wcj_checkout_custom_field_datepicker_maxdate_' . $i, 365);
                     $custom_attributes['firstday'] = get_option('wcj_checkout_custom_field_datepicker_firstday_' . $i, 0);
                     if ('yes' === get_option('wcj_checkout_custom_field_datepicker_changeyear_' . $i, 'yes')) {
                         $custom_attributes['changeyear'] = 1;
                         $custom_attributes['yearrange'] = get_option('wcj_checkout_custom_field_datepicker_yearrange_' . $i, 'c-10:c+10');
                     }
                     $custom_attributes['display'] = 'datepicker' === $the_type ? 'date' : 'week';
                 } elseif ('timepicker' === $the_type) {
                     $custom_attributes['timeformat'] = get_option('wcj_checkout_custom_field_timepicker_format_' . $i, 'hh:mm p');
                     $custom_attributes['interval'] = get_option('wcj_checkout_custom_field_timepicker_interval_' . $i, 15);
                     $custom_attributes['display'] = 'time';
                 } else {
                     $custom_attributes['display'] = $the_type;
                 }
                 $the_type = 'text';
             }
             $the_section = get_option('wcj_checkout_custom_field_section_' . $i);
             $the_key = 'wcj_checkout_field_' . $i;
             $the_field = array('type' => $the_type, 'label' => get_option('wcj_checkout_custom_field_label_' . $i), 'placeholder' => get_option('wcj_checkout_custom_field_placeholder_' . $i), 'required' => 'yes' === get_option('wcj_checkout_custom_field_required_' . $i) ? true : false, 'custom_attributes' => $custom_attributes, 'clear' => 'yes' === get_option('wcj_checkout_custom_field_clear_' . $i) ? true : false, 'class' => array(get_option('wcj_checkout_custom_field_class_' . $i)));
             if ('select' === $the_type || 'radio' === $the_type) {
                 $select_options_raw = get_option('wcj_checkout_custom_field_select_options_' . $i);
                 $select_options = wcj_get_select_options($select_options_raw);
                 if ('select' === $the_type) {
                     $placeholder = get_option('wcj_checkout_custom_field_placeholder_' . $i);
                     if ('' != $placeholder) {
                         $select_options = array_merge(array('' => $placeholder), $select_options);
                     }
                 }
                 $the_field['options'] = $select_options;
                 if (!empty($select_options)) {
                     reset($select_options);
                     $the_field['default'] = key($select_options);
                 }
             }
             if ('checkbox' === $the_type) {
                 $the_field['default'] = 'yes' === get_option('wcj_checkout_custom_field_checkbox_default_' . $i) ? 1 : 0;
             }
             $fields[$the_section][$the_section . '_' . $the_key] = $the_field;
         }
     }
     return $fields;
 }
 /**
  * add_product_input_fields_to_frontend.
  *
  * @version 2.5.5
  */
 public function add_product_input_fields_to_frontend()
 {
     global $product;
     //if ( ! $product ) // return;
     $total_number = apply_filters('booster_get_option', 1, $this->get_value('wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $product->id, 1));
     for ($i = 1; $i <= $total_number; $i++) {
         $type = $this->get_value('wcj_product_input_fields_type_' . $this->scope . '_' . $i, $product->id, 'text');
         $is_enabled = $this->get_value('wcj_product_input_fields_enabled_' . $this->scope . '_' . $i, $product->id, 'no');
         $is_required = $this->get_value('wcj_product_input_fields_required_' . $this->scope . '_' . $i, $product->id, 'no');
         $title = $this->get_value('wcj_product_input_fields_title_' . $this->scope . '_' . $i, $product->id, '');
         $placeholder = $this->get_value('wcj_product_input_fields_placeholder_' . $this->scope . '_' . $i, $product->id, '');
         $datepicker_format = $this->get_value('wcj_product_input_fields_type_datepicker_format_' . $this->scope . '_' . $i, $product->id, '');
         if ('' == $datepicker_format) {
             $datepicker_format = get_option('date_format');
         }
         $datepicker_format = wcj_date_format_php_to_js_v2($datepicker_format);
         $datepicker_mindate = $this->get_value('wcj_product_input_fields_type_datepicker_mindate_' . $this->scope . '_' . $i, $product->id, -365);
         $datepicker_maxdate = $this->get_value('wcj_product_input_fields_type_datepicker_maxdate_' . $this->scope . '_' . $i, $product->id, 365);
         $datepicker_firstday = $this->get_value('wcj_product_input_fields_type_datepicker_firstday_' . $this->scope . '_' . $i, $product->id, 0);
         $datepicker_changeyear = $this->get_value('wcj_product_input_fields_type_datepicker_changeyear_' . $this->scope . '_' . $i, $product->id, 'no');
         $datepicker_yearrange = $this->get_value('wcj_product_input_fields_type_datepicker_yearrange_' . $this->scope . '_' . $i, $product->id, 'c-10:c+10');
         if ('on' === $datepicker_changeyear || 'yes' === $datepicker_changeyear) {
             $datepicker_year = 'changeyear="1" yearRange="' . $datepicker_yearrange . '" ';
         } else {
             $datepicker_year = '';
         }
         $timepicker_format = $this->get_value('wcj_product_input_fields_type_timepicker_format_' . $this->scope . '_' . $i, $product->id, 'hh:mm p');
         $timepicker_interval = $this->get_value('wcj_product_input_fields_type_timepicker_interval_' . $this->scope . '_' . $i, $product->id, 15);
         $file_accept = $this->get_value('wcj_product_input_fields_type_file_accept_' . $this->scope . '_' . $i, $product->id, '');
         $custom_attributes = 'file' === $type ? ' accept="' . $file_accept . '"' : '';
         $field_name = 'wcj_product_input_fields_' . $this->scope . '_' . $i;
         if ('on' === $is_required || 'yes' === $is_required) {
             $title .= get_option('wcj_product_input_fields_frontend_view_required_html', '&nbsp;<abbr class="required" title="required">*</abbr>');
         }
         if ('on' === $is_enabled || 'yes' === $is_enabled) {
             switch ($type) {
                 case 'number':
                 case 'text':
                 case 'file':
                 case 'password':
                 case 'email':
                 case 'tel':
                     echo '<p>' . $title . '<input type="' . $type . '" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
                     break;
                 case 'checkbox':
                     $checked = checked($this->get_value('wcj_product_input_fields_type_checkbox_default_' . $this->scope . '_' . $i, $product->id, 'no'), 'yes', false);
                     echo '<p>' . $title . '<input type="' . $type . '" name="' . $field_name . '"' . $custom_attributes . $checked . '>' . '</p>';
                     break;
                 case 'datepicker':
                     echo '<p>' . $title . '<input ' . $datepicker_year . 'firstday="' . $datepicker_firstday . '" dateformat="' . $datepicker_format . '" mindate="' . $datepicker_mindate . '" maxdate="' . $datepicker_maxdate . '" type="' . $type . '" display="date" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
                     break;
                 case 'weekpicker':
                     echo '<p>' . $title . '<input ' . $datepicker_year . 'firstday="' . $datepicker_firstday . '" dateformat="' . $datepicker_format . '" mindate="' . $datepicker_mindate . '" maxdate="' . $datepicker_maxdate . '" type="' . $type . '" display="week" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
                     break;
                 case 'timepicker':
                     echo '<p>' . $title . '<input interval="' . $timepicker_interval . '" timeformat="' . $timepicker_format . '" type="' . $type . '" display="time" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
                     break;
                 case 'textarea':
                     echo '<p>' . $title . '<textarea name="' . $field_name . '" placeholder="' . $placeholder . '">' . '</textarea>' . '</p>';
                     break;
                 case 'select':
                     $select_options_raw = $this->get_value('wcj_product_input_fields_type_select_options_' . $this->scope . '_' . $i, $product->id, '');
                     $select_options = wcj_get_select_options($select_options_raw, false);
                     if ('' != $placeholder) {
                         $select_options = array_merge(array('' => $placeholder), $select_options);
                     }
                     $select_options_html = '';
                     if (!empty($select_options)) {
                         reset($select_options);
                         $value = key($select_options);
                         foreach ($select_options as $select_option_key => $select_option_title) {
                             $select_options_html .= '<option value="' . $select_option_key . '" ' . selected($value, $select_option_key, false) . '>';
                             $select_options_html .= $select_option_title;
                             $select_options_html .= '</option>';
                         }
                     }
                     echo '<p>' . $title . '<select name="' . $field_name . '">' . $select_options_html . '</select>' . '</p>';
                     break;
                 case 'radio':
                     $select_options_raw = $this->get_value('wcj_product_input_fields_type_select_options_' . $this->scope . '_' . $i, $product->id, '');
                     $select_options = wcj_get_select_options($select_options_raw, false);
                     $select_options_html = '';
                     //$label_id = current( array_keys( $args['options'] ) );
                     if (!empty($select_options)) {
                         reset($select_options);
                         $value = key($select_options);
                         foreach ($select_options as $option_key => $option_text) {
                             $select_options_html .= '<input type="radio" class="input-radio" value="' . esc_attr($option_key) . '" name="' . $field_name . '" id="' . $field_name . '_' . esc_attr($option_key) . '"' . checked($value, $option_key, false) . ' />';
                             $select_options_html .= '<label for="' . $field_name . '_' . esc_attr($option_key) . '" class="radio">' . $option_text . '</label><br>';
                         }
                         echo '<p>' . $title . $select_options_html . '</p>';
                     }
                     break;
                 case 'country':
                     $countries = WC()->countries->get_allowed_countries();
                     if (sizeof($countries) > 1) {
                         $value = key($countries);
                         $field = '<select name="' . $field_name . '" id="' . $field_name . '" class="country_to_state country_select">' . '<option value="">' . __('Select a country&hellip;', 'woocommerce') . '</option>';
                         foreach ($countries as $ckey => $cvalue) {
                             $field .= '<option value="' . esc_attr($ckey) . '" ' . selected($value, $ckey, false) . '>' . __($cvalue, 'woocommerce') . '</option>';
                         }
                         $field .= '</select>';
                         echo '<p>' . $title . $field . '</p>';
                     }
                     break;
                     /* case 'state' : // from woocommerce_form_field()
                     
                     						// Get Country
                     						$country_key = $key == 'billing_state'? 'billing_country' : 'shipping_country';
                     						$current_cc  = WC()->checkout->get_value( $country_key );
                     						$states      = WC()->countries->get_states( $current_cc );
                     
                     						if ( is_array( $states ) && empty( $states ) ) {
                     
                     							$field_container = '<p class="form-row %1$s" id="%2$s" style="display: none">%3$s</p>';
                     
                     							$field .= '<input type="hidden" class="hidden" name="' . esc_attr( $key )  . '" id="' . esc_attr( $args['id'] ) . '" value="" ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '" />';
                     
                     						} elseif ( is_array( $states ) ) {
                     
                     							$field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="state_select ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '">
                     								<option value="">'.__( 'Select a state&hellip;', 'woocommerce' ) .'</option>';
                     
                     							foreach ( $states as $ckey => $cvalue ) {
                     								$field .= '<option value="' . esc_attr( $ckey ) . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue, 'woocommerce' ) .'</option>';
                     							}
                     
                     							$field .= '</select>';
                     
                     						} else {
                     
                     							$field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" value="' . esc_attr( $value ) . '"  placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
                     
                     						}
                     
                     						break; */
             }
         }
     }
 }