Example #1
0
	/**
	 * Initialize the plugin by setting localization and loading public scripts
	 * and styles.
	 *
	 * @since     1.0.0
	 */
	private function __construct() {

		global $wc2_order, $wc2_cart, $wc2_member, $wc2_options;

		/*
		 * Call $plugin_slug from public plugin class.
		 *
		 * @TODO:
		 *
		 * - Rename "Plugin_Name" to the name of your initial plugin class
		 *
		 */
		$plugin = Welcart2::get_instance();
		$this->plugin_slug = $plugin->get_plugin_slug();
		$this->version = Welcart2::VERSION;

		//session_name( $wc2_options['session_name'] );
		$session_name = wc2_get_option( 'session_name' );
		session_name( $session_name );
		session_set_cookie_params ( 0, COOKIEPATH, $_SERVER['SERVER_NAME'], false, true );
		if ( !session_id() ) {
			session_start();
		}

		$this->page = new WC2_Page();

		$this->control();
	}
Example #2
0
 function send_admin_mail()
 {
     $res = false;
     $general = wc2_get_option('general');
     $para = array('to_name' => $this->mail_data['admin_para']['to_name'], 'to_address' => $this->mail_data['admin_para']['to_address'], 'from_name' => $this->mail_data['admin_para']['from_name'], 'from_address' => $this->mail_data['admin_para']['from_address'], 'return_path' => $this->mail_data['admin_para']['return_path'], 'subject' => $this->mail_data['admin_para']['subject'], 'message' => do_shortcode($this->mail_data['admin_para']['message']));
     $res = $this->send_mail($para);
     return $res;
 }
Example #3
0
	/**
	 * Constructor
	 *
	 */
	function __construct( $slug = '' ) {
		if( $slug == '' ) {
			$slug = apply_filters( 'wc2_filter_cart_slug', 'cart' );
		}
		$this->set_cart_slug( $slug );
		if( !isset( $_SESSION[WC2][$slug] ) )
			$_SESSION[WC2][$slug] = array();
		$general = wc2_get_option( 'general' );
		self::$add2cart = $general['add2cart'];
	}
Example #4
0
function wc2_sort_admin_option($option_name, $idstr)
{
    $option_value = wc2_get_option($option_name);
    if (!empty($option_value)) {
        $ids = explode(',', $idstr);
        $c = 0;
        foreach ((array) $ids as $id) {
            $option_value[$id]['sort'] = $c;
            $c++;
        }
        $key_id = array();
        foreach ((array) $option_value as $key => $value) {
            $key_id[$key] = $value['sort'];
        }
        array_multisort($key_id, SORT_ASC, $option_value);
        wc2_update_option($option_name, $option_value);
    }
    return count($option_value);
}
 public function system_ajax()
 {
     if (!check_ajax_referer('wc2_setting_system', 'wc2_nonce', false)) {
         die;
     }
     if (!isset($_POST['action']) or !isset($_POST['mode'])) {
         die;
     }
     if ($_POST['action'] != 'system_ajax') {
         die;
     }
     $res = '';
     switch ($_POST['mode']) {
         case 'target_market':
             $states = wc2_get_option('states_options');
             $data = wc2_stripslashes_deep_post($_POST);
             $target = explode(',', $data['target']);
             foreach ((array) $target as $country) {
                 $prefs = $states[$country];
                 if (is_array($prefs) and 0 < count($prefs)) {
                     $res .= $country . ",";
                     foreach ((array) $prefs as $state) {
                         $res .= $state . "\n";
                     }
                     $res = rtrim($res, "\n") . WC2_SPLIT;
                 } else {
                     $res .= $country . ',' . WC2_SPLIT;
                 }
             }
             $res = rtrim($res, WC2_SPLIT);
     }
     $res = apply_filters('wc2_filter_admin_system_ajax', $res);
     die($res);
 }
 function column_mem_rank($item)
 {
     $rank_type = wc2_get_option('rank_type');
     if (isset($rank_type[$item['mem_rank']])) {
         return $rank_type[$item['mem_rank']];
     }
 }
Example #7
0
 private function check_display_mode()
 {
     $general_options = wc2_get_option('general');
     if (isset($general_options['display_mode']) && $general_options['display_mode'] == 'Maintenancemode') {
         return;
     }
     $start['hour'] = empty($general_options['campaign_schedule']['start']['hour']) ? 0 : $general_options['campaign_schedule']['start']['hour'];
     $start['min'] = empty($general_options['campaign_schedule']['start']['min']) ? 0 : $general_options['campaign_schedule']['start']['min'];
     $start['month'] = empty($general_options['campaign_schedule']['start']['month']) ? 0 : $general_options['campaign_schedule']['start']['month'];
     $start['day'] = empty($general_options['campaign_schedule']['start']['day']) ? 0 : $general_options['campaign_schedule']['start']['day'];
     $start['year'] = empty($general_options['campaign_schedule']['start']['year']) ? 0 : $general_options['campaign_schedule']['start']['year'];
     $end['hour'] = empty($general_options['campaign_schedule']['end']['hour']) ? 0 : $general_options['campaign_schedule']['end']['hour'];
     $end['min'] = empty($general_options['campaign_schedule']['end']['min']) ? 0 : $general_options['campaign_schedule']['end']['min'];
     $end['month'] = empty($general_options['campaign_schedule']['end']['month']) ? 0 : $general_options['campaign_schedule']['end']['month'];
     $end['day'] = empty($general_options['campaign_schedule']['end']['day']) ? 0 : $general_options['campaign_schedule']['end']['day'];
     $end['year'] = empty($general_options['campaign_schedule']['end']['year']) ? 0 : $general_options['campaign_schedule']['end']['year'];
     $starttime = mktime($start['hour'], $start['min'], 0, $start['month'], $start['day'], $start['year']);
     $endtime = mktime($end['hour'], $end['min'], 0, $end['month'], $end['day'], $end['year']);
     $current_time = current_time('timestamp');
     if ($current_time >= $starttime && $current_time <= $endtime) {
         $general_options['display_mode'] = 'Promotionsale';
     } else {
         $general_options['display_mode'] = 'Usualsale';
     }
     wc2_update_option('general', $general_options);
 }
 function column_order_status($item)
 {
     //*** LI CUSTOMIZE >>>
     $order_status = $item['order_status'];
     $item['order_status'] = '';
     $flag_check = wc2_get_order_meta_value($item['ID'], 'flag_check');
     if (!empty($flag_check) and $flag_check[0]['meta_value'] == 1) {
         $item['order_status'] .= '<span class="flag-check"><img src="' . get_template_directory_uri() . '/images/admin/icon-jidotsuka.png" alt="jidotsuka"></span>';
     }
     $flag_caution = wc2_get_order_meta_value($item['ID'], 'flag_caution');
     if (!empty($flag_caution) and $flag_caution[0]['meta_value'] == 1) {
         $item['order_status'] .= '<span class="flag-caution"><img src="' . get_template_directory_uri() . '/images/admin/icon-youchui.png" alt="youchui"></span>';
     }
     //*** LI CUSTOMIZE <<<
     $management_status = wc2_get_option('management_status');
     foreach ($management_status as $status_value => $status_name) {
         //*** LI CUSTOMIZE >>>
         //if( $item['order_status'] == $status_value ) {
         //	$item['order_status'] = $status_name;
         if ($order_status == $status_value) {
             $item['order_status'] .= $status_name;
             //*** LI CUSTOMIZE <<<
             break;
         }
     }
     return $item['order_status'];
 }
Example #9
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 #10
0
function wc2_initial_setting()
{
    //Member rank
    $rank_type = wc2_get_option('rank_type');
    //if( empty($rank_type) ) {
    $rank_type = array('0' => __('Normal member', 'wc2'), '1' => __('Excellent member', 'wc2'), '2' => __('VIP member', 'wc2'), '99' => __('Bad member', 'wc2'));
    //}
    $rank_type = apply_filters('wc2_filter_rank_type', $rank_type);
    wc2_update_option('rank_type', $rank_type);
    //Admin screen label
    $admin_screen_label = wc2_get_option('admin_screen_label');
    //if( empty($admin_screen_label) ) {
    $admin_screen_label = array('order' => __('Order', 'wc2'), 'member' => __('Member', 'wc2'), 'general' => __('General', 'wc2'), 'phrase' => __('Phrase', 'wc2'), 'payment' => __('Payment', 'wc2'), 'delivery' => __('Delivery', 'wc2'), 'system' => __('System', 'wc2'), 'customfield' => __('Custom field', 'wc2'));
    //}
    $admin_screen_label = apply_filters('wc2_filter_admin_screen_label', $admin_screen_label);
    wc2_update_option('admin_screen_label', $admin_screen_label);
    //Stock status
    $stock_status = wc2_get_option('stock_status');
    //if( empty($stock_status) ) {
    $stock_status = array('0' => __('In stock', 'wc2'), '10' => __('Little stock', 'wc2'), '20' => __('Sold Out', 'wc2'), '30' => __('Out Of Stock', 'wc2'), '90' => __('Discontinued', 'wc2'));
    //}
    $stock_status = apply_filters('wc2_filter_stock_status', $stock_status);
    wc2_update_option('stock_status', $stock_status);
    //Management status
    $management_status = wc2_get_option('management_status');
    //if( empty($management_status) ) {
    $management_status = array('new' => __('New order', 'wc2'), 'backordered' => __('Backordered', 'wc2'), 'cancel' => __('Cancel', 'wc2'), 'completion' => __('Shipped', 'wc2'));
    //}
    $management_status = apply_filters('wc2_filter_management_status', $management_status);
    wc2_update_option('management_status', $management_status);
    $receipt_status = wc2_get_option('receipt_status');
    //if( empty($receipt_status) ) {
    $receipt_status = array('unpaid' => __('Unpaid', 'wc2'), 'paid' => __('Payment confirmed', 'wc2'), 'pending' => __('Pending', 'wc2'));
    //}
    $receipt_status = apply_filters('wc2_filter_receipt_status', $receipt_status);
    wc2_update_option('receipt_status', $receipt_status);
    $order_type = wc2_get_option('order_type');
    //if( empty($order_type) ) {
    $order_type = array('' => __('Normal order', 'wc2'), 'estimate' => __('Estimates', 'wc2'), 'adminorder' => __('Management order', 'wc2'));
    //}
    $order_type = apply_filters('wc2_filter_order_type', $order_type);
    wc2_update_option('order_type', $order_type);
    //Display mode
    $display_mode_label = wc2_get_option('display_mode_label');
    //if( empty($display_mode_label) ) {
    $display_mode_label = array('Usualsale' => __('Open', 'wc2'), 'Promotionsale' => __('Campaign Sale', 'wc2'), 'Maintenancemode' => __('Maintenance Mode', 'wc2'));
    //}
    $display_mode_label = apply_filters('wc2_filter_display_mode_label', $display_mode_label);
    wc2_update_option('display_mode_label', $display_mode_label);
    //Shipping rule
    $shipping_rule = wc2_get_option('shipping_rule');
    //if( empty($shipping_rule) ) {
    $shipping_rule['preparations'] = array('0' => __('-- Select --', 'wc2'), '1' => __('Same day', 'wc2'), '2' => __('1-2 days', 'wc2'), '3' => __('2-3 days', 'wc2'), '4' => __('3-5 days', 'wc2'), '5' => __('4-6 days', 'wc2'), '6' => __('About 1 week later', 'wc2'), '7' => __('About 2 weeks later', 'wc2'), '8' => __('About 3 weeks later', 'wc2'), '9' => __('Stock after', 'wc2'));
    $shipping_rule['indication'] = array(0, 0, 2, 3, 5, 6, 7, 14, 21, 0);
    //}
    $shipping_rule = apply_filters('wc2_filter_shipping_rule', $shipping_rule);
    wc2_update_option('shipping_rule', $shipping_rule);
    //Locale default value
    $locale = wc2_get_option('locale_options');
    //if( empty($locale) ) {
    $locale['language'] = array();
    $languages = wc2_get_languages();
    foreach ($languages as $l) {
        $locale['language'][$l] = $l;
    }
    $locale['language']['others'] = __('Follow config.php', 'wc2');
    $locale['currency'] = array('AR' => array('ARS', 2, '.', ',', '$'), 'AU' => array('AUD', 2, '.', ',', '$'), 'AT' => array('EUR', 2, '.', ',', '&#x20AC;'), 'BE' => array('EUR', 2, '.', ',', '&#x20AC;'), 'BR' => array('BRL', 2, '.', ',', '$'), 'CA' => array('CAD', 2, '.', ',', '$'), 'CL' => array('CLP', 2, '.', ',', '$'), 'CN' => array('CNY', 2, '.', ',', '&yen;'), 'CR' => array('CRC', 2, '.', ',', '₡'), 'CZ' => array('CZK', 2, '.', ',', 'Kč'), 'DK' => array('DKK', 2, '.', ',', 'kr'), 'DO' => array('DOP', 2, '.', ',', 'RD$'), 'FI' => array('EUR', 2, '.', ',', '&#x20AC;'), 'FR' => array('EUR', 2, '.', ',', '&#x20AC;'), 'DE' => array('EUR', 2, '.', ',', '&#x20AC;'), 'GR' => array('EUR', 2, '.', ',', '&#x20AC;'), 'GT' => array('GTQ', 2, '.', ',', ''), 'HK' => array('HKD', 2, '.', ',', '$'), 'HU' => array('HUF', 2, '.', ',', ''), 'IN' => array('INR', 2, '.', ',', '&#x20A8;'), 'ID' => array('IDR', 2, '.', ',', 'Rp'), 'IE' => array('EUR', 2, '.', ',', '&#x20AC;'), 'IL' => array('ILS', 2, '.', ',', '&#x20AA;'), 'IT' => array('EUR', 2, '.', ',', '&#x20AC;'), 'JP' => array('JPY', 0, '.', ',', '&yen;'), 'MO' => array('MOP', 2, '.', ',', '$'), 'MY' => array('MYR', 2, '.', ',', 'RM'), 'MX' => array('MXN', 2, '.', ',', '$'), 'NL' => array('EUR', 2, '.', ',', '&#x20AC;'), 'NZ' => array('NZD', 2, '.', ',', '$'), 'NO' => array('NOK', 2, '.', ',', ''), 'PA' => array('PAB', 2, '.', ',', ''), 'PH' => array('PHP', 2, '.', ',', 'P'), 'PL' => array('PLN', 2, '.', ',', ''), 'PT' => array('EUR', 2, '.', ',', '&#x20AC;'), 'PR' => array('USD', 2, '.', ',', '$'), 'RO' => array('ROL', 2, '.', ',', 'L'), 'RU' => array('RUR', 2, '.', ',', ''), 'SG' => array('SGD', 2, '.', ',', '$'), 'KR' => array('KRW', 0, '.', ',', '&#x20A9;'), 'ES' => array('EUR', 2, '.', ',', '&#x20AC;'), 'SW' => array('SEK', 2, '.', ',', ''), 'CH' => array('CHF', 2, '.', ',', 'Fr.'), 'TW' => array('NT$', 0, '.', ',', '元'), 'TH' => array('THB', 2, '.', ',', '฿'), 'TR' => array('TRL', 2, '.', ',', '₤'), 'GB' => array('GBP', 2, '.', ',', '£'), 'US' => array('USD', 2, '.', ',', '$'), 'VN' => array('VND', 2, '.', ',', '₫'), 'OO' => array('USD', 2, '.', ',', '$'));
    $locale['nameform'] = array('AR' => 1, 'AU' => 1, 'AT' => 1, 'BE' => 1, 'BR' => 1, 'CA' => 1, 'CL' => 1, 'CN' => 0, 'CR' => 1, 'CZ' => 1, 'DK' => 1, 'DO' => 1, 'FI' => 1, 'FR' => 1, 'DE' => 1, 'GR' => 1, 'GT' => 1, 'HK' => 1, 'HU' => 1, 'IN' => 1, 'ID' => 1, 'IE' => 1, 'IL' => 1, 'IT' => 1, 'JP' => 0, 'MO' => 1, 'MY' => 1, 'MX' => 1, 'NL' => 1, 'NZ' => 1, 'NO' => 1, 'PA' => 1, 'PH' => 1, 'PL' => 1, 'PT' => 1, 'PR' => 1, 'RO' => 1, 'RU' => 1, 'SG' => 1, 'KR' => 1, 'ES' => 1, 'SW' => 1, 'CH' => 1, 'TW' => 0, 'TH' => 1, 'TR' => 1, 'GB' => 1, 'US' => 1, 'VN' => 1, 'OO' => 1);
    $locale['addressform'] = array('AR' => 'US', 'AU' => 'US', 'AT' => 'US', 'BE' => 'US', 'BR' => 'US', 'CA' => 'US', 'CL' => 'US', 'CN' => 'CN', 'CR' => 'US', 'CZ' => 'US', 'DK' => 'US', 'DO' => 'US', 'FI' => 'US', 'FR' => 'US', 'DE' => 'US', 'GR' => 'US', 'GT' => 'US', 'HK' => 'US', 'HU' => 'US', 'IN' => 'US', 'ID' => 'US', 'IE' => 'US', 'IL' => 'US', 'IT' => 'US', 'JP' => 'JP', 'MO' => 'US', 'MY' => 'US', 'MX' => 'US', 'NL' => 'US', 'NZ' => 'US', 'NO' => 'US', 'PA' => 'US', 'PH' => 'US', 'PL' => 'US', 'PT' => 'US', 'PR' => 'US', 'RO' => 'US', 'RU' => 'US', 'SG' => 'US', 'KR' => 'US', 'ES' => 'US', 'SW' => 'US', 'CH' => 'US', 'TW' => 'JP', 'TH' => 'US', 'TR' => 'US', 'GB' => 'US', 'US' => 'US', 'VN' => 'US', 'OO' => 'US');
    $locale['country'] = array('AR' => __('Argentina', 'wc2'), 'AU' => __('Australia', 'wc2'), 'AT' => __('Austria', 'wc2'), 'BE' => __('Belgium', 'wc2'), 'BR' => __('Brazil', 'wc2'), 'CA' => __('Canada', 'wc2'), 'CL' => __('Chile', 'wc2'), 'CN' => __('China', 'wc2'), 'CR' => __('Costa Rica', 'wc2'), 'CZ' => __('Czech Republic', 'wc2'), 'DK' => __('Denmark', 'wc2'), 'DO' => __('Dominican Republic', 'wc2'), 'FI' => __('Finland', 'wc2'), 'FR' => __('France', 'wc2'), 'DE' => __('Germany', 'wc2'), 'GR' => __('Greece', 'wc2'), 'GT' => __('Guatemala', 'wc2'), 'HK' => __('Hong Kong', 'wc2'), 'HU' => __('Hungary', 'wc2'), 'IN' => __('India', 'wc2'), 'ID' => __('Indonesia', 'wc2'), 'IE' => __('Ireland', 'wc2'), 'IL' => __('Israel', 'wc2'), 'IT' => __('Italy', 'wc2'), 'JP' => __('日本', 'wc2'), 'MO' => __('Macau', 'wc2'), 'MY' => __('Malaysia', 'wc2'), 'MX' => __('Mexico', 'wc2'), 'NL' => __('Netherlands', 'wc2'), 'NZ' => __('New Zealand', 'wc2'), 'NO' => __('Norway', 'wc2'), 'PA' => __('Panama', 'wc2'), 'PH' => __('Philippines', 'wc2'), 'PL' => __('Poland', 'wc2'), 'PT' => __('Portugal', 'wc2'), 'PR' => __('Puerto Rico', 'wc2'), 'RO' => __('Romania', 'wc2'), 'RU' => __('Russia', 'wc2'), 'SG' => __('Singapore', 'wc2'), 'KR' => __('South Korea', 'wc2'), 'ES' => __('Spain', 'wc2'), 'SW' => __('Sweden', 'wc2'), 'CH' => __('Switzerland', 'wc2'), 'TW' => __('Taiwan', 'wc2'), 'TH' => __('Thailand', 'wc2'), 'TR' => __('Turkey', 'wc2'), 'GB' => __('United Kingdom', 'wc2'), 'US' => __('United States', 'wc2'), 'VN' => __('Vietnam', 'wc2'), 'OO' => __('Other', 'wc2'));
    $locale['country_num'] = array('AR' => '54', 'AR' => '61', 'AT' => '43', 'BE' => '32', 'BR' => '55', 'CA' => '1', 'CL' => '56', 'CN' => '86', 'CR' => '506', 'CZ' => '420', 'DK' => '45', 'DO' => '1-809', 'FI' => '358', 'FR' => '33', 'DE' => '49', 'GR' => '30', 'GT' => '502', 'HK' => '852', 'HU' => '36', 'IN' => '91', 'ID' => '62', 'IE' => '353', 'IL' => '972', 'IT' => '39', 'JP' => '81', 'MO' => '853', 'MY' => '60', 'MX' => '52', 'NL' => '31', 'NZ' => '64', 'NO' => '47', 'PA' => '507', 'PH' => '63', 'PL' => '48', 'PT' => '351', 'PR' => '1-787', 'RO' => '40', 'RU' => '7', 'SG' => '65', 'KR' => '82', 'ES' => '34', 'SW' => '46', 'CH' => '41', 'TW' => '886', 'TH' => '66', 'TR' => '90', 'GB' => '44', 'US' => '1', 'VN' => '84', 'OO' => '1');
    $locale['lungage2country'] = array('es_AR' => 'AR', 'en_AU' => 'AU', 'de_AT' => 'AT', 'nl_BE' => 'BE', 'fr_BE' => 'BE', 'pt_BR' => 'BR', 'en_CA' => 'CA', 'fr_CA' => 'CA', 'es_CL' => 'CL', 'zh_CN' => 'CN', 'zh' => 'CN', 'es_CR' => 'CR', 'cs_CZ' => 'CZ', 'cs' => 'CZ', 'da' => 'DK', 'da_DK' => 'DK', 'es_DO' => 'DO', 'fi_FI' => 'FI', 'fi' => 'FI', 'sv_FI' => 'FI', 'fr' => 'FR', 'fr_FR' => 'FR', 'de' => 'DE', 'de_DE' => 'DE', 'el' => 'GR', 'el_GR' => 'GR', 'es_GT' => 'GT', 'zh_HK' => 'HK', 'en_HK' => 'HK', 'hu_HU' => 'HU', 'hu' => 'HU', 'hi' => 'IN', 'hi_IN' => 'IN', 'id' => 'ID', 'id_ID' => 'ID', 'ga' => 'IE', 'ga_IE' => 'IE', 'en_IE' => 'IE', 'he_IL' => 'IL', 'ar_IL' => 'IL', 'it' => 'IT', 'it_IT' => 'IT', 'ja' => 'JP', 'ja_JP' => 'JP', 'zh_MO' => 'MO', 'pt_MO' => 'MO', 'ms' => 'MY', 'ms_MY' => 'MY', 'es_MX' => 'MX', 'nl' => 'NL', 'nl_NL' => 'NL', 'en_NZ' => 'NZ', 'mi_NZ' => 'NZ', 'mi' => 'NZ', 'no' => 'NO', 'no_NO' => 'NO', 'es_PA' => 'PA', 'tl' => 'PH', 'tl_PH' => 'PH', 'en_PH' => 'PH', 'pl' => 'PL', 'pl_PL' => 'PL', 'pt' => 'PT', 'pt_PT' => 'PT', 'es_PR' => 'PR', 'en_PR' => 'PR', 'ro' => 'RO', 'ro_RO' => 'RO', 'ru' => 'RU', 'ru_RU' => 'RU', 'en_SG' => 'SG', 'ms_SG' => 'SG', 'zh_SG' => 'SG', 'ko' => 'KR', 'ko_KR' => 'KR', 'es' => 'ES', 'es_ES' => 'ES', 'sv' => 'SW', 'sv_SW' => 'SW', 'de_CH' => 'CH', 'fr_CH' => 'CH', 'it_CH' => 'CH', 'rm_CH' => 'CH', 'rm' => 'CH', 'zh_TW' => 'TW', 'th' => 'TH', 'th_TH' => 'TH', 'tr' => 'TR', 'tr_TR' => 'TR', 'en' => 'GB', 'en_GB' => 'GB', '' => 'US', 'en_US' => 'US', 'vi' => 'VN', 'vi_VN' => 'VN', 'zh_TW' => 'TW');
    //}
    $locale = apply_filters('wc2_filter_locale', $locale);
    wc2_update_option('locale_options', $locale);
    //American state and prefectures of Japan
    $states = wc2_get_option('states_options');
    //if( empty($states) ) {
    $states['JP'] = array("北海道", "青森県", "岩手県", "宮城県", "秋田県", "山形県", "福島県", "茨城県", "栃木県", "群馬県", "埼玉県", "千葉県", "東京都", "神奈川県", "新潟県", "富山県", "石川県", "福井県", "山梨県", "長野県", "岐阜県", "静岡県", "愛知県", "三重県", "滋賀県", "京都府", "大阪府", "兵庫県", "奈良県", "和歌山県", "鳥取県", "島根県", "岡山県", "広島県", "山口県", "徳島県", "香川県", "愛媛県", "高知県", "福岡県", "佐賀県", "長崎県", "熊本県", "大分県", "宮崎県", "鹿児島県", "沖縄県");
    $states['US'] = array("Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming");
    //}
    wc2_update_option('states_options', $states);
    //Option types
    $item_option_select = wc2_get_option('item_option_select');
    //if( empty($item_option_select) ) {
    $item_option_select = array('0' => __('シングルセレクト', 'wc2'), '1' => __('マルチセレクト', 'wc2'), '2' => __('テキスト', 'wc2'), '3' => __('ラジオボタン', 'wc2'), '4' => __('チェックボックス', 'wc2'), '5' => __('テキストエリア', 'wc2'));
    //}
    wc2_update_option('item_option_select', $item_option_select);
    //Fixed phrase
    $phrase_default = wc2_get_option('phrase_default');
    if (empty($phrase_default)) {
        $blogname = get_option('blogname');
        $home_url = get_option('home');
        $phrase_default['smtp_hostname'] = '';
        $phrase_default['newmem_admin_mail'] = 1;
        $phrase_default['delmem_admin_mail'] = 1;
        $phrase_default['delmem_customer_mail'] = 1;
        $phrase_default['editmem_customer_mail'] = 1;
        $phrase_default['title']['thankyou'] = __('ご注文内容の確認', 'wc2');
        $phrase_default['title']['order'] = __('受注報告', 'wc2');
        $phrase_default['title']['inquiry'] = __('お問い合わせを承りました', 'wc2');
        $phrase_default['title']['membercomp'] = __('ご入会完了のご連絡', 'wc2');
        $phrase_default['title']['completionmail'] = __('商品発送のご連絡', 'wc2');
        $phrase_default['title']['ordermail'] = __('ご注文内容の確認', 'wc2');
        $phrase_default['title']['changemail'] = __('ご注文内容変更の確認', 'wc2');
        $phrase_default['title']['receiptmail'] = __('ご入金確認のご連絡', 'wc2');
        $phrase_default['title']['estimatemail'] = __('お見積の件', 'wc2');
        $phrase_default['title']['cancelmail'] = __('ご注文キャンセルの確認', 'wc2');
        $phrase_default['title']['othermail'] = '';
        $phrase_default['header']['thankyou'] = sprintf(__("この度は%sをご利用くださいまして、誠にありがとうございます。", 'wc2'), $blogname) . "\r\n" . __("下記の通りご注文をお受けいたしましたのでご確認をお願いいたします。", 'wc2') . "\r\n\r\n" . __("商品の準備ができ次第、メールにて発送のご案内をさせていただきます。よろしくお願いいたします。", 'wc2') . "\r\n\r\n";
        $phrase_default['header']['order'] = sprintf(__("%sの注文が入りました。", 'wc2'), $blogname) . "\r\n";
        $phrase_default['header']['inquiry'] = sprintf(__("この度は%sをご利用くださいまして、誠にありがとうございます。", 'wc2'), $blogname) . "\r\n" . __("下記の通りお問い合わせをお受けいたしました。", 'wc2') . "\r\n\r\n" . __("準備ができ次第、メールにてご返答させていただきます。", 'wc2') . "\r\n\r\n";
        $phrase_default['header']['membercomp'] = sprintf(__("この度は%sの会員にご登録くださいまして、誠にありがとうございます。", 'wc2'), $blogname) . "\r\n\r\n" . __("「会員情報」にてご購入商品の履歴が確認できます。", 'wc2') . "\r\n\r\n";
        $phrase_default['header']['completionmail'] = __("本日、ご注文の商品を発送いたしました。", 'wc2') . "\r\n\r\n" . __("配送業者は○○運輸となっております。", 'wc2') . "\r\n\r\n" . __("万が一商品が届かない場合はご連絡ください。よろしくお願いいたします。", 'wc2') . "\r\n\r\n";
        $phrase_default['header']['ordermail'] = sprintf(__("この度は%sをご利用くださいまして、誠にありがとうございます。", 'wc2'), $blogname) . "\r\n" . __("下記の通りご注文内容を変更いたしましたので、ご確認をお願いいたします。", 'wc2') . "\r\n\r\n" . __("商品の準備ができ次第、メールにて発送のご案内をさせていただきます。よろしくお願いいたします。", 'wc2') . "\r\n\r\n";
        $phrase_default['header']['changemail'] = sprintf(__("この度は%sをご利用くださいまして、誠にありがとうございます。", 'wc2'), $blogname) . "\r\n" . __("下記の通りご注文内容を変更いたしましたので、ご確認をお願いいたします。", 'wc2') . "\r\n\r\n" . __("商品の準備ができ次第、メールにて発送のご案内をさせていただきます。よろしくお願いいたします。", 'wc2') . "\r\n\r\n";
        $phrase_default['header']['receiptmail'] = sprintf(__("この度は%sをご利用くださいまして、誠にありがとうございます。", 'wc2'), $blogname) . "\r\n" . __("ご入金の確認ができましたので、ご連絡いたします。", 'wc2') . "\r\n\r\n" . __("商品の準備ができ次第、メールにて発送のご案内をさせていただきます。よろしくお願いいたします。", 'wc2') . "\r\n\r\n";
        $phrase_default['header']['estimatemail'] = sprintf(__("この度は%sをご利用くださいまして、誠にありがとうございます。", 'wc2'), $blogname) . "\r\n" . __("下記の通りお見積いたしましたので、ご確認をお願いいたします。", 'wc2') . "\r\n\r\n" . __("お見積の有効期限は一週間となっております。よろしくお願いいたします。", 'wc2') . "\r\n\r\n";
        $phrase_default['header']['cancelmail'] = sprintf(__("この度は%sをご利用くださいまして、誠にありがとうございます。", 'wc2'), $blogname) . "\r\n" . __("ご注文のキャンセルを承りました。今後ともよろしくお願いいたします。", 'wc2') . "\r\n\r\n";
        $phrase_default['header']['othermail'] = sprintf(__("この度は%sをご利用くださいまして、誠にありがとうございます。", 'wc2'), $blogname) . "\r\n\r\n";
        $general_options = wc2_get_option('wc2_general');
        $company_name = isset($general_options['company_name']) ? $general_options['company_name'] : '';
        $zip_code = isset($general_options['zip_code']) ? $general_options['zip_code'] : '';
        $address1 = isset($general_options['address1']) ? $general_options['address1'] : '';
        $address2 = isset($general_options['address2']) ? $general_options['address2'] : '';
        $tel_number = isset($general_options['tel_number']) ? $general_options['tel_number'] : '';
        $fax_number = isset($general_options['fax_number']) ? $general_options['fax_number'] : '';
        $inquiry_mail = isset($general_options['inquiry_mail']) ? $general_options['inquiry_mail'] : '';
        $footer = "=============================================\r\n" . $blogname . "\r\n" . $company_name . "\r\n" . $zip_code . "\r\n" . $address1 . "\r\n" . $address2 . "\r\n" . "TEL " . $tel_number . "\r\n" . "FAX " . $fax_number . "\r\n" . __('contact', 'wc2') . " " . $inquiry_mail . "\r\n" . $home_url . "\r\n" . "=============================================\r\n";
        $phrase_default['footer']['thankyou'] = $footer;
        $phrase_default['footer']['order'] = $footer;
        $phrase_default['footer']['inquiry'] = $footer;
        $phrase_default['footer']['membercomp'] = $footer;
        $phrase_default['footer']['completionmail'] = $footer;
        $phrase_default['footer']['ordermail'] = $footer;
        $phrase_default['footer']['changemail'] = $footer;
        $phrase_default['footer']['receiptmail'] = $footer;
        $phrase_default['footer']['estimatemail'] = $footer;
        $phrase_default['footer']['cancelmail'] = $footer;
        $phrase_default['footer']['othermail'] = $footer;
    }
    wc2_update_option('phrase_default', $phrase_default);
    //Essential mark
    $essential_mark = wc2_get_option('essential_mark');
    //if( empty($essential_mark) ) {
    $essential_mark = array('email' => '<span class="required">' . __('*', 'wc2') . '</span>', 'name1' => '<span class="required">' . __('*', 'wc2') . '</span>', 'name2' => '', 'name3' => '', 'name4' => '', 'zipcode' => '<span class="required">' . __('*', 'wc2') . '</span>', 'country' => '<span class="required">' . __('*', 'wc2') . '</span>', 'pref' => '<span class="required">' . __('*', 'wc2') . '</span>', 'address1' => '<span class="required">' . __('*', 'wc2') . '</span>', 'address2' => '', 'tel' => '<span class="required">' . __('*', 'wc2') . '</span>', 'fax' => '');
    //}
    $essential_mark = apply_filters('wc2_filter_essential_mark', $essential_mark);
    wc2_update_option('essential_mark', $essential_mark);
    $noreceipt_status = array('BT');
    $noreceipt_status = apply_filters('wc2_filter_noreceipt_status', $noreceipt_status);
    wc2_update_option('noreceipt_status', $noreceipt_status);
    $custom_field_option = array('capa' => array('admin' => '管理パネルのみ', 'public' => 'フロントにも表示'), 'means' => array('select' => 'シングルセレクト', 'radio' => 'ラジオボタン', 'check' => 'チェックボックス', 'text' => 'テキスト', 'textarea' => 'テキストエリア'), 'essential' => true, 'position' => array('head' => '先頭', 'beforename' => '名前の前', 'aftername' => '名前の後', 'bottom' => '最後尾', 'other' => 'その他'));
    wc2_update_option('custom_field_option', $custom_field_option);
    //Orderlist refine period
    $order_refine_period = wc2_get_option('order_refine_period');
    //if( empty($order_refine_period) ) {
    $order_refine_period = array('0' => __('This month', 'wc2'), '1' => __('Last month', 'wc2'), '2' => __('The past one week', 'wc2'), '3' => __('Last 30 days', 'wc2'), '4' => __('Last 90days', 'wc2'), '5' => __('Period specified', 'wc2'), '6' => __('All', 'wc2'));
    //}
    $order_refine_period = apply_filters('wc2_filter_order_refine_period', $order_refine_period);
    wc2_update_option('order_refine_period', $order_refine_period);
    do_action('wc2_action_initial_setting');
}
Example #11
0
 public function get_pdf_myaddress($pdf, $lineheight)
 {
     $system = wc2_get_option('system');
     $general = wc2_get_option('general');
     $applyform = wc2_get_apply_addressform($system['addressform']);
     $name = '';
     switch ($applyform) {
         case 'JP':
             $address = empty($general['address2']) ? $general['address1'] : $general['address1'] . "\n" . $general['address2'];
             $pdf->MultiCell(60, $lineheight, $this->conv_enc(__('zip code', 'wc2') . ' ' . $general['zip_code']), 0, 'L');
             $pdf->MultiCell(60, $lineheight, $this->conv_enc($address), 0, 'L');
             break;
         case 'US':
         default:
             $address = empty($general['address2']) ? $general['address1'] : $general['address2'] . "\n" . $general['address1'];
             $pdf->MultiCell(60, $lineheight, $this->conv_enc($address), 0, 'L');
             $pdf->MultiCell(60, $lineheight, $this->conv_enc(__('zip code', 'wc2') . ' ' . $general['zip_code']), 0, 'L');
             break;
     }
 }
 function setup_cod_ajax()
 {
     if (!check_ajax_referer('wc2_setting_payment', 'wc2_nonce', false)) {
         die;
     }
     $payment_info = wc2_get_option('payment_info');
     $message = '';
     $_POST = WC2_Utils::stripslashes_deep_post($_POST);
     $payment_info['cod_type'] = isset($_POST['cod_type']) ? $_POST['cod_type'] : 'fix';
     if (isset($_POST['cod_fee'])) {
         $payment_info['cod_fee'] = (int) $_POST['cod_fee'];
     }
     if ('fix' == $payment_info['cod_type']) {
         if (isset($_POST['cod_fee'])) {
             $payment_info['cod_fee'] = (int) $_POST['cod_fee'];
             if (!is_numeric($_POST['cod_fee'])) {
                 $message = __('値が不正な項目があります', 'wc2');
             }
         }
         if (isset($_POST['cod_limit_amount'])) {
             $payment_info['cod_limit_amount'] = (int) $_POST['cod_limit_amount'];
             if (!WC2_Utils::is_blank($_POST['cod_limit_amount']) && 0 === (int) $_POST['cod_limit_amount']) {
                 $message = __('値が不正な項目があります', 'wc2');
             }
         }
     } elseif ('change' == $payment_info['cod_type']) {
         if (isset($_POST['cod_first_amount'])) {
             $payment_info['cod_first_amount'] = (int) $_POST['cod_first_amount'];
             if (0 === (int) $_POST['cod_first_amount']) {
                 $message = __('値が不正な項目があります', 'wc2');
             }
         }
         if (isset($_POST['cod_limit_amount'])) {
             $payment_info['cod_limit_amount'] = (int) $_POST['cod_limit_amount'];
             if (!WC2_Utils::is_blank($_POST['cod_limit_amount']) && 0 === (int) $_POST['cod_limit_amount']) {
                 $message = __('値が不正な項目があります', 'wc2');
             }
         }
         if (isset($_POST['cod_first_fee'])) {
             $payment_info['cod_first_fee'] = (int) $_POST['cod_first_fee'];
             if (0 === (int) $_POST['cod_first_fee'] && '0' !== $_POST['cod_first_fee']) {
                 $message = __('値が不正な項目があります', 'wc2');
             }
         }
         if (isset($_POST['cod_end_fee'])) {
             $payment_info['cod_end_fee'] = (int) $_POST['cod_end_fee'];
             if (0 === (int) $_POST['cod_end_fee'] && '0' !== $_POST['cod_end_fee']) {
                 $message = __('値が不正な項目があります', 'wc2');
             }
         }
         unset($payment_info['cod_amounts'], $payment_info['cod_fees']);
         if (isset($_POST['cod_amounts'])) {
             for ($i = 0; $i < count((array) $_POST['cod_amounts']); $i++) {
                 $payment_info['cod_amounts'][$i] = (int) $_POST['cod_amounts'][$i];
                 $payment_info['cod_fees'][$i] = (int) $_POST['cod_fees'][$i];
                 if (0 === (int) $_POST['cod_amounts'][$i] || 0 === (int) $_POST['cod_fees'][$i] && '0' !== $_POST['cod_fees'][$i]) {
                     $message = __('値が不正な項目があります', 'wc2');
                 }
             }
         }
     }
     if ('' == $message) {
         $r = 'success';
         wc2_update_option('payment_info', $payment_info);
     } else {
         $r = 'error' . WC2_SPLIT . $message;
     }
     $r = apply_filters('wc2_filter_admin_payment_setup_cod_ajax', $r);
     die($r);
 }
Example #13
0
 static function use_ssl()
 {
     $system_options = wc2_get_option('system');
     $use_ssl = $system_options['use_ssl'];
     return $use_ssl;
 }
Example #14
0
function wc2_item_edit_js()
{
    global $post_type, $pagenow;
    //if( ITEM_POST_TYPE != $post_type or $pagenow != 'edit.php' ) return;
    if (ITEM_POST_TYPE != $post_type or $pagenow != 'edit.php' or array_key_exists('page', $_GET)) {
        return;
    }
    $stock_status = wc2_get_option('stock_status');
    $display_status = array('publish' => __('Published'), 'future' => __('Scheduled'), 'draft' => __('Draft'), 'pending' => __('Pending Review'), 'private' => __('Private'));
    $search_condition = array_key_exists('search_condition', $_GET) ? $_GET['search_condition'] : '';
    $search_word = array_key_exists('search_word', $_GET) ? $_GET['search_word'] : '';
    ob_start();
    ?>
<script type="text/javascript">
jQuery(function($) {
	$(document).on( "change", "#search_condition", function() {
		var fld = '';
		switch( $(this).val() ) {
		case "item_code":
		case "item_name":
			fld = '<input name="search_word" id="search_word" type="text" value="<?php 
    esc_attr_e($search_word);
    ?>
" />';
			break;
		case "stock_status":
			fld = '<select name="search_word" id="search_word">';
<?php 
    foreach ($stock_status as $key => $value) {
        $selected = $key == $search_word ? ' selected="selected"' : '';
        ?>
			fld += '<option value="<?php 
        echo $key;
        ?>
"<?php 
        echo $selected;
        ?>
><?php 
        esc_attr_e($value);
        ?>
</option>';

<?php 
    }
    ?>
			fld += '</select>';
			break;
		case "display_status":
			fld = '<select name="search_word" id="search_word">';
<?php 
    foreach ($display_status as $key => $value) {
        $selected = $key == $search_word ? ' selected="selected"' : '';
        ?>
			fld += '<option value="<?php 
        echo $key;
        ?>
"<?php 
        echo $selected;
        ?>
><?php 
        esc_attr_e($value);
        ?>
</option>';

<?php 
    }
    ?>
			fld += '</select>';
			break;
		case "stock0":
		default:
		}
		$("#search_field").html( fld );
	});
<?php 
    if ('' != $search_condition) {
        ?>
	$("#search_condition").val( "<?php 
        echo $search_condition;
        ?>
" );
	$("#search_condition").trigger( "change" );
<?php 
    }
    do_action('wc2_action_item_edit_js');
    ?>
});
</script>
<?php 
    $js = ob_get_contents();
    ob_end_clean();
    echo apply_filters('wc2_filter_item_edit_js', $js);
}
Example #15
0
 private function _set_item_column_init()
 {
     //*** Not be changed.
     $this->item_table_column = array(ITEM_CODE, ITEM_NAME, ITEM_PRODUCT_TYPE, ITEM_CHARGES_TYPE);
     $this->item_sku_table_column = array(ITEM_SKU_CODE, ITEM_SKU_NAME, ITEM_SKU_PRICE, ITEM_SKU_COSTPRICE, ITEM_SKU_LISTPRICE, ITEM_SKU_UNIT, ITEM_SKU_STOCK, ITEM_SKU_STATUS, ITEM_SKU_SET_QUANTITY_DISCOUNT, ITEM_SKU_SORT);
     //Item base box column
     $this->item_base_column = array(ITEM_CODE => array('display' => '', 'type' => TYPE_TEXT_A, 'value' => '', 'essential' => 1, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_NAME => array('display' => '', 'type' => TYPE_TEXT, 'value' => '', 'essential' => 1, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_PRODUCT_TYPE => array('display' => '', 'type' => TYPE_RADIO, 'value' => '0:物販;1:コンテンツファイル;2:サービス', 'essential' => 1, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_CHARGES_TYPE => array('display' => '', 'type' => TYPE_SELECT, 'value' => '0:通常課金;1:継続課金;2:定期購入', 'essential' => 1, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_PURCHASE_LIMIT => array('display' => '', 'type' => TYPE_PARENT, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_PURCHASE_LIMIT_LOWEST => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => ITEM_PURCHASE_LIMIT, 'label_pre' => '', 'label_post' => '枚以上'), ITEM_PURCHASE_LIMIT_HIGHEST => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => ITEM_PURCHASE_LIMIT, 'label_pre' => '', 'label_post' => '枚まで'), ITEM_POINT_RATE => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => '%(整数)'), ITEM_QUANTITY_DISCOUNT => array('display' => '', 'type' => TYPE_PARENT, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_QUANTITY_DISCOUNT_NUM1 => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => ITEM_QUANTITY_DISCOUNT, 'label_pre' => '1.', 'label_post' => '枚以上で'), ITEM_QUANTITY_DISCOUNT_RATE1 => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => ITEM_QUANTITY_DISCOUNT, 'label_pre' => '', 'label_post' => '円引き(単価)<br />'), ITEM_QUANTITY_DISCOUNT_NUM2 => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => ITEM_QUANTITY_DISCOUNT, 'label_pre' => '2.', 'label_post' => '枚以上で'), ITEM_QUANTITY_DISCOUNT_RATE2 => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => ITEM_QUANTITY_DISCOUNT, 'label_pre' => '', 'label_post' => '円引き(単価)<br />'), ITEM_QUANTITY_DISCOUNT_NUM3 => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => ITEM_QUANTITY_DISCOUNT, 'label_pre' => '3.', 'label_post' => '枚以上で'), ITEM_QUANTITY_DISCOUNT_RATE3 => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => ITEM_QUANTITY_DISCOUNT, 'label_pre' => '', 'label_post' => '円引き(単価)'));
     //Item meta box column
     $this->item_meta_column = array();
     //Item SKU box column
     $stock_status = wc2_get_option('stock_status');
     $stock_status_value = '';
     foreach ((array) $stock_status as $key => $value) {
         $stock_status_value .= $key . ':' . $value . ';';
     }
     $stock_status_value = rtrim($stock_status_value, ';');
     $this->item_sku_column = array(ITEM_SKU_CODE => array('display' => '', 'type' => TYPE_TEXT_A, 'value' => '', 'essential' => 1, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_SKU_NAME => array('display' => '', 'type' => TYPE_TEXT, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_SKU_UNIT => array('display' => '', 'type' => TYPE_TEXT, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_SKU_STOCK => array('display' => '', 'type' => TYPE_TEXT_I, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_SKU_STATUS => array('display' => '', 'type' => TYPE_SELECT, 'value' => $stock_status_value, 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_SKU_PRICE => array('display' => '', 'type' => TYPE_TEXT_P, 'value' => '', 'essential' => 1, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_SKU_COSTPRICE => array('display' => '', 'type' => TYPE_TEXT_P, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_SKU_LISTPRICE => array('display' => '', 'type' => TYPE_TEXT_P, 'value' => '', 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''), ITEM_SKU_SET_QUANTITY_DISCOUNT => array('display' => '', 'type' => TYPE_SELECT, 'value' => '0:適用しない;1:適用する', 'essential' => 0, 'default' => '', 'parent' => '', 'label_pre' => '', 'label_post' => ''));
     //Item SKU meta box column
     $this->item_sku_meta_column = array();
     // SKU table format ( row * column )
     $this->item_sku_format = array(0 => array(ITEM_SKU_CODE, ITEM_SKU_NAME, ITEM_SKU_UNIT, ITEM_SKU_STOCK, ITEM_SKU_STATUS), 1 => array(ITEM_SKU_PRICE, ITEM_SKU_LISTPRICE, ITEM_SKU_COSTPRICE, '', ITEM_SKU_SET_QUANTITY_DISCOUNT));
 }
Example #16
0
 function acting_get_point($order_id, $add = true)
 {
     global $wpdb;
     if (!apply_filters('wc2_action_acting_getpoint_switch', true, $order_id, $add)) {
         return;
     }
     $general = wc2_get_option('general');
     if ($general['point_assign'] != 0) {
         if (wc2_is_membersystem_state() && wc2_is_membersystem_point()) {
             $query = $wpdb->prepare("SELECT member_id, getpoint FROM {$this->order_table} WHERE ID = %d", $order_id);
             $row = $wpdb->get_row($query, ARRAY_A);
             $member_id = $row[ORDER_MEMBER_ID];
             $getpoint = $row[ORDER_GETPOINT];
             if (!empty($member_id) && 0 < $getpoint) {
                 $calc = $add ? '+' : '-';
                 $query = $wpdb->prepare("UPDATE {$this->member_table} SET mem_point = ( mem_point " . $calc . " %d ) WHERE ID = %d", $getpoint, $member_id);
                 $wpdb->query($query);
                 if (array_key_exists('point', $_SESSION[WC2]['member'])) {
                     $query = $wpdb->prepare("SELECT mem_point FROM {$this->member_table} WHERE ID = %d", $member_id);
                     $point = $wpdb->get_var($query);
                     $_SESSION[WC2]['member']['point'] = $point;
                 }
             }
         }
     }
     do_action('wc2_action_acting_getpoint', $order_id, $add);
 }
    public function get_custom_field($custom_field_key)
    {
        $field_param = wc2_get_option($custom_field_key);
        list($prefix, $key) = explode('_', $custom_field_key, 2);
        $r = '';
        if (empty($field_param)) {
            return $r;
        }
        $custom_field_option = wc2_get_option('custom_field_option');
        $name = $field_param['name'];
        $capaoption = '';
        foreach ($custom_field_option['capa'] as $capakey => $capavalue) {
            $selected = $capakey == $field_param['capa'] ? ' selected="selected"' : '';
            $capaoption .= '<option value="' . $capakey . '"' . $selected . '>' . esc_html($capavalue) . '</option>' . "\n";
        }
        $meansoption = '';
        foreach ($custom_field_option['means'] as $meankey => $meanvalue) {
            $selected = $meankey == $field_param['means'] ? ' selected="selected"' : '';
            $meansoption .= '<option value="' . $meankey . '"' . $selected . '>' . esc_html($meanvalue) . '</option>' . "\n";
        }
        $essential = $field_param['essential'] == 1 ? ' checked="checked"' : '';
        $value = trim($field_param['value']);
        $positionsoption = '';
        if (WC2_CSOD == $prefix) {
            $csod_position = array('beforeremarks' => '備考の前', 'other' => 'その他');
            foreach ($csod_position as $poskey => $posvalue) {
                $selected = $poskey == $field_param['position'] ? ' selected="selected"' : '';
                $positionsoption .= '<option value="' . $poskey . '"' . $selected . '>' . esc_html($posvalue) . '</option>' . "\n";
            }
        } else {
            foreach ($custom_field_option['position'] as $poskey => $posvalue) {
                $selected = $poskey == $field_param['position'] ? ' selected="selected"' : '';
                $positionsoption .= '<option value="' . $poskey . '"' . $selected . '>' . esc_html($posvalue) . '</option>' . "\n";
            }
        }
        $r .= '
		<tr id="' . $prefix . '-' . $key . '" class="' . $prefix . ' ' . $key . '">
			<td class="item-opt-key">
				<div><input type="text" name="' . $prefix . '[' . $key . '][key]" id="' . $prefix . '[' . $key . '][key]" class="regular-text optname" value="' . $key . '" readonly /></div>
				<div><input type="text" name="' . $prefix . '[' . $key . '][name]" id="' . $prefix . '[' . $key . '][name]" class="regular-text optname" value="' . $name . '" /></div>
				<div class="optcheck">
					<select name="' . $prefix . '[' . $key . '][capa]" id="' . $prefix . '[' . $key . '][capa]">' . $capaoption . '</select>
					<select name="' . $prefix . '[' . $key . '][means]" id="' . $prefix . '[' . $key . '][means]">' . $meansoption . '</select>
					<select name="' . $prefix . '[' . $key . '][position]" id="' . $prefix . '[' . $key . '][position]">' . $positionsoption . '</select>
					<label for="' . $prefix . '[' . $key . '][essential]"><input type="checkbox" name="' . $prefix . '[' . $key . '][essential]" id="' . $prefix . '[' . $key . '][essential]" value="1"' . $essential . ' /><span>' . __('必須項目', 'wc2') . '</span></label>
				</div>
				<div class="submit">
					<input type="button" class="button" name="del_' . $prefix . '[' . $key . ']" id="del_' . $prefix . '[' . $key . ']" value="' . esc_attr(__('Delete')) . '" onclick="customField.Delete(\'' . $prefix . '\', \'' . $key . '\');" />
					<input type="button" class="button" name="upd_' . $prefix . '[' . $key . ']" id="upd_' . $prefix . '[' . $key . ']" value="' . esc_attr(__('Update')) . '" onclick="customField.Update(\'' . $prefix . '\', \'' . $key . '\');" />
				</div>
				<div id="' . $prefix . '_loading-' . $key . '" class="meta_submit_loading"></div>
			</td>
			<td class="item-opt-value"><textarea name="' . $prefix . '[' . $key . '][value]" id="' . $prefix . '[' . $key . '][value]" class="optvalue">' . $value . '</textarea></td>
		</tr>';
        return $r;
    }
Example #18
0
function wc2_get_send_out_date() {
	$general = wc2_get_option( 'general' );
	$delivery = wc2_get_option( 'delivery' );
	$shipping_rule = wc2_get_option( 'shipping_rule' );

	$bus_day_arr = (isset($general['business_days'])) ? $general['business_days'] : false;
	list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = preg_split( '([^0-9])', current_time('mysql') );
	if( !is_array($bus_day_arr) ) {
		$today_bus_flag = 1;
	} else {
		$today_bus_flag = isset($bus_day_arr[(int)$today_year][(int)$today_month][(int)$today_day]) ? (int)$bus_day_arr[(int)$today_year][(int)$today_month][(int)$today_day] : 1;
	}

	// get the time limit addition
	$limit_hour = (!empty($delivery['delivery_time_limit']['hour'])) ? $delivery['delivery_time_limit']['hour'] : false;
	$limit_min = (!empty($delivery['delivery_time_limit']['min'])) ? $delivery['delivery_time_limit']['min'] : false;

	if( false === $hour || false === $minute ) {
		$time_limit_addition = false;
	} elseif( ($hour.':'.$minute.':'.$second) > ($limit_hour.':'.$limit_min.':00') ) {
		$time_limit_addition = 1;
	} else {
		$time_limit_addition = 0;
	}

	// get the shipping indication in cart
	$cart = wc2_get_cart();
	$shipping_indication = apply_filters( 'wc2_filter_shipping_indication', $shipping_rule['indication'] );
	$shipping = 0;
	$indication_flag = true;
	foreach( $cart as $key => $cart_row ) {
		$shipment = wc2_get_item_value_by_item_id( $cart_row['item_id'], ITEM_PREPARATIONS_SHIPMENT );
		if( $shipment === 0 or $shipment === 9 ) {
			$indication_flag = false;
			break;
		}
		if( $shipping < $shipment ) $shipping = $shipment;
	}
	$indication_incart = ( $indication_flag ) ? $shipping_indication[$shipping] : false;
	$indication_incart = apply_filters( 'wc2_filter_indication_incart', $indication_incart, $shipping_indication, $shipping, $cart );

	// get the send out date
	$sendout_num = 0;
	if( $today_bus_flag ) {
		if( $time_limit_addition ) {
			$sendout_num += 1;
		}
		if( false !== $indication_incart ) {
			$sendout_num += $indication_incart;
		}
	} else {
		if( false !== $indication_incart ) {
			$sendout_num += $indication_incart;
		}
	}
	$holiday = 0;
	for( $i = 0; $i <= $sendout_num; $i++ ) {
		list($yyyy, $mm, $dd) = explode('-', date('Y-m-d', mktime(0,0,0,(int)$today_month,($today_day + $i),(int)$today_year)));
		if( isset($bus_day_arr[(int)$yyyy][(int)$mm][(int)$dd]) && !$bus_day_arr[(int)$yyyy][(int)$mm][(int)$dd] ) {
			$holiday++;
			$sendout_num++;
		}
		if( 100 < $sendout_num ) break;
	}
	list($send_y, $send_m, $send_d) = explode('-', date('Y-m-d', mktime(0,0,0,(int)$today_month,($today_day + $sendout_num),(int)$today_year)));

	$sendout = array(
		'today_bus_flag'      => $today_bus_flag, 
		'time_limit_addition' => $time_limit_addition, 
		'indication_incart'   => $indication_incart, 
		'holiday'             => $holiday, 
		'sendout_num'         => $sendout_num, 
		'sendout_date'        => array('year' => $send_y, 'month' => $send_m, 'day' => $send_d)
	);
	return $sendout;
}
Example #19
0
	public function changepass_check(){
		$mes = array();
		//文字数チェック追加
		if( WC2_Utils::is_blank($_POST['new_password1']) || WC2_Utils::is_blank($_POST['new_password2']) ){
			$mes[] = __('新しいパスワードを入力してください。', 'wc2');
		}elseif( trim($_POST['new_password1']) != trim($_POST['new_password2']) ){
			$mes[] = __('確認用パスワードと異なります。', 'wc2');
		}elseif( !preg_match( "/^[a-zA-Z0-9]+$/", trim( $_POST['new_password1'] ) ) ){
			$mes[] = __('パスワードは半角英数字で入力してください。', 'wc2');
		}else{
			$general = wc2_get_option('general');
			$member_pass_rule_min = $general['member_pass_rule_min'];
			$member_pass_rule_max = $general['member_pass_rule_max'];
			if( !empty( $member_pass_rule_max ) ){
				if( $member_pass_rule_min > strlen( trim($_POST['new_password1']) ) || strlen( trim($_POST['new_password1']) ) > $member_pass_rule_max ){
					$mes[] = sprintf(__('パスワードは%1$s文字以上%2$s文字以下で入力してください。', 'wc2'), $member_pass_rule_min, $member_pass_rule_max );
				}
			}else{
				if( $member_pass_rule_min > strlen( trim($_POST['new_password1']) ) ){
					$mes[] = sprintf(__('パスワードは%s文字以上で入力してください。', 'wc2'), $member_pass_rule_min);
				}
			}
		}
		return $mes;
	}
Example #20
0
 function member_password_rule()
 {
     $general = wc2_get_option('general');
     $member_pass_rule_min = isset($general['member_pass_rule_min']) ? $general['member_pass_rule_min'] : '';
     $member_pass_rule_max = isset($general['member_pass_rule_max']) ? $general['member_pass_rule_max'] : '';
     if (empty($member_pass_rule_min)) {
         return;
     }
     if (empty($member_pass_rule_max)) {
         $rule = $member_pass_rule_min . '文字以上';
     } else {
         $rule = $member_pass_rule_min . '文字以上 ' . $member_pass_rule_max . '文字以下';
     }
     return $rule;
 }
Example #21
0
    }
}
?>
					<label for="chk-order-note"><input type="checkbox" class="check-order" id="chk-order-note" value="note"<?php 
wc2_checked_e($chk_order, 'note');
?>
 /><?php 
_e('Notes', 'wc2');
?>
</label>
				<?php 
$oth_keys = WC2_Funcs::get_custom_field_keys(WC2_CSOD, 'other');
if (!empty($oth_keys)) {
    foreach ($oth_keys as $key => $cs_key) {
        $checked = WC2_Funcs::get_checked($chk_order, $cs_key);
        $entry = wc2_get_option($cs_key);
        $name = $entry['name'];
        ?>
					<label for="chk-order-<?php 
        esc_attr_e($cs_key);
        ?>
"><input type="checkbox" class="check-order" id="chk-order-<?php 
        esc_attr_e($cs_key);
        ?>
" value="<?php 
        esc_attr_e($cs_key);
        ?>
"<?php 
        echo $checked;
        ?>
/><?php 
 public function general_setting_page()
 {
     global $allowedposttags;
     if (!isset($this->plugin_screen_hook_suffix)) {
         return;
     }
     $screen = get_current_screen();
     if ($this->plugin_screen_hook_suffix != $screen->id) {
         return;
     }
     $general = wc2_get_option('general');
     $cart_description = wc2_get_option('cart_description');
     $member_description = wc2_get_option('member_description');
     if (array_key_exists('wc2_option_update', $_POST)) {
         check_admin_referer('wc2_setting_general', 'wc2_nonce');
         //			$this->error_message = $this->setting_delivery_check();
         $_POST = WC2_Utils::stripslashes_deep_post($_POST);
         //ショップ設定
         $general['company_name'] = isset($_POST['company_name']) ? trim($_POST['company_name']) : '';
         $general['zip_code'] = isset($_POST['zip_code']) ? trim($_POST['zip_code']) : '';
         $general['address1'] = isset($_POST['address1']) ? trim($_POST['address1']) : '';
         $general['address2'] = isset($_POST['address2']) ? trim($_POST['address2']) : '';
         $general['tel_number'] = isset($_POST['tel_number']) ? trim($_POST['tel_number']) : '';
         $general['fax_number'] = isset($_POST['fax_number']) ? trim($_POST['fax_number']) : '';
         $general['order_mail'] = isset($_POST['order_mail']) ? trim($_POST['order_mail']) : '';
         $general['inquiry_mail'] = isset($_POST['inquiry_mail']) ? trim($_POST['inquiry_mail']) : '';
         $general['sender_mail'] = isset($_POST['sender_mail']) ? trim($_POST['sender_mail']) : '';
         $general['error_mail'] = isset($_POST['error_mail']) ? trim($_POST['error_mail']) : '';
         $general['postage_privilege'] = isset($_POST['postage_privilege']) ? trim($_POST['postage_privilege']) : '';
         $general['purchase_limit'] = isset($_POST['purchase_limit']) ? trim($_POST['purchase_limit']) : '';
         $general['shipping_rule'] = isset($_POST['shipping_rule']) ? trim($_POST['shipping_rule']) : '';
         $general['tax_mode'] = isset($_POST['tax_mode']) ? trim($_POST['tax_mode']) : 'include';
         $general['tax_target'] = isset($_POST['tax_target']) ? trim($_POST['tax_target']) : 'products';
         $general['tax_rate'] = isset($_POST['tax_rate']) ? (int) $_POST['tax_rate'] : '';
         $general['tax_method'] = isset($_POST['tax_method']) ? trim($_POST['tax_method']) : '';
         $general['copyright'] = isset($_POST['copyright']) ? trim($_POST['copyright']) : '';
         $general['add2cart'] = isset($_POST['add2cart']) ? trim($_POST['add2cart']) : '0';
         //営業設定
         $general['display_mode'] = isset($_POST['display_mode']) ? trim($_POST['display_mode']) : '';
         $general['campaign_category'] = empty($_POST['cat']) ? '0' : $_POST['cat'];
         $general['campaign_privilege'] = isset($_POST['cat_privilege']) ? trim($_POST['cat_privilege']) : '';
         $general['privilege_point'] = isset($_POST['point_num']) ? (int) $_POST['point_num'] : '';
         $general['privilege_discount'] = isset($_POST['discount_num']) ? (int) $_POST['discount_num'] : '';
         $general['campaign_schedule'] = isset($_POST['campaign_schedule']) ? $_POST['campaign_schedule'] : '0';
         if (isset($_POST['business_days'])) {
             $general['business_days'] = $_POST['business_days'];
         }
         //会員システム
         $general['membersystem_state'] = isset($_POST['membersystem_state']) ? trim($_POST['membersystem_state']) : '';
         $general['membersystem_point'] = isset($_POST['membersystem_point']) ? trim($_POST['membersystem_point']) : '';
         $general['point_rate'] = isset($_POST['point_rate']) ? (int) $_POST['point_rate'] : 1;
         $general['start_point'] = isset($_POST['start_point']) ? (int) $_POST['start_point'] : '';
         $general['point_coverage'] = isset($_POST['point_coverage']) ? (int) $_POST['point_coverage'] : 0;
         $general['point_assign'] = isset($_POST['point_assign']) ? (int) $_POST['point_assign'] : 1;
         $general['member_pass_rule_min'] = isset($_POST['member_pass_rule_min']) ? (int) $_POST['member_pass_rule_min'] : 6;
         $general['member_pass_rule_max'] = isset($_POST['member_pass_rule_max']) && !empty($_POST['member_pass_rule_max']) ? (int) $_POST['member_pass_rule_max'] : '';
         //カートページ設定
         foreach ($general['indi_item_name'] as $key => $val) {
             $general['indi_item_name'][$key] = isset($_POST['indication'][$key]) ? 1 : 0;
         }
         foreach ($_POST['position'] as $key => $value) {
             $general['position'][$key] = $value;
         }
         //カート関連ページに挿入する説明書き
         foreach ($_POST['cart_header'] as $key => $value) {
             $cart_description['cart_header'][$key] = isset($_POST['cart_header'][$key]) ? addslashes(wp_kses($value, $allowedposttags)) : '';
         }
         foreach ($_POST['cart_footer'] as $key => $value) {
             $cart_description['cart_footer'][$key] = isset($_POST['cart_footer'][$key]) ? addslashes(wp_kses($value, $allowedposttags)) : '';
         }
         //会員関連ページに挿入する説明書き
         foreach ($_POST['member_header'] as $key => $value) {
             $member_description['member_header'][$key] = isset($_POST['member_header'][$key]) ? addslashes(wp_kses($value, $allowedposttags)) : '';
         }
         foreach ($_POST['member_footer'] as $key => $value) {
             $member_description['member_footer'][$key] = isset($_POST['member_footer'][$key]) ? addslashes(wp_kses($value, $allowedposttags)) : '';
         }
         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;
         }
         $general = apply_filters('wc2_filter_admin_setup_options', $general);
         wc2_update_option('general', $general);
         wc2_update_option('cart_description', $cart_description);
         wc2_update_option('member_description', $member_description);
         do_action('wc2_action_general_option_update');
         $this->action_status = 'success';
         $this->action_message = __('Updated!');
     } else {
         $this->action_status = 'none';
         $this->action_message = '';
     }
     $status = $this->action_status;
     $message = $this->action_message;
     //today
     list($todayyy, $todaymm, $todaydd) = wc2_get_today();
     for ($i = 0; $i < 12; $i++) {
         if (0 == $i) {
             $this->cal[$i] = new Calendar_Data();
             $this->cal[$i]->setToday($todayyy, $todaymm, $todaydd);
             $this->cal[$i]->setCalendarData();
         }
         list($month_yy[$i], $month_mm[$i], $month_dd[$i]) = wc2_get_aftermonth($todayyy, $todaymm, 1, $i);
         $this->cal[$i] = new Calendar_Data();
         $this->cal[$i]->setToday($month_yy[$i], $month_mm[$i], $month_dd[$i]);
         $this->cal[$i]->setCalendarData();
     }
     $yearstr = substr(get_date_from_gmt(gmdate('Y-m-d H:i:s', time())), 0, 4);
     $campaign_schedule_start_year = isset($general['campaign_schedule']['start']['year']) ? $general['campaign_schedule']['start']['year'] : 0;
     $campaign_schedule_start_month = isset($general['campaign_schedule']['start']['month']) ? $general['campaign_schedule']['start']['month'] : 0;
     $campaign_schedule_start_day = isset($general['campaign_schedule']['start']['day']) ? $general['campaign_schedule']['start']['day'] : 0;
     $campaign_schedule_start_hour = isset($general['campaign_schedule']['start']['hour']) ? $general['campaign_schedule']['start']['hour'] : 0;
     $campaign_schedule_start_min = isset($general['campaign_schedule']['start']['min']) ? $general['campaign_schedule']['start']['min'] : 0;
     $campaign_schedule_end_year = isset($general['campaign_schedule']['end']['year']) ? $general['campaign_schedule']['end']['year'] : 0;
     $campaign_schedule_end_month = isset($general['campaign_schedule']['end']['month']) ? $general['campaign_schedule']['end']['month'] : 0;
     $campaign_schedule_end_day = isset($general['campaign_schedule']['end']['day']) ? $general['campaign_schedule']['end']['day'] : 0;
     $campaign_schedule_end_hour = isset($general['campaign_schedule']['end']['hour']) ? $general['campaign_schedule']['end']['hour'] : 0;
     $campaign_schedule_end_min = isset($general['campaign_schedule']['end']['min']) ? $general['campaign_schedule']['end']['min'] : 0;
     $common_opts = isset($general['_iopt_']) ? $general['_iopt_'] : '';
     $display_mode_label = wc2_get_option('display_mode_label');
     $indi_item_name = $general['indi_item_name'];
     $pos_item_name = $general['pos_item_name'];
     foreach ((array) $indi_item_name as $key => $value) {
         $checked_item_name[$key] = $indi_item_name[$key] == 1 ? ' checked="checked"' : '';
     }
     if (!empty($cart_description)) {
         $cart_page_data = stripslashes_deep($cart_description);
     } else {
         $cart_page_data['cart_header'] = array();
         $cart_page_data['cart_footer'] = array();
     }
     if (!empty($member_description)) {
         $member_page_data = stripslashes_deep($member_description);
     } else {
         $member_page_data['member_header'] = array();
         $member_page_data['member_footer'] = array();
     }
     require_once WC2_PLUGIN_DIR . '/admin/views/setting-general.php';
 }
Example #23
0
 public function phrase_ajax()
 {
     //if( !check_ajax_referer( 'wc2_setting_phrase', 'wc2_nonce', false ) ) die();
     if (!isset($_POST['action']) or !isset($_POST['mode'])) {
         die;
     }
     if ($_POST['action'] != 'phrase_ajax') {
         die;
     }
     $res = '';
     switch ($_POST['mode']) {
         case 'select':
             $phrase = $_POST['phrase'];
             $phrase_options = wc2_get_option('phrase');
             $phrase_default = wc2_get_option('phrase_default');
             $title = WC2_Utils::is_blank($phrase_options['title'][$phrase]) ? $phrase_default['title'][$phrase] : $phrase_options['title'][$phrase];
             $header = WC2_Utils::is_blank($phrase_options['header'][$phrase]) ? $phrase_default['header'][$phrase] : $phrase_options['header'][$phrase];
             $footer = WC2_Utils::is_blank($phrase_options['footer'][$phrase]) ? $phrase_default['footer'][$phrase] : $phrase_options['footer'][$phrase];
             $res = 'OK' . WC2_SPLIT . $title . WC2_SPLIT . $header . WC2_SPLIT . $footer;
             break;
         case 'update':
             if (!check_ajax_referer('wc2_setting_phrase', 'wc2_nonce', false)) {
                 $res = 'NG' . WC2_SPLIT . __('Security error.');
             } else {
                 $_POST = wc2_stripslashes_deep_post($_POST);
                 $phrase = $_POST['phrase'];
                 $phrase_options = wc2_get_option('phrase');
                 $phrase_options['title'][$phrase] = urldecode(trim($_POST['title']));
                 $phrase_options['header'][$phrase] = urldecode(trim($_POST['header']));
                 $phrase_options['footer'][$phrase] = urldecode(trim($_POST['footer']));
                 $phrase_options = apply_filters('wc2_filter_admin_phrase_update', $phrase_options, $phrase);
                 wc2_update_option('phrase', $phrase_options);
                 $res = 'OK' . WC2_SPLIT . $phrase_options['footer'][$phrase];
             }
             break;
     }
     $res = apply_filters('wc2_filter_admin_phrase_ajax', $res);
     die($res);
 }
 function delete_delivery_days()
 {
     $delivery_days = wc2_get_option('delivery_days');
     $id = (int) $_POST['id'];
     for ($i = 0; $i < count($delivery_days); $i++) {
         if ($delivery_days[$i]['id'] === $id) {
             $index = $i;
         }
     }
     array_splice($delivery_days, $index, 1);
     $res = wc2_update_option('delivery_days', $delivery_days);
     if ($res !== NULL) {
         $data_val = array('id' => $id);
         $data = array('message' => __('Updated!'), 'value' => $data_val);
         wp_send_json_success($data);
     } else {
         //error
         $data = array('message' => __('Update Failed'));
         wp_send_json_error($data);
     }
 }
Example #25
0
 public function wc2_download_member_list()
 {
     global $wpdb;
     $wc2_options = wc2_get_option();
     $locale_options = wc2_get_option('locale_options');
     $applyform = WC2_Funcs::get_apply_addressform($wc2_options['system']['addressform']);
     $target_market = $wc2_options['system']['target_market'];
     $MLT = new Member_List_Table();
     //1ぺーじあたりのテーブルの行数
     $per_page = $MLT->get_items_per_page(self::$per_page_slug);
     //ソート
     $args = $MLT->sort_culum_order_by($per_page);
     //データ
     $rows = $MLT->get_list_data($args);
     $ext = $_REQUEST['ftype'];
     if ($ext == 'csv') {
         //CSV
         $table_h = "";
         $table_f = "";
         $tr_h = "";
         $tr_f = "";
         $th_h1 = '"';
         $th_h = ',"';
         $th_f = '"';
         $td_h1 = '"';
         $td_h = ',"';
         $td_f = '"';
         $nb = " ";
         $lf = "\n";
     } else {
         exit;
     }
     $wc2_opt_member = wc2_get_option('wc2_opt_member');
     if (!is_array($wc2_opt_member)) {
         $wc2_opt_member = array();
     }
     $wc2_opt_member['ftype_mem'] = $ext;
     //---------------------- checkbox Check -----------------------//
     $chk_mem = array();
     $chk_mem['ID'] = 1;
     //$chk_mem['code'] = 1;
     $chk_mem['account'] = 1;
     //head
     $hd_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'head');
     if (!empty($hd_keys)) {
         foreach ($hd_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $chk_mem['email'] = isset($_REQUEST['check']['email']) ? 1 : 0;
     //beforename
     $bn_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'beforename');
     if (!empty($bn_keys)) {
         foreach ($bn_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $chk_mem['name'] = 1;
     $chk_mem['kana'] = isset($_REQUEST['check']['kana']) ? 1 : 0;
     //aftername
     $an_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'aftername');
     if (!empty($an_keys)) {
         foreach ($an_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $chk_mem['country'] = isset($_REQUEST['check']['country']) ? 1 : 0;
     $chk_mem['zipcode'] = isset($_REQUEST['check']['zipcode']) ? 1 : 0;
     $chk_mem['pref'] = 1;
     $chk_mem['address1'] = 1;
     $chk_mem['address2'] = 1;
     $chk_mem['tel'] = isset($_REQUEST['check']['tel']) ? 1 : 0;
     $chk_mem['fax'] = isset($_REQUEST['check']['fax']) ? 1 : 0;
     //bottom
     $btm_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'bottom');
     if (!empty($btm_keys)) {
         foreach ($btm_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $chk_mem['registered'] = isset($_REQUEST['check']['registered']) ? 1 : 0;
     $chk_mem['point'] = isset($_REQUEST['check']['point']) ? 1 : 0;
     $chk_mem['rank'] = isset($_REQUEST['check']['rank']) ? 1 : 0;
     //other
     $oth_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'other');
     if (!empty($oth_keys)) {
         foreach ($oth_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $wc2_opt_member['chk_mem'] = apply_filters('wc2_filter_chk_mem', $chk_mem);
     //		update_option('wc2_opt_member', $wc2_opt_member);
     wc2_update_option('wc2_opt_member', $wc2_opt_member);
     //---------------------- TITLE -----------------------//
     $line = $table_h;
     $line .= $tr_h;
     $line .= $th_h1 . __('Membership ID', 'wc2') . $th_f;
     $line .= $th_h . __('Login account', 'wc2') . $th_f;
     //csmb head
     $hd_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'head');
     if (!empty($hd_keys)) {
         foreach ($hd_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     if (isset($_REQUEST['check']['email'])) {
         $line .= $th_h . __('E-mail', 'wc2') . $th_f;
     }
     //csmb beforename
     $bn_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'beforename');
     if (!empty($bn_keys)) {
         foreach ($bn_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     $line .= $th_h . __('Name', 'wc2') . $th_f;
     if ('JP' == $applyform) {
         if (isset($_REQUEST['check']['kana'])) {
             $line .= $th_h . __('Kana', 'wc2') . $th_f;
         }
     }
     //csmb aftername
     $an_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'aftername');
     if (!empty($an_keys)) {
         foreach ($an_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     switch ($applyform) {
         case 'JP':
             if (isset($_REQUEST['check']['country'])) {
                 $line .= $th_h . __('Country', 'wc2') . $th_f;
             }
             if (isset($_REQUEST['check']['zipcode'])) {
                 $line .= $th_h . __('Postal Code', 'wc2') . $th_f;
             }
             $line .= $th_h . __('Prefecture', 'wc2') . $th_f;
             $line .= $th_h . __('City', 'wc2') . $th_f;
             $line .= $th_h . __('Building name, floor, room number', 'wc2') . $th_f;
             if (isset($_REQUEST['check']['tel'])) {
                 $line .= $th_h . __('Phone number', 'wc2') . $th_f;
             }
             if (isset($_REQUEST['check']['fax'])) {
                 $line .= $th_h . __('FAX number', 'wc2') . $th_f;
             }
             break;
         case 'US':
         default:
             $line .= $th_h . __('Building name, floor, room number', 'wc2') . $th_f;
             $line .= $th_h . __('City', 'wc2') . $th_f;
             $line .= $th_h . __('Prefecture', 'wc2') . $th_f;
             $line .= $th_h . __('Postal Code', 'wc2') . $th_f;
             if (isset($_REQUEST['check']['country'])) {
                 $line .= $th_h . __('Country', 'wc2') . $th_f;
             }
             if (isset($_REQUEST['check']['tel'])) {
                 $line .= $th_h . __('Phone number', 'wc2') . $th_f;
             }
             if (isset($_REQUEST['check']['fax'])) {
                 $line .= $th_h . __('FAX number', 'wc2') . $th_f;
             }
             break;
     }
     //csmb bottom
     $btm_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'bottom');
     if (!empty($btm_keys)) {
         foreach ($btm_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     if (isset($_REQUEST['check']['rank'])) {
         $line .= $th_h . __('ランク', 'wc2') . $th_f;
     }
     if (isset($_REQUEST['check']['point'])) {
         $line .= $th_h . __('保有ポイント', 'wc2') . $th_f;
     }
     if (isset($_REQUEST['check']['registered'])) {
         $line .= $th_h . __('Started date', 'wc2') . $th_f;
     }
     //csmb other
     $oth_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'other');
     if (!empty($oth_keys)) {
         foreach ($oth_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     $line .= apply_filters('wc2_filter_chk_mem_label', NULL, $wc2_opt_member, $rows);
     $line .= $tr_f . $lf;
     //---------------------- DATA -----------------------//
     foreach ((array) $rows as $array) {
         $member_id = $array['ID'];
         $data = wc2_get_member_data($member_id);
         //$meta_data = wc2_get_member_data($member_id);
         $line .= $tr_h;
         $line .= $td_h1 . $member_id . $td_f;
         $line .= $td_h . wc2_entity_decode($data['account'], $ext) . $td_f;
         //csmb head
         $hd_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'head');
         if (!empty($hd_keys)) {
             foreach ($hd_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         if (isset($_REQUEST['check']['email'])) {
             $line .= $td_h . wc2_entity_decode($data['email'], $ext) . $td_f;
         }
         //csmb beforename
         $bn_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'beforename');
         if (!empty($bn_keys)) {
             foreach ($bn_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         switch ($applyform) {
             case 'JP':
                 $line .= $td_h . wc2_entity_decode($data['name1'] . ' ' . $data['name2'], $ext) . $td_f;
                 if (isset($_REQUEST['check']['kana'])) {
                     $line .= $td_h . wc2_entity_decode($data['name3'] . ' ' . $data['name4'], $ext) . $td_f;
                 }
                 break;
             default:
                 $line .= $td_h . wc2_entity_decode($data['name2'] . ' ' . $data['name1'], $ext) . $td_f;
                 break;
         }
         //csmb aftername
         $an_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'aftername');
         if (!empty($an_keys)) {
             foreach ($an_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         $address_info = '';
         switch ($applyform) {
             case 'JP':
                 if (isset($_REQUEST['check']['country'])) {
                     $country_code = $data['country'];
                     $member_country = !empty($country_code) ? $locale_options['country'][$country_code] : '';
                     $address_info .= $td_h . $member_country . $td_f;
                 }
                 if (isset($_REQUEST['check']['zipcode'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['zipcode'], $ext) . $td_f;
                 }
                 $address_info .= $td_h . wc2_entity_decode($data['pref'], $ext) . $td_f;
                 $address_info .= $td_h . wc2_entity_decode($data['address1'], $ext) . $td_f;
                 $address_info .= $td_h . wc2_entity_decode($data['address2'], $ext) . $td_f;
                 if (isset($_REQUEST['check']['tel'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['tel'], $ext) . $td_f;
                 }
                 if (isset($_REQUEST['check']['fax'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['fax'], $ext) . $td_f;
                 }
                 break;
             case 'US':
             default:
                 $address_info .= $td_h . wc2_entity_decode($data['address2'], $ext) . $td_f;
                 $address_info .= $td_h . wc2_entity_decode($data['address1'], $ext) . $td_f;
                 $address_info .= $td_h . wc2_entity_decode($data['pref'], $ext) . $td_f;
                 if (isset($_REQUEST['check']['zipcode'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['zipcode'], $ext) . $td_f;
                 }
                 if (isset($_REQUEST['check']['country'])) {
                     $country_code = $data['country'];
                     $member_country = !empty($country_code) ? $locale_options['country'][$country_code] : '';
                     $address_info .= $td_h . $member_country . $td_f;
                 }
                 if (isset($_REQUEST['check']['tel'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['tel'], $ext) . $td_f;
                 }
                 if (isset($_REQUEST['check']['fax'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['fax'], $ext) . $td_f;
                 }
                 break;
         }
         $address_info_args = compact('td_h', 'td_f', 'ext', 'member_id', 'applyform');
         $line .= apply_filters('wc2_filter_mem_csv_address_info', $address_info, $data, $address_info_args);
         //csmb bottom
         $btm_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'bottom');
         if (!empty($btm_keys)) {
             foreach ($btm_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         if (isset($_REQUEST['check']['rank'])) {
             $rank_num = $data['rank'];
             $line .= $td_h . $wc2_options['rank_type'][$rank_num] . $td_f;
         }
         if (isset($_REQUEST['check']['point'])) {
             $line .= $td_h . $data['point'] . $td_f;
         }
         if (isset($_REQUEST['check']['registered'])) {
             $line .= $td_h . $data['registered'] . $td_f;
         }
         //csmb other
         $oth_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'other');
         if (!empty($oth_keys)) {
             foreach ($oth_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         $line .= apply_filters('wc2_filter_chk_mem_data', NULL, $wc2_opt_member, $member_id, $data);
         $line .= $tr_f . $lf;
     }
     $line .= $table_f . $lf;
     if ($ext == 'xls') {
         header("Content-Type: application/vnd.ms-excel; charset=Shift-JIS");
     } elseif ($ext == 'csv') {
         header("Content-Type: application/octet-stream");
     }
     header("Content-Disposition: attachment; filename=wc2_member_list." . $ext);
     mb_http_output('pass');
     print mb_convert_encoding($line, "SJIS-win", "UTF-8");
     exit;
 }
Example #26
0
        function process_posts()
        {
            if (!($fp = fopen($this->file, "r"))) {
                echo '<p><strong>' . __('Failed to open file.', 'wc2') . '</strong></p>';
                wp_import_cleanup($this->id);
                return false;
            }
            global $wpdb;
            $wc2_item = WC2_DB_Item::get_instance();
            //all delete
            //$wc2_item->delete_all_item_data();
            //die();
            $err = new WP_Error();
            $sp = ",";
            $lines = array();
            $buf = '';
            while (!feof($fp)) {
                $temp = fgets($fp, 10240);
                if (0 == strlen($temp)) {
                    continue;
                }
                $num = substr_count($temp, '"');
                if (0 == $num % 2 && '' == $buf) {
                    $lines[] = $temp;
                } elseif (1 == $num % 2 && '' == $buf) {
                    $buf .= $temp;
                } elseif (0 == $num % 2 && '' != $buf) {
                    $buf .= $temp;
                } elseif (1 == $num % 2 && '' != $buf) {
                    $buf .= $temp;
                    $lines[] = $buf;
                    $buf = '';
                }
            }
            fclose($fp);
            //Post data - fixed
            define('COL_POST_ID', 0);
            define('COL_POST_AUTHOR', 1);
            define('COL_POST_CONTENT', 2);
            define('COL_POST_TITLE', 3);
            define('COL_POST_EXCERPT', 4);
            define('COL_POST_STATUS', 5);
            define('COL_POST_COMMENT_STATUS', 6);
            define('COL_POST_PASSWORD', 7);
            define('COL_POST_NAME', 8);
            define('COL_POST_MODIFIED', 9);
            define('COL_POST_CATEGORY', 10);
            define('COL_POST_TAG', 11);
            define('COL_POST_CUSTOM_FIELD', 12);
            define('COL_ITEM_CODE', 13);
            define('COL_ITEM_NAME', 14);
            $item_base_column = $wc2_item->get_item_base_column();
            $item_meta_column = $wc2_item->get_item_meta_column();
            $item_sku_column = $wc2_item->get_item_sku_column();
            $item_sku_meta_column = $wc2_item->get_item_sku_meta_column();
            $system = wc2_get_option('system');
            $this->encode_type = isset($system['csv_encode_type']) ? $system['csv_encode_type'] : 0;
            $start_col = 13;
            $sku_start_col = $start_col;
            foreach ((array) $item_base_column as $key => $column) {
                if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                    $sku_start_col++;
                }
            }
            foreach ((array) $item_meta_column as $key => $column) {
                if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                    $sku_start_col++;
                }
            }
            $post_status = array('publish', 'future', 'draft', 'pending', 'private');
            $pre_item_code = '';
            $item_id = 0;
            $sku_id = 1;
            $this->data_rows = count($lines);
            $this->success = 0;
            $this->false = 0;
            //Progressbar 処理件数SET
            echo '<script type="text/javascript">PG_Set_Max(' . $this->data_rows . ');</script>' . "\r\n";
            ob_flush();
            flush();
            foreach ($lines as $row => $line) {
                $datas = array();
                $datas = explode($sp, trim($line));
                $this->values = array();
                $buf = '';
                foreach ($datas as $data) {
                    $num = substr_count($data, '"');
                    if (0 == $num % 2 && '' == $buf) {
                        if ('"' == substr($data, 0, 1)) {
                            $data = substr($data, 1);
                        }
                        if ('"' == substr($data, -1)) {
                            $data = substr($data, 0, -1);
                        }
                        $data = str_replace(array('""'), '"', $data);
                        $this->values[] = false !== $data ? $data : '';
                    } elseif (1 == $num % 2 && '' == $buf) {
                        $buf .= $data;
                    } elseif (0 == $num % 2 && '' != $buf) {
                        $buf .= $sp . $data;
                    } elseif (1 == $num % 2 && '' != $buf) {
                        $buf .= $sp . $data;
                        if ('"' == substr($buf, 0, 1)) {
                            $buf = substr($buf, 1);
                        }
                        if ('"' == substr($buf, -1)) {
                            $buf = substr($buf, 0, -1);
                        }
                        $buf = str_replace(array('""'), '"', $buf);
                        $this->values[] = false !== $buf ? $buf : '';
                        $buf = '';
                    }
                }
                if ('Post ID' == $this->values[COL_POST_ID]) {
                    $this->data_rows -= 1;
                    $this->progress_add();
                    continue;
                }
                if ($pre_item_code == $this->values[COL_ITEM_CODE] && WC2_Utils::is_blank($this->values[COL_POST_ID])) {
                    $mode = 'add';
                    $post_id = '';
                } else {
                    $post_id = !WC2_Utils::is_blank($this->values[COL_POST_ID]) ? (int) $this->values[COL_POST_ID] : '';
                    if ($post_id) {
                        $post_ob = get_post($post_id);
                        if (!isset($post_ob->ID) || empty($post_ob)) {
                            $this->error_log($row, __("Post-ID {$post_id} does not exist.", 'wc2'));
                            $this->create_log();
                            $this->progress_add();
                            continue;
                        }
                        $mode = 'upd';
                    } else {
                        $mode = 'add';
                    }
                }
                $wc2_item->set_the_post_id($post_id);
                //data_check
                foreach ($this->values as $key => $val) {
                    $value = trim($val);
                    switch ($key) {
                        case COL_POST_ID:
                            if (!preg_match("/^[0-9]+\$/", $value) && 0 != strlen($value)) {
                                $this->error_log($row, __('A value of the Post-ID is abnormal.', 'wc2'));
                            }
                            break;
                        case COL_POST_AUTHOR:
                        case COL_POST_COMMENT_STATUS:
                        case COL_POST_PASSWORD:
                        case COL_POST_NAME:
                        case COL_POST_TITLE:
                        case COL_POST_CONTENT:
                        case COL_POST_EXCERPT:
                            break;
                        case COL_POST_STATUS:
                            if (0 == strlen($value) || !in_array($value, $post_status)) {
                                $this->error_log($row, __('A value of the display status is abnormal.', 'wc2'));
                            }
                            break;
                        case COL_POST_MODIFIED:
                            if ('future' == $this->values[COL_POST_STATUS] && (0 == strlen($value) || '0000-00-00 00:00:00' == $value)) {
                                if (preg_match($date_pattern, $value, $match)) {
                                    if (checkdate($match[2], $match[3], $match[1]) && (0 < $match[4] && 24 > $match[4]) && (0 < $match[5] && 60 > $match[5]) && (0 < $match[6] && 60 > $match[6])) {
                                    } else {
                                        $this->error_log($row, __('A value of the schedule is abnormal.', 'wc2'));
                                    }
                                } else {
                                    $this->error_log($row, __('A value of the schedule is abnormal.', 'wc2'));
                                }
                            } else {
                                if (0 != strlen($value) && '0000-00-00 00:00:00' != $value) {
                                    if (preg_match("/^[0-9]+\$/", substr($value, 0, 4))) {
                                        if (strtotime($value) === false) {
                                            $this->error_log($row, __('A value of the schedule is abnormal.', 'wc2'));
                                        }
                                    } else {
                                        $datetime = explode(' ', $value);
                                        $date_str = $this->dates_interconv($datetime[0]) . ' ' . $datetime[1];
                                        if (strtotime($date_str) === false) {
                                            $this->error_log($row, __('A value of the schedule is abnormal.', 'wc2'));
                                        }
                                    }
                                }
                            }
                            break;
                        case COL_POST_CATEGORY:
                            if (0 == strlen($value)) {
                                $this->error_log($row, __('A category is non-input.', 'wc2'));
                            }
                            break;
                        case COL_POST_TAG:
                        case COL_POST_CUSTOM_FIELD:
                            break;
                        case COL_ITEM_CODE:
                            if (0 == strlen($value)) {
                                $this->error_log($row, __('An item code is non-input.', 'wc2'));
                            } else {
                                $post_ids = $wc2_item->get_some_post_ids_by_item_code($value);
                                if ('upd' == $mode) {
                                    if (1 < count($post_ids)) {
                                        $this->error_log($row, __('This Item-Code has been duplicated.', 'wc2'));
                                        foreach ($post_ids as $res_val) {
                                            $this->error_log($row, "item_code=" . $value . ", post_id=" . $res_val['item_post_id']);
                                        }
                                    } elseif (1 === count($post_ids)) {
                                        if ($post_ids[0]['item_post_id'] != $post_id) {
                                            $this->error_log($row, __('This Item-Code has already been used.', 'wc2'));
                                            $this->error_log($row, "item_code=" . $value . ", post_id=" . $post_ids[0]['item_post_id']);
                                        }
                                    }
                                } else {
                                    if ('add' == $mode) {
                                        if ($value != $pre_item_code) {
                                            if (0 < count($post_ids)) {
                                                $this->error_log($row, __('This Item-Code has already been used.', 'wc2'));
                                                foreach ($post_ids as $res_val) {
                                                    $this->error_log($row, "item_code=" . $value . ", post_id=" . $res_val['item_post_id']);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        case COL_ITEM_NAME:
                            if (0 == strlen($value)) {
                                $this->error_log($row, __('An item name is non-input.', 'wc2'));
                            }
                            break;
                    }
                }
                //表示する Item column をエラーチェック
                $check_num = $start_col;
                foreach ($item_base_column as $key => $column) {
                    if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                        $check_column[$key] = $check_num;
                        $check_num++;
                    }
                }
                foreach ($item_meta_column as $key => $column) {
                    if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                        $check_column[$key] = $check_num;
                        $check_num++;
                    }
                }
                foreach ($item_sku_column as $key => $column) {
                    if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                        $check_column[$key] = $check_num;
                        $check_num++;
                    }
                }
                foreach ($item_sku_meta_column as $key => $column) {
                    if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                        $check_column[$key] = $check_num;
                        $check_num++;
                    }
                }
                foreach ($check_column as $column_key => $data_num) {
                    switch ($column_key) {
                        case ITEM_PRODUCT_TYPE:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Product type is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_CHARGES_TYPE:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Billing type is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_PURCHASE_LIMIT_LOWEST:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Purchase limit(lowest) is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_PURCHASE_LIMIT_HIGHEST:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Purchase limit(highest) is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_POINT_RATE:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the point rate is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_QUANTITY_DISCOUNT_NUM1:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Quantity discount1(number) is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_QUANTITY_DISCOUNT_RATE1:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Quantity discount1(rate) is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_QUANTITY_DISCOUNT_NUM2:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Quantity discount2(number) is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_QUANTITY_DISCOUNT_RATE2:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Quantity discount2(rate) is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_QUANTITY_DISCOUNT_NUM3:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Quantity discount3(number) is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_QUANTITY_DISCOUNT_RATE3:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Quantity discount3(rate) is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_SKU_CODE:
                            if (0 == strlen($this->values[$data_num])) {
                                $this->error_log($row, __('A SKU code is non-input.', 'wc2'));
                            }
                            break;
                        case ITEM_SKU_NAME:
                        case ITEM_SKU_UNIT:
                            break;
                        case ITEM_SKU_STOCK:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the SKU stock is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_SKU_STATUS:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the SKU status is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_SKU_PRICE:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the SKU price is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_SKU_COSTPRICE:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the SKU cost price is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_SKU_LISTPRICE:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the SKU list price is abnormal.', 'wc2'));
                            }
                            break;
                        case ITEM_SKU_SET_QUANTITY_DISCOUNT:
                            if (!preg_match("/^[0-9]+\$/", $this->values[$data_num])) {
                                $this->error_log($row, __('A value of the Quantity discount applies is abnormal.', 'wc2'));
                            }
                            break;
                    }
                }
                if ('' != $this->get_log_line()) {
                    $this->create_log();
                    $this->progress_add();
                    continue;
                }
                $post = array();
                if ($pre_item_code != $this->values[COL_ITEM_CODE]) {
                    $sku_id = 1;
                    if ($this->values[COL_POST_MODIFIED] == '' || $this->values[COL_POST_MODIFIED] == '0000-00-00 00:00:00') {
                        $post['post_date'] = current_time('mysql');
                        $post['post_date_gmt'] = current_time('mysql', 1);
                        $post['post_modified'] = current_time('mysql');
                        $post['post_modified_gmt'] = current_time('mysql', 1);
                    } else {
                        if (preg_match("/^[0-9]+\$/", substr($this->values[COL_POST_MODIFIED], 0, 4))) {
                            $time_data = strtotime($this->values[COL_POST_MODIFIED]);
                        } else {
                            $datetime = explode(' ', $this->values[COL_POST_MODIFIED]);
                            $date_str = $this->dates_interconv($datetime[0]) . ' ' . $datetime[1];
                            $time_data = strtotime($date_str);
                        }
                        $post['post_date'] = date('Y-m-d H:i:s', $time_data);
                        $post['post_date_gmt'] = gmdate('Y-m-d H:i:s', $time_data);
                        $post['post_modified'] = date('Y-m-d H:i:s', $time_data);
                        $post['post_modified_gmt'] = gmdate('Y-m-d H:i:s', $time_data);
                    }
                    if ('publish' == $this->values[COL_POST_STATUS]) {
                        $now = current_time('mysql');
                        if (mysql2date('U', $post['post_modified'], false) > mysql2date('U', $now, false)) {
                            $this->values[COL_POST_STATUS] = 'future';
                        }
                    } elseif ('future' == $this->values[COL_POST_STATUS]) {
                        $now = current_time('mysql');
                        if (mysql2date('U', $post['post_modified'], false) <= mysql2date('U', $now, false)) {
                            $this->values[COL_POST_STATUS] = 'publish';
                        }
                    }
                    $post['ID'] = $post_id;
                    $post['post_author'] = !WC2_Utils::is_blank($this->values[COL_POST_AUTHOR]) ? $this->values[COL_POST_AUTHOR] : 1;
                    $post['post_content'] = $this->convert_encoding($this->values[COL_POST_CONTENT]);
                    $post['post_title'] = $this->convert_encoding($this->values[COL_POST_TITLE]);
                    $post['post_excerpt'] = $this->convert_encoding($this->values[COL_POST_EXCERPT]);
                    $post['post_status'] = $this->values[COL_POST_STATUS];
                    $post['comment_status'] = !WC2_Utils::is_blank($this->values[COL_POST_COMMENT_STATUS]) ? $this->values[COL_POST_COMMENT_STATUS] : 'close';
                    $post['ping_status'] = 'close';
                    $post['post_password'] = '******' == $post['post_status'] ? '' : $this->values[COL_POST_PASSWORD];
                    $post['post_type'] = ITEM_POST_TYPE;
                    $post['post_parent'] = 0;
                    $post_name = sanitize_title($this->convert_encoding($this->values[COL_POST_NAME]));
                    $post['post_name'] = wp_unique_post_slug($post_name, $post_id, $post['post_status'], $post['post_type'], $post['post_parent']);
                    $post['to_ping'] = '';
                    $post['pinged'] = '';
                    $post['menu_order'] = 0;
                    $post['post_content_filtered'] = '';
                    if (empty($post['post_name']) && !in_array($post['post_status'], array('draft', 'pending', 'auto-draft'))) {
                        $post['post_name'] = sanitize_title($post['post_title'], $post_id);
                    }
                    if ($mode == 'add') {
                        $post['guid'] = '';
                        if (false === $wpdb->insert($wpdb->posts, $post)) {
                            $this->error_log($row, __('This data was not registered in the database.', 'wc2'));
                            $pre_item_code = $this->values[COL_ITEM_CODE];
                            $this->create_log();
                            $this->progress_add();
                            continue;
                        }
                        $post_id = $wpdb->insert_id;
                        $wc2_item->set_the_post_id($post_id);
                        $where = array('ID' => $post_id);
                        $wpdb->update($wpdb->posts, array('guid' => get_permalink($post_id)), $where);
                    } elseif ($mode == 'upd') {
                        $where = array('ID' => $post_id);
                        if (false === $wpdb->update($wpdb->posts, $post, $where)) {
                            $this->error_log($row, __('The data were not registered with a database.', 'wc2'));
                            $pre_item_code = $this->values[COL_ITEM_CODE];
                            $this->create_log();
                            $this->progress_add();
                            continue;
                        }
                        //delete all metas of Item
                        $meta_key_table = array();
                        $cfrows = explode(';', trim($this->values[COL_POST_CUSTOM_FIELD]));
                        //if( !(1 === count($cfrows) && '' == reset($cfrows)) ) {
                        if ('' != reset($cfrows)) {
                            foreach ($cfrows as $cf) {
                                list($meta_key, $meta_value) = explode('=', $cf, 2);
                                if (!WC2_Utils::is_blank($meta_key)) {
                                    array_push($meta_key_table, $this->convert_encoding($meta_key));
                                }
                            }
                        }
                        $meta_key_table = apply_filters('wc2_filter_importitem_delete_postmeta', $meta_key_table);
                        $res = $wc2_item->delete_custome_field_key($meta_key_table);
                        if (false === $res) {
                            $this->error_log($row, __('Error : delete postmeta', 'wc2'));
                            $pre_item_code = $this->values[COL_ITEM_CODE];
                            $this->create_log();
                            $this->progress_add();
                            continue;
                        }
                        //delete Item revisions
                        $res = $wc2_item->delete_item_revision();
                        if (false === $res) {
                            $this->error_log($row, __('Error : delete revisions', 'wc2'));
                            $pre_item_code = $this->values[COL_ITEM_CODE];
                            $this->create_log();
                            $this->progress_add();
                            continue;
                        }
                        //delete relationships of category
                        $res = $wc2_item->delete_term_relationship();
                        if (false === $res) {
                            $this->error_log($row, __('Error : delete term_relationships(category)', 'wc2'));
                            $pre_item_code = $this->values[COL_ITEM_CODE];
                            $this->create_log();
                            $this->progress_add();
                            continue;
                        }
                        //delete relationships of tag
                        //$query = "SELECT term_taxonomy_id, COUNT(*) AS ct FROM {$wpdb->term_relationships} GROUP BY term_taxonomy_id";
                        //$relation_data = $wpdb->get_results( $query, ARRAY_A );
                        $relation_data = $wc2_item->get_count_term_taxonomy();
                        foreach ((array) $relation_data as $relation_rows) {
                            $term_taxonomy_where['term_taxonomy_id'] = $relation_rows['term_taxonomy_id'];
                            //	$term_taxonomy_id['term_taxonomy_id'] = $relation_rows['term_taxonomy_id'];
                            $term_taxonomy_updatas['count'] = $relation_rows['ct'];
                            if (false === $wpdb->update($wpdb->term_taxonomy, $term_taxonomy_updatas, $term_taxonomy_where)) {
                                $this->error_log($row, __('Error : delete term_relationships(tag)', 'wc2'));
                                $pre_item_code = $this->values[COL_ITEM_CODE];
                                continue;
                            }
                        }
                    }
                    //add term_relationships, edit term_taxonomy
                    //category
                    $categories = explode(';', $this->values[COL_POST_CATEGORY]);
                    $category_ids = array();
                    foreach ((array) $categories as $category) {
                        $cat = get_term_by('slug', $category, 'item');
                        if ($cat == false) {
                            $category = (string) $category;
                            $this->error_log($row, __(sprintf('Since the category slug "%s" does not exist or could not be category registration.', $this->convert_encoding($category)), 'wc2'));
                            continue;
                        }
                        $category_ids[] = $cat->term_id;
                    }
                    $term_taxonomy_ids = wp_set_post_terms($post_id, $category_ids, 'item');
                    foreach ($term_taxonomy_ids as $term_taxonomy_id) {
                        $wc2_item->term_taxonomy_count_post($term_taxonomy_id);
                    }
                    //tag
                    $tags_concat = str_replace(';', ',', $this->convert_encoding($this->values[COL_POST_TAG]));
                    $term_taxonomy_ids = wp_set_post_terms($post_id, $tags_concat, 'item-tag');
                    foreach ($term_taxonomy_ids as $term_taxonomy_id) {
                        $wc2_item->term_taxonomy_count_post($term_taxonomy_id);
                    }
                    //add custom field
                    $cfrows = explode(';', trim($this->values[COL_POST_CUSTOM_FIELD]));
                    //if( !(1 === count($cfrows) && '' == reset($cfrows)) ) {
                    if ('' != reset($cfrows)) {
                        $valstr = '';
                        foreach ($cfrows as $cf) {
                            list($meta_key, $meta_value) = explode('=', $cf, 2);
                            if (!WC2_Utils::is_blank($meta_key)) {
                                update_post_meta($post_id, $this->convert_encoding($meta_key), $this->convert_encoding($meta_value));
                            }
                        }
                    }
                    $wc2_item->clear_column();
                    //Item data set
                    $col = $start_col;
                    foreach ($item_base_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_value($key, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    foreach ($item_meta_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_value($key, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    //SKU data set
                    $col = $sku_start_col;
                    foreach ($item_sku_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    foreach ($item_sku_meta_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    if ($mode == 'add') {
                        $wc2_item->add_item_data();
                    } elseif ($mode == 'upd') {
                        $wc2_item->update_item_data();
                    }
                } else {
                    //sku登録のみの行
                    $sku_id++;
                    //SKU data set
                    $col = $sku_start_col;
                    foreach ($item_sku_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    foreach ($item_sku_meta_column as $key => $column) {
                        if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                            $wc2_item->set_the_item_sku_value($key, $sku_id, $this->set_value($col, $column['type']));
                            $col++;
                        }
                    }
                    $item_id = $wc2_item->get_item_id_by_post_id($post_id);
                    $sku_data = $wc2_item->get_item_sku_data($item_id, $sku_id);
                    if (0 == $wc2_item->count_sku_data($sku_id)) {
                        if (0 < $sku_id and '' != $wc2_item->get_the_item_sku_code($sku_id)) {
                            $res = $wc2_item->add_item_sku_data($sku_id, $wc2_item->get_item_sku_data($item_id, $sku_id));
                            if (false === $res) {
                                break;
                            }
                        }
                    } else {
                        $res = $wc2_item->update_item_sku_data($sku_id, $wc2_item->get_item_sku_data($item_id, $sku_id));
                        if (false === $res) {
                            break;
                        }
                    }
                }
                if ('' != $this->get_log_line()) {
                    $this->create_log();
                }
                //登録成功数加算
                $this->success += 1;
                $pre_item_code = $this->values[COL_ITEM_CODE];
                clean_post_cache($post_id);
                wp_cache_delete($post_id, 'posts');
                wp_cache_delete($post_id, 'post_meta');
                clean_object_term_cache($post_id, 'post');
                //進捗加算
                $this->progress_add();
            }
            wp_import_cleanup($this->id);
            $this->false = $this->data_rows - $this->success;
            echo '<h3>' . __('All Done.', 'wc2') . '</h3>
				  <h3>' . sprintf(__('Success %d failure %d', 'wc2'), $this->success, $this->false) . '</h3>';
            if (0 < strlen($this->log)) {
                WC2_Utils::wc2_log($this->log, "import_item.log");
                echo str_replace("\n", "<br />", $this->log);
            }
        }
Example #27
0
" />
				<fieldset class="dl-check-option">
					<legend><?php 
_e($this->title . '情報', 'wc2');
?>
</legend>
					<label for="chk_mem[ID]"><input type="checkbox" class="check_member" id="chk_mem[ID]" value="ID" checked="checked" disabled="disabled" /><?php 
_e('Membership ID', 'wc2');
?>
</label>
					<label for="chk_mem[account]"><input type="checkbox" class="check_member" id="chk_mem[account]" value="account" checked="checked" disabled="disabled" /><?php 
_e('Login account', 'wc2');
?>
</label>
			<?php 
$wc2_options = wc2_get_option();
$hd_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'head');
if (!empty($hd_keys)) {
    foreach ($hd_keys as $csmb_key) {
        $checked = WC2_Funcs::get_checked($chk_mem, $csmb_key);
        $name = $wc2_options[$csmb_key]['name'];
        echo '<label for="chk_mem[' . $csmb_key . ']"><input type="checkbox" class="check_member" id="chk_mem[' . esc_attr($csmb_key) . ']" value="' . esc_attr($csmb_key) . '"' . $checked . ' />' . esc_html($name) . '</label>' . "\n";
    }
}
?>
				<label for="chk_mem[email]"><input type="checkbox" class="check_member" id="chk_mem[email]" value="email"<?php 
wc2_checked_e($chk_mem, 'email');
?>
 /><?php 
_e('E-mail', 'wc2');
?>
		$index = wc2_get_delivery_method_index( $id );
		if( 0 <= $index ) {
			$script_days .= '
	delivery_days['.$id.'] = [];';
			$script_days .= '
	delivery_days['.$id.'].push("'.$delivery['delivery_method'][$index]['days'].'");';
		}
	}

	//配達日数に設定されている県毎の日数
	$target_market = ( isset($system['target_market']) && !empty($system['target_market']) ) ? $system['target_market'] : wc2_get_local_target_market();
	$prefs = array();
	foreach( (array)$target_market as $tm ) {
		$prefs[$tm] = $system['province'][$tm];
	}
	$delivery_days = wc2_get_option( 'delivery_days' );
	$script_days .= '
	var delivery_days_value = [];';
	foreach( (array)$default_deli as $id ) {
		$index = wc2_get_delivery_method_index( $id );
		if( 0 <= $index ) {
			$days = (int)$delivery['delivery_method'][$index]['days'];
			if( 0 <= $days ) {
				for( $i = 0; $i < count((array)$delivery_days); $i++ ) {
					if( (int)$delivery_days[$i]['id'] == $days ) {
						$script_days .= '
	delivery_days_value['.$days.'] = [];';
						foreach( (array)$target_market as $tm ) {
							$script_days .= '
	delivery_days_value['.$days.']["'.$tm.'"] = [];';
							foreach( (array)$prefs[$tm] as $pref ) {
Example #29
0
 public function download_order_list()
 {
     $order_list = new WC2_Order_List_Table();
     //1ページあたりのテーブルの行数
     $per_page = $order_list->get_items_per_page(self::$per_page_slug);
     //ソート
     $args = $order_list->sort_culum_order_by($per_page);
     //データ
     $list_data = $order_list->get_list_data($args);
     $wc2_order = WC2_DB_Order::get_instance();
     $system_options = wc2_get_option('system');
     $applyform = wc2_get_apply_addressform($system_options['addressform']);
     $management_status = wc2_get_option('management_status');
     $receipt_status = wc2_get_option('receipt_status');
     $order_type = wc2_get_option('order_type');
     $locale_options = wc2_get_option('locale_options');
     $list = '';
     $opt_order = wc2_get_option('opt_order');
     $chk_order = !empty($opt_order['chk_order']) ? $opt_order['chk_order'] : array();
     //--------------------- checkbox Check ---------------------//
     //-------- Customer -------//
     $chk_order['ID'] = 1;
     $chk_order['deco_id'] = 1;
     $chk_order['order_date'] = 1;
     $chk_order['member_id'] = isset($_REQUEST['check']['member_id']) ? 1 : 0;
     $cscs_head = wc2_get_custom_field_keys(WC2_CSCS, 'head');
     if (!empty($cscs_head)) {
         foreach ($cscs_head as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $chk_order['email'] = isset($_REQUEST['check']['email']) ? 1 : 0;
     $cscs_beforename = wc2_get_custom_field_keys(WC2_CSCS, 'beforename');
     if (!empty($cscs_beforename)) {
         foreach ($cscs_beforename as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $chk_order['name'] = 1;
     $chk_order['kana'] = isset($_REQUEST['check']['kana']) ? 1 : 0;
     $cscs_aftername = wc2_get_custom_field_keys(WC2_CSCS, 'aftername');
     if (!empty($cscs_aftername)) {
         foreach ($cscs_aftername as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $chk_order['country'] = isset($_REQUEST['check']['country']) ? 1 : 0;
     $chk_order['zipcode'] = isset($_REQUEST['check']['zipcode']) ? 1 : 0;
     $chk_order['pref'] = 1;
     $chk_order['address1'] = 1;
     $chk_order['address2'] = 1;
     $chk_order['tel'] = isset($_REQUEST['check']['tel']) ? 1 : 0;
     $chk_order['fax'] = isset($_REQUEST['check']['fax']) ? 1 : 0;
     $cscs_bottom = wc2_get_custom_field_keys(WC2_CSCS, 'bottom');
     if (!empty($cscs_bottom)) {
         foreach ($cscs_bottom as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $cscs_other = wc2_get_custom_field_keys(WC2_CSCS, 'other');
     if (!empty($cscs_other)) {
         foreach ($cscs_other as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     //-------- Delivery -------//
     $csde_head = wc2_get_custom_field_keys(WC2_CSDE, 'head');
     if (!empty($csde_head)) {
         foreach ($csde_head as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $csde_beforename = wc2_get_custom_field_keys(WC2_CSDE, 'beforename');
     if (!empty($csde_beforename)) {
         foreach ($csde_beforename as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $chk_order['delivery_name'] = 1;
     $chk_order['delivery_kana'] = isset($_REQUEST['check']['delivery_kana']) ? 1 : 0;
     $csde_aftername = wc2_get_custom_field_keys(WC2_CSDE, 'aftername');
     if (!empty($csde_aftername)) {
         foreach ($csde_aftername as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $chk_order['delivery_country'] = isset($_REQUEST['check']['delivery_country']) ? 1 : 0;
     $chk_order['delivery_zipcode'] = isset($_REQUEST['check']['delivery_zipcode']) ? 1 : 0;
     $chk_order['delivery_pref'] = 1;
     $chk_order['delivery_address1'] = 1;
     $chk_order['delivery_address2'] = 1;
     $chk_order['delivery_tel'] = isset($_REQUEST['check']['delivery_tel']) ? 1 : 0;
     $chk_order['delivery_fax'] = isset($_REQUEST['check']['delivery_fax']) ? 1 : 0;
     $csde_bottom = wc2_get_custom_field_keys(WC2_CSDE, 'bottom');
     if (!empty($csde_bottom)) {
         foreach ($csde_bottom as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $csde_other = wc2_get_custom_field_keys(WC2_CSDE, 'other');
     if (!empty($csde_other)) {
         foreach ($csde_other as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     //--------- Order --------//
     $chk_order['shipping_date'] = isset($_REQUEST['check']['shipping_date']) ? 1 : 0;
     $chk_order['payment_method'] = isset($_REQUEST['check']['payment_method']) ? 1 : 0;
     $chk_order['delivery_method'] = isset($_REQUEST['check']['delivery_method']) ? 1 : 0;
     $chk_order['delivery_date'] = isset($_REQUEST['check']['delivery_date']) ? 1 : 0;
     $chk_order['delivery_time'] = isset($_REQUEST['check']['delivery_time']) ? 1 : 0;
     $chk_order['delidue_date'] = isset($_REQUEST['check']['delidue_date']) ? 1 : 0;
     $chk_order['order_status'] = isset($_REQUEST['check']['order_status']) ? 1 : 0;
     $chk_order['receipt_status'] = isset($_REQUEST['check']['receipt_status']) ? 1 : 0;
     $chk_order['receipted_date'] = isset($_REQUEST['check']['receipted_date']) ? 1 : 0;
     $chk_order['order_type'] = isset($_REQUEST['check']['order_type']) ? 1 : 0;
     $chk_order['total_amount'] = isset($_REQUEST['check']['total_amount']) ? 1 : 0;
     $chk_order['getpoint'] = isset($_REQUEST['check']['getpoint']) ? 1 : 0;
     $chk_order['usedpoint'] = isset($_REQUEST['check']['usedpoint']) ? 1 : 0;
     $chk_order['discount'] = isset($_REQUEST['check']['discount']) ? 1 : 0;
     $chk_order['shipping_charge'] = isset($_REQUEST['check']['shipping_charge']) ? 1 : 0;
     $chk_order['cod_fee'] = isset($_REQUEST['check']['cod_fee']) ? 1 : 0;
     $chk_order['tax'] = isset($_REQUEST['check']['tax']) ? 1 : 0;
     $csod_beforeremarks = wc2_get_custom_field_keys(WC2_CSOD, 'beforeremarks');
     if (!empty($csod_beforeremarks)) {
         foreach ($csod_beforeremarks as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $chk_order['note'] = isset($_REQUEST['check']['note']) ? 1 : 0;
     $csod_other = wc2_get_custom_field_keys(WC2_CSOD, 'other');
     if (!empty($csod_other)) {
         foreach ($csod_other as $val) {
             $chk_order[$val] = isset($_REQUEST['check'][$val]) ? 1 : 0;
         }
     }
     $opt_order['chk_order'] = apply_filters('wc2_filter_admin_order_list_chk_order', $chk_order);
     wc2_update_option('opt_order', $opt_order);
     //---------------------------- TITLE -----------------------------//
     $title = '';
     //-------- Customer --------//
     $title .= '"' . __('ID', 'wc2') . '"';
     if (1 == $chk_order['deco_id']) {
         $title .= ',"' . __('Order number', 'wc2') . '"';
     }
     if (1 == $chk_order['order_date']) {
         $title .= ',"' . __('Order date', 'wc2') . '"';
     }
     if (1 == $chk_order['member_id']) {
         $title .= ',"' . __('Membership ID', 'wc2') . '"';
     }
     //cscs_head
     if (!empty($cscs_head)) {
         foreach ($cscs_head as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     if (1 == $chk_order['email']) {
         $title .= ',"' . __('E-mail', 'wc2') . '"';
     }
     //cscs_beforename
     if (!empty($cscs_beforename)) {
         foreach ($cscs_beforename as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     if (1 == $chk_order['name']) {
         $title .= ',"' . __('Name', 'wc2') . '"';
     }
     if (1 == $chk_order['kana']) {
         $title .= ',"' . __('Kana', 'wc2') . '"';
     }
     //cscs_aftername
     if (!empty($cscs_aftername)) {
         foreach ($cscs_aftername as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     if ('JP' == $applyform) {
         if (1 == $chk_order['country']) {
             $title .= ',"' . __('Country', 'wc2') . '"';
         }
         if (1 == $chk_order['zipcode']) {
             $title .= ',"' . __('Postal Code', 'wc2') . '"';
         }
         if (1 == $chk_order['pref']) {
             $title .= ',"' . __('Prefecture', 'wc2') . '"';
         }
         if (1 == $chk_order['address1']) {
             $title .= ',"' . __('City', 'wc2') . '"';
         }
         if (1 == $chk_order['address2']) {
             $title .= ',"' . __('Building name, floor, room number', 'wc2') . '"';
         }
         if (1 == $chk_order['tel']) {
             $title .= ',"' . __('Phone number', 'wc2') . '"';
         }
         if (1 == $chk_order['fax']) {
             $title .= ',"' . __('FAX number', 'wc2') . '"';
         }
     } else {
         if (1 == $chk_order['address2']) {
             $title .= ',"' . __('Building name, floor, room number', 'wc2') . '"';
         }
         if (1 == $chk_order['address1']) {
             $title .= ',"' . __('City', 'wc2') . '"';
         }
         if (1 == $chk_order['pref']) {
             $title .= ',"' . __('Prefecture', 'wc2') . '"';
         }
         if (1 == $chk_order['zipcode']) {
             $title .= ',"' . __('Postal Code', 'wc2') . '"';
         }
         if (1 == $chk_order['country']) {
             $title .= ',"' . __('Country', 'wc2') . '"';
         }
         if (1 == $chk_order['tel']) {
             $title .= ',"' . __('Phone number', 'wc2') . '"';
         }
         if (1 == $chk_order['fax']) {
             $title .= ',"' . __('FAX number', 'wc2') . '"';
         }
     }
     //cscs_bottom
     if (!empty($cscs_bottom)) {
         foreach ($cscs_bottom as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     //cscs_other
     if (!empty($cscs_other)) {
         foreach ($cscs_other as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     //-------- Delivery -------//
     //csde_head
     if (!empty($csde_head)) {
         foreach ($csde_head as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     //csde_beforename
     if (!empty($csde_beforename)) {
         foreach ($csde_beforename as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     if (1 == $chk_order['delivery_name']) {
         $title .= ',"' . __('Name', 'wc2') . '"';
     }
     if (1 == $chk_order['delivery_kana']) {
         $title .= ',"' . __('Kana', 'wc2') . '"';
     }
     //csde_aftername
     if (!empty($csde_aftername)) {
         foreach ($csde_aftername as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     if ('JP' == $applyform) {
         if (1 == $chk_order['delivery_country']) {
             $title .= ',"' . __('Shipping country', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_zipcode']) {
             $title .= ',"' . __('Shipping postal code', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_pref']) {
             $title .= ',"' . __('Shipping prefecture', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_address1']) {
             $title .= ',"' . __('Shipping city', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_address2']) {
             $title .= ',"' . __('Shipping building name, floor, room number', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_tel']) {
             $title .= ',"' . __('Shipping phone number', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_fax']) {
             $title .= ',"' . __('Shipping FAX number', 'wc2') . '"';
         }
     } else {
         if (1 == $chk_order['delivery_address2']) {
             $title .= ',"' . __('Shipping building name, floor, room number', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_address1']) {
             $title .= ',"' . __('Shipping city', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_pref']) {
             $title .= ',"' . __('Shipping prefecture', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_zipcode']) {
             $title .= ',"' . __('Shipping postal code', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_country']) {
             $title .= ',"' . __('Shipping country', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_tel']) {
             $title .= ',"' . __('Shipping phone number', 'wc2') . '"';
         }
         if (1 == $chk_order['delivery_fax']) {
             $title .= ',"' . __('Shipping FAX number', 'wc2') . '"';
         }
     }
     //csde_bottom
     if (!empty($csde_bottom)) {
         foreach ($csde_bottom as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     //csde_other
     if (!empty($csde_other)) {
         foreach ($csde_other as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     //--------- Order ---------//
     if (1 == $chk_order['shipping_date']) {
         $title .= ',"' . __('Shipping date', 'wc2') . '"';
     }
     if (1 == $chk_order['payment_method']) {
         $title .= ',"' . __('Payment method', 'wc2') . '"';
     }
     if (1 == $chk_order['delivery_method']) {
         $title .= ',"' . __('Delivery method', 'wc2') . '"';
     }
     if (1 == $chk_order['delivery_date']) {
         $title .= ',"' . __('Delivery date', 'wc2') . '"';
     }
     if (1 == $chk_order['delivery_time']) {
         $title .= ',"' . __('Delivery time', 'wc2') . '"';
     }
     if (1 == $chk_order['delidue_date']) {
         $title .= ',"' . __('Shipping schedule date', 'wc2') . '"';
     }
     if (1 == $chk_order['order_status']) {
         $title .= ',"' . __('Order status', 'wc2') . '"';
     }
     if (1 == $chk_order['receipt_status']) {
         $title .= ',"' . __('Receipt status', 'wc2') . '"';
     }
     if (1 == $chk_order['receipted_date']) {
         $title .= ',"' . __('Receipted date', 'wc2') . '"';
     }
     if (1 == $chk_order['order_type']) {
         $title .= ',"' . __('Order type', 'wc2') . '"';
     }
     if (1 == $chk_order['total_amount']) {
         $title .= ',"' . __('Total Amount', 'wc2') . '"';
     }
     if (1 == $chk_order['getpoint']) {
         $title .= ',"' . __('Granted points', 'wc2') . '"';
     }
     if (1 == $chk_order['usedpoint']) {
         $title .= ',"' . __('Used points', 'wc2') . '"';
     }
     if (1 == $chk_order['discount']) {
         $title .= ',"' . __('Discount', 'wc2') . '"';
     }
     if (1 == $chk_order['shipping_charge']) {
         $title .= ',"' . __('Shipping charges', 'wc2') . '"';
     }
     if (1 == $chk_order['cod_fee']) {
         $title .= ',"' . __('COD fee', 'wc2') . '"';
     }
     if (1 == $chk_order['tax']) {
         $title .= ',"' . __('Consumption tax', 'wc2') . '"';
     }
     //csod_beforeremarks
     if (!empty($csod_beforeremarks)) {
         foreach ($csod_beforeremarks as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     if (1 == $chk_order['note']) {
         $title .= ',"' . __('Notes', 'wc2') . '"';
     }
     //csod_other
     if (!empty($csod_other)) {
         foreach ($csod_other as $val) {
             if (1 == $chk_order[$val]) {
                 $name = wc2_get_custom_field_value($val, 'name');
                 $title .= ',"' . wc2_entity_decode($name) . '"';
             }
         }
     }
     $list .= apply_filters('wc2_filter_admin_order_list_dl_order_title', $title, $chk_order);
     $list .= "\n";
     //----------------------------- DATA ----------------------------//
     foreach ((array) $list_data as $row) {
         $order_id = $row['ID'];
         $data = $wc2_order->get_order_data($order_id);
         $delivery_data = $data['delivery'][0];
         //-------- Customer -------//
         $line = '"' . $order_id . '"';
         if (1 == $chk_order['deco_id']) {
             $line .= ',"' . $data['dec_order_id'] . '"';
         }
         if (1 == $chk_order['order_date']) {
             $line .= ',"' . $data['order_date'] . '"';
         }
         if (1 == $chk_order['member_id']) {
             $line .= ',"' . $data['member_id'] . '"';
         }
         //cscs_head
         if (!empty($cscs_head)) {
             foreach ($cscs_head as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         if (1 == $chk_order['email']) {
             $line .= ',"' . wc2_entity_decode($data['email']) . '"';
         }
         //cscs_beforename
         if (!empty($cscs_beforename)) {
             foreach ($cscs_beforename as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         if (1 == $chk_order['name']) {
             $line .= ',"' . wc2_entity_decode($data['name1'] . ' ' . $data['name2']) . '"';
         }
         if (1 == $chk_order['kana']) {
             $line .= ',"' . wc2_entity_decode($data['name3'] . ' ' . $data['name4']) . '"';
         }
         //cscs_aftername
         if (!empty($cscs_aftername)) {
             foreach ($cscs_aftername as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         if ('JP' == $applyform) {
             if (1 == $chk_order['country']) {
                 $line .= ',"' . $locale_options['country'][$data['country']] . '"';
             }
             if (1 == $chk_order['zipcode']) {
                 $line .= ',"' . $data['zipcode'] . '"';
             }
             if (1 == $chk_order['pref']) {
                 $line .= ',"' . wc2_entity_decode($data['pref']) . '"';
             }
             if (1 == $chk_order['address1']) {
                 $line .= ',"' . wc2_entity_decode($data['address1']) . '"';
             }
             if (1 == $chk_order['address2']) {
                 $line .= ',"' . wc2_entity_decode($data['address2']) . '"';
             }
             if (1 == $chk_order['tel']) {
                 $line .= ',"' . $data['tel'] . '"';
             }
             if (1 == $chk_order['fax']) {
                 $line .= ',"' . $data['fax'] . '"';
             }
         } else {
             if (1 == $chk_order['address2']) {
                 $line .= ',"' . wc2_entity_decode($data['address2']) . '"';
             }
             if (1 == $chk_order['address1']) {
                 $line .= ',"' . wc2_entity_decode($data['address1']) . '"';
             }
             if (1 == $chk_order['pref']) {
                 $line .= ',"' . wc2_entity_decode($data['pref']) . '"';
             }
             if (1 == $chk_order['zipcode']) {
                 $line .= ',"' . $data['zipcode'] . '"';
             }
             if (1 == $chk_order['country']) {
                 $line .= ',"' . $locale_options['country'][$data['country']] . '"';
             }
             if (1 == $chk_order['tel']) {
                 $line .= ',"' . $data['tel'] . '"';
             }
             if (1 == $chk_order['fax']) {
                 $line .= ',"' . $data['fax'] . '"';
             }
         }
         //cscs_bottom
         if (!empty($cscs_bottom)) {
             foreach ($cscs_bottom as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         //cscs_other
         if (!empty($cscs_other)) {
             foreach ($cscs_other as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         //-------- Delivery -------//
         //csde_head
         if (!empty($csde_head)) {
             foreach ($csde_head as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         //csde_beforename
         if (!empty($csde_beforename)) {
             foreach ($csde_beforename as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         if (1 == $chk_order['delivery_name']) {
             $line .= ',"' . wc2_entity_decode($delivery_data['name1'] . ' ' . $delivery_data['name2']) . '"';
         }
         if (1 == $chk_order['delivery_kana']) {
             $line .= ',"' . wc2_entity_decode($delivery_data['name3'] . ' ' . $delivery_data['name4']) . '"';
         }
         //csde_aftername
         if (!empty($csde_aftername)) {
             foreach ($csde_aftername as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         if ('JP' == $applyform) {
             if (1 == $chk_order['delivery_country']) {
                 $line .= ',"' . $locale_options['country'][$delivery_data['country']] . '"';
             }
             if (1 == $chk_order['delivery_zipcode']) {
                 $line .= ',"' . $delivery_data['zipcode'] . '"';
             }
             if (1 == $chk_order['delivery_pref']) {
                 $line .= ',"' . $delivery_data['pref'] . '"';
             }
             if (1 == $chk_order['delivery_address1']) {
                 $line .= ',"' . $delivery_data['address1'] . '"';
             }
             if (1 == $chk_order['delivery_address2']) {
                 $line .= ',"' . $delivery_data['address2'] . '"';
             }
             if (1 == $chk_order['delivery_tel']) {
                 $line .= ',"' . $delivery_data['tel'] . '"';
             }
             if (1 == $chk_order['delivery_fax']) {
                 $line .= ',"' . $delivery_data['fax'] . '"';
             }
         } else {
             if (1 == $chk_order['delivery_address2']) {
                 $line .= ',"' . $delivery_data['address2'] . '"';
             }
             if (1 == $chk_order['delivery_address1']) {
                 $line .= ',"' . $delivery_data['address1'] . '"';
             }
             if (1 == $chk_order['delivery_pref']) {
                 $line .= ',"' . $delivery_data['pref'] . '"';
             }
             if (1 == $chk_order['delivery_zipcode']) {
                 $line .= ',"' . $delivery_data['zipcode'] . '"';
             }
             if (1 == $chk_order['delivery_country']) {
                 $line .= ',"' . $locale_options['country'][$delivery_data['country']] . '"';
             }
             if (1 == $chk_order['delivery_tel']) {
                 $line .= ',"' . $delivery_data['tel'] . '"';
             }
             if (1 == $chk_order['delivery_fax']) {
                 $line .= ',"' . $delivery_data['fax'] . '"';
             }
         }
         //csde_bottom
         if (!empty($csde_bottom)) {
             foreach ($csde_bottom as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         //csde_other
         if (!empty($csde_other)) {
             foreach ($csde_other as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_CUSTOMER][$cskey]) ? $data[WC2_CUSTOM_CUSTOMER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         //--------- Order ---------//
         if (1 == $chk_order['shipping_date']) {
             $line .= ',"' . $data['order_modified'] . '"';
         }
         if (1 == $chk_order['payment_method']) {
             $line .= ',"' . wc2_entity_decode($data['payment_name']) . '"';
         }
         if (1 == $chk_order['delivery_method']) {
             $line .= ',"' . wc2_entity_decode($data['delivery_name']) . '"';
         }
         if (1 == $chk_order['delivery_date']) {
             $line .= ',"' . $data['delivery_date'] . '"';
         }
         if (1 == $chk_order['delivery_time']) {
             $line .= ',"' . $data['delivery_time'] . '"';
         }
         if (1 == $chk_order['delidue_date']) {
             $line .= ',"' . $data['delidue_date'] . '"';
         }
         if (1 == $chk_order['order_status']) {
             $management_status_name = array_key_exists($data['order_status'], $management_status) ? $management_status[$data['order_status']] : '';
             $line .= ',"' . wc2_entity_decode($management_status_name) . '"';
         }
         if (1 == $chk_order['receipt_status']) {
             $receipt_status_name = array_key_exists($data['receipt_status'], $receipt_status) ? $receipt_status[$data['receipt_status']] : '';
             $line .= ',"' . wc2_entity_decode($receipt_status_name) . '"';
         }
         if (1 == $chk_order['receipted_date']) {
             $line .= ',"' . $data['receipted_date'] . '"';
         }
         if (1 == $chk_order['order_type']) {
             $order_type_name = array_key_exists($data['order_type'], $order_type) ? $order_type[$data['order_type']] : '';
             $line .= ',"' . wc2_entity_decode($order_type_name) . '"';
         }
         if (1 == $chk_order['total_amount']) {
             $total_price = $data['item_total_price'] - $data['usedpoint'] + $data['discount'] + $data['shipping_charge'] + $data['cod_fee'] + $data['tax'];
             $line .= ',"' . $total_price . '"';
         }
         if (1 == $chk_order['getpoint']) {
             $line .= ',"' . $data['getpoint'] . '"';
         }
         if (1 == $chk_order['usedpoint']) {
             $line .= ',"' . $data['usedpoint'] . '"';
         }
         if (1 == $chk_order['discount']) {
             $line .= ',"' . $data['discount'] . '"';
         }
         if (1 == $chk_order['shipping_charge']) {
             $line .= ',"' . $data['shipping_charge'] . '"';
         }
         if (1 == $chk_order['cod_fee']) {
             $line .= ',"' . $data['cod_fee'] . '"';
         }
         if (1 == $chk_order['tax']) {
             $line .= ',"' . $data['tax'] . '"';
         }
         //csod_beforeremarks
         if (!empty($csod_beforeremarks)) {
             foreach ($csod_beforeremarks as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_ORDER][$cskey]) ? $data[WC2_CUSTOM_ORDER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         if (1 == $chk_order['note']) {
             $line .= ',"' . wc2_entity_decode($data['note']) . '"';
         }
         //csod_other
         if (!empty($csod_other)) {
             foreach ($csod_other as $val) {
                 if (1 == $chk_order[$val]) {
                     list($pfx, $cskey) = explode('_', $val, 2);
                     $value = isset($data[WC2_CUSTOM_ORDER][$cskey]) ? $data[WC2_CUSTOM_ORDER][$cskey] : '';
                     $line .= ',"' . wc2_entity_decode($value) . '"';
                 }
             }
         }
         $list .= apply_filters('wc2_filter_admin_order_list_dl_order', $line, $chk_order, $data);
         $list .= "\n";
     }
     header("Content-Type: application/octet-stream");
     header("Content-Disposition: attachment; filename=wc2_order_list.csv");
     mb_http_output("pass");
     print mb_convert_encoding($list, "SJIS-win", "UTF-8");
     exit;
 }