Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
function wc2_download_item_list()
{
    global $wpdb, $wp_query;
    if (isset($wp_query->request)) {
        list($item_query, $limit) = explode('LIMIT', $wp_query->request);
        $rows = $wpdb->get_results($item_query, ARRAY_A);
    } else {
        return;
    }
    $ext = $_REQUEST['ftype'];
    if ($ext == 'csv') {
        //CSV
        $sp = ";";
        $eq = "=";
        $lf = "\n";
    } else {
        exit;
    }
    $wc2_opt_item = wc2_get_option('wc2_opt_item');
    if (!is_array($wc2_opt_item)) {
        $wc2_opt_item = array();
    }
    $wc2_opt_item['chk_header'] = isset($_GET['chk_header']) ? 1 : 0;
    $wc2_opt_item['ftype_item'] = $ext;
    update_option('wc2_opt_item', $wc2_opt_item);
    $wc2_item = WC2_DB_Item::get_instance();
    $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();
    $item_label = $wc2_item->get_item_label();
    $item_label[ITEM_PURCHASE_LIMIT_LOWEST] = __('購入制限数(最低)', 'wc2');
    $item_label[ITEM_PURCHASE_LIMIT_HIGHEST] = __('購入制限数(最大)', 'wc2');
    $item_label[ITEM_QUANTITY_DISCOUNT_NUM1] = __('大口割引1(数)', 'wc2');
    $item_label[ITEM_QUANTITY_DISCOUNT_RATE1] = __('大口割引1(割引率)', 'wc2');
    $item_label[ITEM_QUANTITY_DISCOUNT_NUM2] = __('大口割引2(数)', 'wc2');
    $item_label[ITEM_QUANTITY_DISCOUNT_RATE2] = __('大口割引2(割引率)', 'wc2');
    $item_label[ITEM_QUANTITY_DISCOUNT_NUM3] = __('大口割引3(数)', 'wc2');
    $item_label[ITEM_QUANTITY_DISCOUNT_RATE3] = __('大口割引3(割引率)', 'wc2');
    $wc2_item->set_item_label($item_label);
    //---------------------- TITLE -----------------------//
    $line = '';
    if (1 == $wc2_opt_item['chk_header']) {
        $line .= '"' . __('Post ID', 'wc2') . '"';
        $line .= ',"' . __('Post Author', 'wc2') . '"';
        $line .= ',"' . __('explanation', 'wc2') . '"';
        $line .= ',"' . __('Title', 'wc2') . '"';
        $line .= ',"' . __('excerpt', 'wc2') . '"';
        $line .= ',"' . __('display status', 'wc2') . '"';
        $line .= ',"' . __('Comment Status', 'wc2') . '"';
        $line .= ',"' . __('Post Password', 'wc2') . '"';
        $line .= ',"' . __('Post Name', 'wc2') . '"';
        $line .= ',"' . __('公開日', 'wc2') . '"';
        $line .= ',"' . __('カテゴリー', 'wc2') . '"';
        $line .= ',"' . __('タグ', 'wc2') . '"';
        $line .= ',"' . __('Custom Field', 'wc2') . '"';
        //		$line .= ',"'. __('商品コード', 'wc2') .'"';
        //		$line .= ',"'. __('商品名', 'wc2') .'"';
        foreach ($item_base_column as $key => $column) {
            if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                $line .= ',"' . $wc2_item->get_the_item_label($key) . '"';
            }
        }
        foreach ((array) $item_meta_column as $key => $column) {
            if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                $line .= ',"' . $wc2_item->get_the_item_label($key) . '"';
            }
        }
        foreach ($item_sku_column as $key => $column) {
            if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                $line .= ',"' . $wc2_item->get_the_item_label($key) . '"';
            }
        }
        foreach ($item_sku_meta_column as $key => $column) {
            if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                $line .= ',"' . $wc2_item->get_the_item_label($key) . '"';
            }
        }
        //商品オプション
        $line .= $lf;
    }
    set_time_limit(3600);
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=wc2_item_list.csv");
    mb_http_output('pass');
    @ob_end_flush();
    flush();
    $array_value_types = array(TYPE_CHECK, TYPE_SELECT_MULTIPLE);
    //セミコロン区切りで出力する
    foreach ((array) $rows as $row) {
        $post_id = $row['ID'];
        $post = get_post($post_id);
        $wc2_item->set_the_post_id($post_id);
        $item_data = $wc2_item->get_item_data();
        //Post Data
        $line_item = '';
        $line_item = '"' . $post->ID . '"';
        $line_item .= ',"' . $post->post_author . '"';
        $line_item .= ',"' . wc2_entity_decode($post->post_content) . '"';
        $line_item .= ',"' . wc2_entity_decode($post->post_title) . '"';
        $line_item .= ',"' . wc2_entity_decode($post->post_excerpt) . '"';
        $line_item .= ',"' . $post->post_status . '"';
        $line_item .= ',"' . $post->comment_status . '"';
        $line_item .= ',"' . $post->post_password . '"';
        $line_item .= ',"' . urldecode($post->post_name) . '"';
        $line_item .= ',"' . $post->post_date . '"';
        //Categories
        $category = '';
        //$cat_ids = get_the_category( $post_id );
        $categories = wp_get_post_terms($post_id, 'item');
        if (!empty($categories)) {
            foreach ($categories as $val) {
                $category .= $val->term_id . $sp;
            }
            $category = rtrim($category, $sp);
        }
        $line_item .= ',"' . $category . '"';
        //Tags
        $tag = '';
        $tags = wp_get_post_terms($post_id, 'item-tag');
        foreach ($tags as $val) {
            $tag .= $val->name . $sp;
        }
        $tag = rtrim($tag, $sp);
        $line_item .= ',"' . $tag . '"';
        //Custom Fields
        $cfield = '';
        $custom_fields = get_post_custom($post_id);
        if (is_array($custom_fields) && 0 < count($custom_fields)) {
            foreach ($custom_fields as $cfkey => $cfvalues) {
                if (is_array($cfvalues)) {
                    $cfield .= wc2_entity_decode($cfkey) . $eq . wc2_entity_decode($cfvalues[0]) . $sp;
                } else {
                    $cfield .= wc2_entity_decode($cfkey) . $eq . wc2_entity_decode($cfvalues) . $sp;
                }
            }
            $cfield = rtrim($cfield, $sp);
        }
        $line_item .= ',"' . $cfield . '"';
        //Item Data
        foreach ($item_base_column as $key => $column) {
            if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                //checkbox, multiselectはセミコロン区切りで出力
                if (in_array($column['type'], $array_value_types)) {
                    $value = '';
                    $value = maybe_unserialize($wc2_item->get_the_item_value($key));
                    if (!empty($value)) {
                        $concat = '';
                        foreach (array($value) as $key => $val) {
                            $concat = $val . $sp;
                        }
                        $concat = rtrim($concat, $sp);
                        $line_item .= ',"' . $concat . '"';
                    } else {
                        $line_item .= ',""';
                    }
                } else {
                    $line_item .= ',"' . $wc2_item->get_the_item_value($key) . '"';
                }
            }
        }
        foreach ($item_meta_column as $key => $column) {
            if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                //checkbox, multiselectはセミコロン区切りで出力
                if (in_array($column['type'], $array_value_types)) {
                    $value = '';
                    $value = maybe_unserialize($wc2_item->get_the_item_value($key));
                    if (!empty($value)) {
                        $concat = '';
                        foreach (array($value) as $key => $val) {
                            $concat = $val . $sp;
                        }
                        $concat = rtrim($concat, $sp);
                        $line_item .= ',"' . $concat . '"';
                    } else {
                        $line_item .= ',""';
                    }
                } else {
                    $line_item .= ',"' . $wc2_item->get_the_item_value($key) . '"';
                }
            }
        }
        //Item Options
        $line_options = '';
        /*
        		$option_meta = usces_get_opts( $post_id, 'sort' );
        		foreach($option_meta as $option_value) {
        			$value = '';
        			if(is_array($option_value['value'])) {
        				foreach($option_value['value'] as $k => $v) {
        					$v = usces_change_line_break( $v );
        					$values = explode("\n", $v);
        					foreach($values as $val) {
        						$value .= $val.$sp;
        					}
        				}
        				$value = rtrim($value, $sp);
        			} else {
        				$value = trim($option_value['value']);
        				$value = str_replace("\n", ';', $value);
        			}
        
        			$line_options .= $td_h.usces_entity_decode($option_value['name'], $ext).$td_f;
        			$line_options .= $td_h.$option_value['means'].$td_f;
        			$line_options .= $td_h.$option_value['essential'].$td_f;
        			$line_options .= $td_h.usces_entity_decode($value, $ext).$td_f;
        
        		}
        */
        //SKU data
        foreach ($item_data['item_sku'] as $skuindex => $skuval) {
            $line_sku = '';
            foreach ($item_sku_column as $key => $column) {
                if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                    //checkbox, multiselectはセミコロン区切りで出力
                    if (in_array($column['type'], $array_value_types)) {
                        $value = '';
                        $value = maybe_unserialize($wc2_item->get_the_item_sku_value($key, $skuindex));
                        if (!empty($value)) {
                            $concat = '';
                            foreach (array($value) as $key => $val) {
                                $concat = $val . $sp;
                            }
                            $concat = rtrim($concat, $sp);
                            $line_sku .= ',"' . $concat . '"';
                        } else {
                            $line_sku .= ',""';
                        }
                    } else {
                        $line_sku .= ',"' . $wc2_item->get_the_item_sku_value($key, $skuindex) . '"';
                    }
                }
            }
            foreach ($item_sku_meta_column as $key => $column) {
                if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
                    //checkbox, multiselectはセミコロン区切りで出力
                    if (in_array($column['type'], $array_value_types)) {
                        $value = '';
                        $value = maybe_unserialize($wc2_item->get_the_item_sku_value($key, $skuindex));
                        if (!empty($value)) {
                            $concat = '';
                            foreach (array($value) as $key => $val) {
                                $concat = $val . $sp;
                            }
                            $concat = rtrim($concat, $sp);
                            $line_sku .= ',"' . $concat . '"';
                        } else {
                            $line_sku .= ',""';
                        }
                    } else {
                        $line_sku .= ',"' . $wc2_item->get_the_item_sku_value($key, $skuindex) . '"';
                    }
                }
            }
            $line .= $line_item . $line_sku . $line_options . "\n";
        }
        print mb_convert_encoding($line, "SJIS-win", "UTF-8");
        if (ob_get_contents()) {
            ob_flush();
            flush();
        }
        $line = '';
        wp_cache_flush();
    }
    exit;
}
Ejemplo n.º 3
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;
 }