Example #1
0
 public function init_options()
 {
     $session_name = wc2_get_option('session_name');
     if (empty($session_name)) {
         $session_name = $this->plugin_slug . mt_rand(1000, 9999);
         wc2_update_option('session_name', $session_name);
     }
     /*-------------------------------
     			基本設定オプション初期値
     		---------------------------------*/
     $general = wc2_get_option('general');
     if (!isset($general['campaign_category'])) {
         $general['campaign_category'] = 0;
     }
     if (!isset($general['campaign_privilege'])) {
         $general['campaign_privilege'] = '';
     }
     if (!isset($general['privilege_point'])) {
         $general['privilege_point'] = '';
     }
     if (!isset($general['privilege_discount'])) {
         $general['privilege_discount'] = '';
     }
     if (!isset($general['company_name'])) {
         $general['company_name'] = '';
     }
     if (!isset($general['zip_code'])) {
         $general['zip_code'] = '';
     }
     if (!isset($general['address1'])) {
         $general['address1'] = '';
     }
     if (!isset($general['address2'])) {
         $general['address2'] = '';
     }
     if (!isset($general['tel_number'])) {
         $general['tel_number'] = '';
     }
     if (!isset($general['fax_number'])) {
         $general['fax_number'] = '';
     }
     if (!isset($general['order_mail'])) {
         $general['order_mail'] = '';
     }
     if (!isset($general['inquiry_mail'])) {
         $general['inquiry_mail'] = '';
     }
     if (!isset($general['sender_mail'])) {
         $general['sender_mail'] = '';
     }
     if (!isset($general['error_mail'])) {
         $general['error_mail'] = '';
     }
     if (!isset($general['copyright'])) {
         $general['copyright'] = '';
     }
     if (!isset($general['postage_privilege'])) {
         $general['postage_privilege'] = '';
     }
     if (!isset($general['purchase_limit'])) {
         $general['purchase_limit'] = '';
     }
     if (!isset($general['shipping_rule'])) {
         $general['shipping_rule'] = '';
     }
     if (!isset($general['tax_rate'])) {
         $general['tax_rate'] = '';
         $general['tax_method'] = 'cutting';
         $general['tax_mode'] = 'include';
         $general['tax_target'] = 'products';
     } else {
         if (!isset($general['tax_mode'])) {
             $general['tax_mode'] = empty($general['tax_rate']) ? 'include' : 'exclude';
         }
         if (!isset($general['tax_target'])) {
             $general['tax_target'] = 'all';
         }
     }
     if (!isset($general['add2cart'])) {
         $general['add2cart'] = '0';
     }
     if (!isset($general['membersystem_state'])) {
         $general['membersystem_state'] = 'activate';
     }
     if (!isset($general['membersystem_point'])) {
         $general['membersystem_point'] = 'activate';
     }
     if (!isset($general['point_rate'])) {
         $general['point_rate'] = '';
     }
     if (!isset($general['start_point'])) {
         $general['start_point'] = '';
     }
     if (!isset($general['point_coverage'])) {
         $general['point_coverage'] = 1;
     }
     if (!isset($general['point_assign'])) {
         $general['point_assign'] = 1;
     }
     if (!isset($general['member_pass_rule_min']) || empty($general['member_pass_rule_min'])) {
         $general['member_pass_rule_min'] = 6;
     }
     if (!isset($general['member_pass_rule_max']) || empty($general['member_pass_rule_max'])) {
         $general['member_pass_rule_max'] = '';
     }
     if (!isset($general['indi_item_name'])) {
         $general['indi_item_name']['item_name'] = 1;
         $general['indi_item_name']['item_code'] = 1;
         $general['indi_item_name']['sku_name'] = 1;
         $general['indi_item_name']['sku_code'] = 1;
         $general['pos_item_name']['item_name'] = 1;
         $general['pos_item_name']['item_code'] = 2;
         $general['pos_item_name']['sku_name'] = 3;
         $general['pos_item_name']['sku_code'] = 4;
     }
     wc2_update_option('general', $general);
     $cart_description = wc2_get_option('cart_description');
     $member_description = wc2_get_option('member_description');
     if (!isset($cart_description['cart_header'])) {
         $cart_description['cart_header'] = array('top' => '', 'customer' => '', 'delivery' => '', 'confirm' => '', 'complete' => '');
     }
     if (!isset($cart_description['cart_footer'])) {
         $cart_description['cart_footer'] = array('top' => '', 'customer' => '', 'delivery' => '', 'confirm' => '', 'complete' => '');
     }
     if (!isset($member_description['member_header'])) {
         $member_description['member_header'] = array('login' => '', 'newmemberform' => '', 'lostpassword' => '', 'changepassword' => '', 'memberform' => '', 'complete' => '');
     }
     if (!isset($member_description['member_footer'])) {
         $member_description['member_footer'] = array('login' => '', 'newmemberform' => '', 'lostpassword' => '', 'changepassword' => '', 'memberform' => '', 'complete' => '');
     }
     wc2_update_option('cart_description', $cart_description);
     wc2_update_option('member_description', $member_description);
     $this->check_display_mode();
     /*---------------------------------
     			メール設定オプション初期値
     		----------------------------------*/
     $phrase = wc2_get_option('phrase');
     $phrase_default = wc2_get_option('phrase_default');
     if (!isset($phrase['title'])) {
         foreach ((array) $phrase_default['title'] as $key => $value) {
             $phrase['title'][$key] = $value;
         }
     }
     if (!isset($phrase['header'])) {
         foreach ((array) $phrase_default['header'] as $key => $value) {
             $phrase['header'][$key] = $value;
         }
     }
     if (!isset($phrase['footer'])) {
         foreach ((array) $phrase_default['footer'] as $key => $value) {
             $phrase['footer'][$key] = $value;
         }
     }
     wc2_update_option('phrase', $phrase);
     /*---------------------------------
     			配送設定オプション初期値
     		-----------------------------------/
     
     
     		/*---------------------------------
     			システム設定オプション初期値
     		 ----------------------------------*/
     $system_options = wc2_get_option('system');
     if (!isset($system_options['addressform'])) {
         $system_options['addressform'] = wc2_get_local_addressform();
     }
     //住所様式
     if (!isset($system_options['target_market'])) {
         $system_options['target_market'] = wc2_get_local_target_market();
     }
     //販売対象国
     if (!isset($system_options['mem_option_digit'])) {
         $system_options['mem_option_digit'] = 5;
     }
     //会員コード桁数
     if (!isset($system_options['currency'])) {
         $system_options['currency'] = wc2_get_base_country();
     }
     if (!isset($system_options['base_country'])) {
         $system_options['base_country'] = wc2_get_base_country();
     }
     if (!isset($system_options['divide_item'])) {
         $system_options['divide_item'] = 0;
     }
     //表示モード
     if (!isset($system_options['itemimg_anchor_rel'])) {
         $system_options['itemimg_anchor_rel'] = '';
     }
     //rel属性
     if (!isset($system_options['composite_category_orderby'])) {
         $system_options['composite_category_orderby'] = 'ID';
     }
     //複合カテゴリーソート項目
     if (!isset($system_options['composite_category_order'])) {
         $system_options['composite_category_order'] = 'ASC';
     }
     //複合カテゴリーソート順
     if (!isset($system_options['use_ssl'])) {
         $system_options['use_ssl'] = 0;
     }
     //SSLを使用する
     if (!isset($system_options['ssl_url_admin'])) {
         $system_options['ssl_url_admin'] = '';
     }
     //WordPress のアドレス (SSL)
     if (!isset($system_options['ssl_url'])) {
         $system_options['ssl_url'] = '';
     }
     //ブログのアドレス (SSL)
     if (!isset($system_options['inquiry_id'])) {
         $system_options['inquiry_id'] = '';
     }
     if (!isset($system_options['no_cart_css'])) {
         $system_options['no_cart_css'] = 0;
     }
     if (!isset($system_options['dec_orderID_flag'])) {
         $system_options['dec_orderID_flag'] = 0;
     }
     if (!isset($system_options['dec_orderID_prefix'])) {
         $system_options['dec_orderID_prefix'] = '';
     }
     if (!isset($system_options['dec_orderID_digit'])) {
         $system_options['dec_orderID_digit'] = 8;
     }
     if (!isset($system_options['subimage_rule'])) {
         $system_options['subimage_rule'] = 1;
     }
     if (!isset($system_options['pdf_delivery'])) {
         $system_options['system']['pdf_delivery'] = 0;
     }
     if (!isset($system_options['csv_encode_type'])) {
         $system_options['csv_encode_type'] = 0;
     }
     //$system['currency'] = wc2_get_base_country();
     //$system['base_country'] = wc2_get_base_country();
     wc2_update_option('system', $system_options);
     /*------------------------------
     		支払設定オプション初期値
     	 -------------------------------*/
     //$payment_method = wc2_get_option( 'payment_method' );
     //if( !$payment_method ) $payment_method = array();
     $settlement_types = wc2_get_option('settlement_types');
     if (!$settlement_types) {
         $settlement_types = array('BT' => __('Bank transfer', 'wc2'), 'COD' => __('COD', 'wc2'));
     }
     wc2_update_option('settlement_types', $settlement_types);
     $payment_info = wc2_get_option('payment_info');
     if (!isset($payment_info['cod_type'])) {
         $payment_info['cod_type'] = 'fix';
     }
     wc2_update_option('payment_info', $payment_info);
     do_action('wc2_init_option');
 }
Example #2
0
	public function set_entry() {

		$_POST = wc2_stripslashes_deep_post( $_POST );

		if( isset($_SESSION[WC2]['member']['ID']) && !empty($_SESSION[WC2]['member']['ID']) ) {
			if( $_REQUEST['cart'] != 'confirm' ) {
				foreach( $_SESSION[WC2]['member'] as $key => $value ) {
					switch( $key ) {
					case 'ID':
					case 'passwd':
					case 'rank':
					case 'point':
					case 'registered':
						break;

					case WC2_CUSTOM_MEMBER:
						foreach( $value as $mbkey => $mbvalue ) {
							if( empty($_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$mbkey]) ) {
								if( is_array($mbvalue) ) {
									foreach( $mbvalue as $k => $v ) {
										$_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$mbkey][$v] = $v;
									}
								} else {
									$_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$mbkey] = $mbvalue;
								}
							}
						}
						break;

					case 'country':
						$_SESSION[WC2]['entry']['customer'][$key] = ( empty($value) ) ? wc2_get_base_country() : $value;
						break;

					default:
						if( is_array($value) ) {
							foreach( $value as $k => $v ) {
								$_SESSION[WC2]['entry']['customer'][$k] = $v;
							}
						} else {
							$_SESSION[WC2]['entry']['customer'][$key] = $value;
						}
					}
				}
			}
		}

		if( isset($_POST['customer']) ) {
			foreach( $_POST['customer'] as $key => $value ) {
				if( 'passwd' == $key || 'passwd2' == $key ){
					continue;
				}
				if( 'country' == $key && empty($value) ) {
					$_SESSION[WC2]['entry']['customer'][$key] = wc2_get_base_country();
				} else {
					$_SESSION[WC2]['entry']['customer'][$key] = $value;
				}
			}
		}

		if( isset($_POST['delivery']) ) {
			foreach( $_POST['delivery'] as $key => $value ) {
				if( 'country' == $key && empty($value) ){
					$_SESSION[WC2]['entry']['delivery'][$key] = wc2_get_base_country();
				} else{
					$_SESSION[WC2]['entry']['delivery'][$key] = $value;
				}
			}
		}

		if( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 0 ) {
			foreach( $_SESSION[WC2]['entry']['customer'] as $key => $value ) {
				if( 'country' == $key && empty($value) ) {
					$_SESSION[WC2]['entry']['delivery'][$key] = wc2_get_base_country();
				} else {
					$_SESSION[WC2]['entry']['delivery'][$key] = $value;
				}
			}
		}

		if( isset($_POST['offer']) ) {
			foreach( $_POST['offer'] as $key => $value ) {
				$_SESSION[WC2]['entry']['order'][$key] = $value;
			}
		}

		if( isset($_SESSION[WC2]['entry']['delivery']['delivery_flag']) && $_SESSION[WC2]['entry']['delivery']['delivery_flag'] == 0 ) {
			self::set_custom_customer_delivery();
		}

/*
		if( isset($_POST[WC2_CUSTOM_ORDER]) ) {
			unset($_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER]);
			foreach( $_POST[WC2_CUSTOM_ORDER] as $key => $value ) {
				if( is_array($value) ) {
					foreach( $value as $k => $v ) {
						$_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER][$key][$v] = $v;
					}
				} else {
					$_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER][$key] = $value;
				}
			}
		}

		if( isset($_POST[WC2_CUSTOM_CUSTOMER]) ) {
			unset($_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER]);
			foreach( $_POST[WC2_CUSTOM_CUSTOMER] as $key => $value ) {
				if( is_array($value) ) {
					foreach( $value as $k => $v ) {
						$_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$key][$v] = $v;
					}
				} else {
					$_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$key] = $value;
				}
			}
		}

		if( isset($_POST[WC2_CUSTOM_DELIVERY]) ) {
			unset($_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY]);
			foreach( $_POST[WC2_CUSTOM_DELIVERY] as $key => $value ) {
				if( is_array($value) ) {
					foreach( $value as $k => $v ) {
						$_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY][$key][$v] = $v;
					}
				} else {
					$_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY][$key] = $value;
				}
			}
		}
*/

		if( isset($_POST['wcaction']) && 'delivery_process' == $_POST['wcaction'] ){
			//csod
			if( isset( $_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER] ) ){
				unset($_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER]);
			}
			$csod_keys = wc2_get_custom_field_keys(WC2_CSOD);

			if( !empty($csod_keys) && is_array($csod_keys) ){
				foreach($csod_keys as $key){
					list( $pfx, $csod_key ) = explode('_', $key, 2);
					$csod_val = ( isset( $_POST[WC2_CUSTOM_ORDER][$csod_key] ) ) ? $_POST[WC2_CUSTOM_ORDER][$csod_key]: '';
					$_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER][$csod_key] = $csod_val;

				}
			}

			//csde
			if( isset( $_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY] ) ){
				unset($_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY]);
			}
			$csde_keys = wc2_get_custom_field_keys(WC2_CSDE);
			if( !empty($csde_keys) && is_array($csde_keys) ){
				foreach($csde_keys as $key){
					list( $pfx, $csde_key ) = explode('_', $key, 2);
					$csde_val = ( isset( $_POST[WC2_CUSTOM_DELIVERY][$csde_key] ) ) ? $_POST[WC2_CUSTOM_DELIVERY][$csde_key]: '';
					$_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY][$csde_key] = $csde_val;
				}
			}
		}elseif( isset($_POST['wcaction']) && 'customer_process' == $_POST['wcaction'] ) {
			//cscs
			if( isset( $_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER] ) ){
				unset($_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER]);
			}
			$cscs_keys = wc2_get_custom_field_keys(WC2_CSCS);
			if( !empty($cscs_keys) && is_array($cscs_keys) ){
				foreach($cscs_keys as $key){
					list( $pfx, $cscs_key ) = explode('_', $key, 2);
					$cscs_val = ( isset( $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key] ) ) ? $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key]: '';
					$_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$cscs_key] = $cscs_val;
				}
			}
		}

		if( ( isset($_SESSION[WC2]['entry']['delivery']['delivery_flag']) && $_SESSION[WC2]['entry']['delivery']['delivery_flag'] == 0 ) || 
			( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 0 ) ) {
			self::set_custom_customer_delivery();
		}

		do_action( 'wc2_action_set_entry' );
	}
Example #3
0
	/**
	 * Delivery input check
	 *
	 */
	public function delivery_check() {
		$mes = array();
		if( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) {
			//氏名
			if ( WC2_Utils::is_blank($_POST['delivery']['name1']) || WC2_Utils::is_blank($_POST['delivery']['name2']) ){
				$mes[] = __('氏名を入力してください。', 'wc2');
			}
			//郵便番号
			if ( WC2_Utils::is_blank($_POST['delivery']['zipcode']) ){
				$mes[] = __('郵便番号が入力されていません。', 'wc2');
			}elseif( preg_match('/[^\d-]/', trim($_POST['delivery']['zipcode'])) ){
				$mes[] = __('郵便番号は半角数字で入力してください。', 'wc2');
			}
			//都道府県
			if ( WC2_UNSELECTED == ($_POST['delivery']['pref']) )
				$mes[] = __('都道府県が選択されていません。', 'wc2');
			//市区町村・番地
			if ( WC2_Utils::is_blank($_POST['delivery']['address1']) )
				$mes[] = __('市区町村・番地が入力されていません。', 'wc2');
			//電話番号
			if( WC2_Utils::is_blank($_POST['delivery']['tel']) ){
				$mes[] = __('電話番号が入力されていません。', 'wc2');
			}elseif( !WC2_Utils::is_blank($_POST['delivery']['tel']) && preg_match('/[^\d]/', trim($_POST['delivery']['tel'])) ){
				$mes[] = __('電話番号は半角数字で入力してください。', 'wc2');
			}
		}
		if( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WC2_Utils::is_zero($_POST['offer']['delivery_method'])) )
			$mes[] = __('配送方法を選択してください。', 'wc2');
		if( !isset($_POST['offer']['payment_method']) ) {
			$mes[] = __('支払方法を選択してください。', 'wc2');
		} else {
			$entry_data = wc2_get_entry();
			$delivery = wc2_get_option( 'delivery' );
			$general = wc2_get_option( 'general' );
			$payment = wc2_get_payment( $_POST['offer']['payment_method'] );
			if( 'COD' == $payment['settlement'] ) {
				$item_total_price = wc2_get_item_total_price();
				$materials = array(
					'total_price' => $item_total_price,
					'discount' => $entry_data['order']['discount'],
					'shipping_charge' => $entry_data['order']['shipping_charge'],
					'cod_fee' => $entry_data['order']['cod_fee'],
				);
				$item_total_price += wc2_get_tax( $materials );
				$cod_limit_amount = ( isset($general['cod_limit_amount']) && 0 < (int)$general['cod_limit_amount'] ) ? $general['cod_limit_amount'] : 0;
				if( 0 < $cod_limit_amount && $item_total_price > $cod_limit_amount )
					$mes[] = sprintf(__('商品合計金額が、代引きでご購入できる上限額(%s)を超えています。', 'wc2'), wc2_crform( $general['cod_limit_amount'], true, false ));
			}

			$d_method_index = wc2_get_delivery_method_index( (int)$_POST['offer']['delivery_method'] );
			if( $delivery['delivery_method'][$d_method_index]['nocod'] == 1 ) {
				if('COD' == $payment['settlement'])
					$mes[] = __('この配送方法では、代引きはご利用できません。', 'wc2');
			}

			$country = $entry_data['delivery']['country'];
			$local_country = wc2_get_base_country();
			if( $country == $local_country ) {
				if( $delivery['delivery_method'][$d_method_index]['intl'] == 1 ) {
					$mes[] = __('配送方法が誤っています。国際便は指定できません。', 'wc2');
				}
			} else {
				if( WC2_Utils::is_zero($delivery['delivery_method'][$d_method_index]['intl']) ) {
					$mes[] = __('配送方法が誤っています。国際便を指定してください。', 'wc2');
				}
			}
		}
	
		//custom_delivery check
		$csde_mes = wc2_custom_field_enter_check('delivery');
		foreach( $csde_mes as $csde_mes_val ){
			$mes[] = $csde_mes_val;
		}

		//custom_order check
		$csod_mes = wc2_custom_field_enter_check('order');
		foreach( $csod_mes as $csod_mes_val ){
			$mes[] = $csod_mes_val;
		}

		$mes = apply_filters( 'wc2_filter_delivery_check', $mes );
		return $mes;
	}
Example #4
0
function wc2_get_shipping_charge($d_method_id, $pref, $country = '', $cart = array())
{
    if (empty($country)) {
        $country = wc2_get_base_country();
    }
    if (empty($cart) and !is_admin()) {
        $cart = wc2_get_cart();
    }
    //if( empty($entry_data) )
    //	$entry_data = wc2_get_entry();
    /*	if( function_exists( 'dlseller_have_shipped' ) && !dlseller_have_shipped() ) {
    		$charge = 0;
    		$charge = apply_filters( 'wc2_filter_get_shipping_charge', $charge, $cart, $entry_data );
    		return $charge;
    	}
    */
    $delivery = wc2_get_option('delivery');
    $delivery_method = isset($delivery['delivery_method']) ? $delivery['delivery_method'] : array();
    $shipping_charge = wc2_get_option('shipping_charge');
    //配送方法ID
    //$d_method_id = $entry_data['order']['delivery_method'];
    //配送方法index
    $d_method_index = wc2_get_delivery_method_index($d_method_id);
    //送料ID
    $fixed_charge_id = isset($delivery_method[$d_method_index]['charge']) ? $delivery_method[$d_method_index]['charge'] : -1;
    $individual_quant = 0;
    $charges = array();
    $individual_charges = array();
    foreach ($cart as $row) {
        if (-1 == $fixed_charge_id) {
            //商品送料ID
            $s_charge_id = wc2_get_item_value_by_item_id($row['item_id'], ITEM_SHIPPING_CHARGE);
            //商品送料index
            $s_charge_index = wc2_get_shipping_charge_index($s_charge_id);
            $charge = isset($shipping_charge[$s_charge_index][$country][$pref]) ? $shipping_charge[$s_charge_index][$country][$pref] : 0;
        } else {
            $s_charge_index = wc2_get_shipping_charge_index($fixed_charge_id);
            $charge = isset($shipping_charge[$s_charge_index][$country][$pref]) ? $shipping_charge[$s_charge_index][$country][$pref] : 0;
        }
        $item_individual_shipping_charges = wc2_get_item_value_by_item_id($row['item_id'], ITEM_INDIVIDUAL_SHIPPING_CHARGES);
        if ($item_individual_shipping_charges) {
            $individual_quant += $row['quantity'];
            $individual_charges[] = $row['quantity'] * $charge;
        } else {
            $charges[] = $charge;
        }
    }
    if (0 < count($charges)) {
        rsort($charges);
        $max_charge = $charges[0];
        $charge = $max_charge + array_sum($individual_charges);
    } else {
        $charge = array_sum($individual_charges);
    }
    $charge = apply_filters('wc2_filter_get_shipping_charge', $charge, $cart);
    return $charge;
}
Example #5
0
 static function get_pref_select($type, $values)
 {
     $system_options = wc2_get_option('system');
     $country = empty($values['country']) ? wc2_get_base_country() : $values['country'];
     if (!in_array($country, $system_options['target_market'])) {
         $country = $system_options['target_market'][0];
     }
     $prefs = WC2_Funcs::get_states($country);
     $html = '<select name="' . esc_attr($type . '[pref]') . '" id="' . esc_attr($type) . '_pref" class="pref">';
     $prefs_count = count($prefs);
     if ($prefs_count > 0) {
         $select = __('-- 選択 --', 'wc2');
         $html .= '<option value="' . esc_attr(WC2_UNSELECTED) . '">' . esc_html($select) . "</option>\n";
         for ($i = 0; $i < $prefs_count; $i++) {
             $html .= '<option value="' . esc_attr($prefs[$i]) . '"' . ($prefs[$i] == $values['pref'] ? ' selected="selected"' : '') . '>' . esc_html($prefs[$i]) . "</option>\n";
         }
     }
     $html .= "</select>\n";
     return $html;
 }
 public function system_setting_page()
 {
     if (!isset($this->plugin_screen_hook_suffix)) {
         return;
     }
     $screen = get_current_screen();
     if ($this->plugin_screen_hook_suffix != $screen->id) {
         return;
     }
     $system_options = wc2_get_option('system');
     $states = wc2_get_option('states_options');
     $locale = wc2_get_option('locale_options');
     if (array_key_exists('wc2_option_update', $_POST)) {
         $this->action_status = 'success';
         $_POST = WC2_Utils::stripslashes_deep_post($_POST);
         $system_options['divide_item'] = isset($_POST['divide_item']) ? 1 : 0;
         $system_options['itemimg_anchor_rel'] = isset($_POST['itemimg_anchor_rel']) ? trim($_POST['itemimg_anchor_rel']) : '';
         $system_options['composite_category_orderby'] = isset($_POST['composite_category_orderby']) ? $_POST['composite_category_orderby'] : '';
         $system_options['composite_category_order'] = isset($_POST['composite_category_order']) ? $_POST['composite_category_order'] : '';
         $system_options['settlement_path'] = isset($_POST['settlement_path']) ? $_POST['settlement_path'] : '';
         if (WC2_Utils::is_blank($system_options['settlement_path'])) {
             $system_options['settlement_path'] = WC2_PLUGIN_DIR . '/settlement/';
         }
         $sl = substr($system_options['settlement_path'], -1);
         if ($sl != '/' && $sl != '\\') {
             $system_options['settlement_path'] .= '/';
         }
         $system_options['logs_path'] = isset($_POST['logs_path']) ? $_POST['logs_path'] : '';
         if (!WC2_Utils::is_blank($system_options['logs_path'])) {
             $sl = substr($system_options['logs_path'], -1);
             if ($sl == '/' || $sl == '\\') {
                 $system_options['logs_path'] = substr($system_options['logs_path'], 0, -1);
             }
         }
         $system_options['use_ssl'] = isset($_POST['use_ssl']) ? 1 : 0;
         $system_options['ssl_url'] = isset($_POST['ssl_url']) ? rtrim($_POST['ssl_url'], '/') : '';
         $system_options['ssl_url_admin'] = isset($_POST['ssl_url_admin']) ? rtrim($_POST['ssl_url_admin'], '/') : '';
         if (WC2_Utils::is_blank($system_options['ssl_url']) || WC2_Utils::is_blank($system_options['ssl_url_admin'])) {
             $system_options['use_ssl'] = 0;
         }
         $system_options['inquiry_id'] = isset($_POST['inquiry_id']) ? esc_html(rtrim($_POST['inquiry_id'])) : '';
         $system_options['use_javascript'] = isset($_POST['use_javascript']) ? (int) $_POST['use_javascript'] : 1;
         $system_options['front_lang'] = isset($_POST['front_lang']) && 'others' != $_POST['front_lang'] ? $_POST['front_lang'] : wc2_get_local_language();
         $system_options['currency'] = isset($_POST['currency']) && 'others' != $_POST['currency'] ? $_POST['currency'] : wc2_get_base_country();
         $system_options['addressform'] = isset($_POST['addressform']) ? $_POST['addressform'] : wc2_get_local_addressform();
         $system_options['target_market'] = isset($_POST['target_market']) ? $_POST['target_market'] : wc2_get_local_target_market();
         $system_options['no_cart_css'] = isset($_POST['no_cart_css']) ? 1 : 0;
         $system_options['dec_orderID_flag'] = isset($_POST['dec_orderID_flag']) ? (int) $_POST['dec_orderID_flag'] : 0;
         $system_options['dec_orderID_prefix'] = isset($_POST['dec_orderID_prefix']) ? esc_html(rtrim($_POST['dec_orderID_prefix'])) : '';
         $system_options['pdf_delivery'] = isset($_POST['pdf_delivery']) ? (int) $_POST['pdf_delivery'] : 0;
         $system_options['csv_encode_type'] = isset($_POST['csv_encode_type']) ? (int) $_POST['csv_encode_type'] : 0;
         if (isset($_POST['dec_orderID_digit'])) {
             $dec_orderID_digit = (int) rtrim($_POST['dec_orderID_digit']);
             if (6 > $dec_orderID_digit) {
                 $system_options['dec_orderID_digit'] = 6;
             } else {
                 $system_options['dec_orderID_digit'] = $dec_orderID_digit;
             }
         } else {
             $system_options['dec_orderID_digit'] = 6;
         }
         $system_options['subimage_rule'] = isset($_POST['subimage_rule']) ? (int) $_POST['subimage_rule'] : 0;
         unset($system_options['province']);
         foreach ((array) $system_options['target_market'] as $target_market) {
             $province = array();
             if (!empty($_POST['province_' . $target_market])) {
                 $temp_pref = explode("\n", $_POST['province_' . $target_market]);
                 foreach ($temp_pref as $pref) {
                     if (!WC2_Utils::is_blank($pref)) {
                         $province[] = trim($pref);
                     }
                 }
                 if (1 == count($province)) {
                     $this->action_status = 'error';
                 }
             } else {
                 if (isset($states[$target_market]) && is_array($states[$target_market])) {
                     $province = $states[$target_market];
                 } else {
                     $this->action_status = 'error';
                 }
             }
             $system_options['province'][$target_market] = $province;
         }
         if ($this->action_status != 'success') {
             $this->action_message = __('データに不備があります', 'wc2');
         } else {
             wc2_update_option('system', $system_options);
             $this->action_message = __('Updated!');
         }
     } else {
         if (!isset($system_options['province']) || empty($system_options['province'])) {
             $system_options['province'][$system_options['base_country']] = $states[$system_options['base_country']];
         }
         $this->action_status = 'none';
         $this->action_message = '';
     }
     $status = $this->action_status;
     $message = $this->action_message;
     $divide_item = $system_options['divide_item'];
     $itemimg_anchor_rel = $system_options['itemimg_anchor_rel'];
     $composite_category_orderby = $system_options['composite_category_orderby'];
     $composite_category_order = $system_options['composite_category_order'];
     $logs_path = isset($system_options['logs_path']) ? $system_options['logs_path'] : '';
     $use_ssl = $system_options['use_ssl'];
     $ssl_url = $system_options['ssl_url'];
     $ssl_url_admin = $system_options['ssl_url_admin'];
     $inquiry_id = $system_options['inquiry_id'];
     $orderby_itemsku = isset($system_options['orderby_itemsku']) ? $system_options['orderby_itemsku'] : 0;
     $orderby_itemopt = isset($system_options['orderby_itemopt']) ? $system_options['orderby_itemopt'] : 0;
     $system_front_lang = isset($system_options['front_lang']) && !empty($system_options['front_lang']) ? $system_options['front_lang'] : wc2_get_local_language();
     $system_currency = isset($system_options['currency']) && !empty($system_options['currency']) ? $system_options['currency'] : wc2_get_base_country();
     $system_addressform = isset($system_options['addressform']) && !empty($system_options['addressform']) ? $system_options['addressform'] : wc2_get_local_addressform();
     $system_target_markets = isset($system_options['target_market']) && !empty($system_options['target_market']) ? $system_options['target_market'] : wc2_get_local_target_market();
     $no_cart_css = isset($system_options['no_cart_css']) ? $system_options['no_cart_css'] : 0;
     $dec_orderID_flag = isset($system_options['dec_orderID_flag']) ? $system_options['dec_orderID_flag'] : 0;
     $dec_orderID_prefix = isset($system_options['dec_orderID_prefix']) ? $system_options['dec_orderID_prefix'] : '';
     $dec_orderID_digit = isset($system_options['dec_orderID_digit']) ? $system_options['dec_orderID_digit'] : '';
     $subimage_rule = isset($system_options['subimage_rule']) ? $system_options['subimage_rule'] : 0;
     $pdf_delivery = isset($system_options['pdf_delivery']) ? $system_options['pdf_delivery'] : 0;
     $csv_encode_type = isset($system_options['csv_encode_type']) ? $system_options['csv_encode_type'] : 0;
     require_once WC2_PLUGIN_DIR . '/admin/views/setting-system.php';
 }