Beispiel #1
0
    static function get_addressform($data, $type)
    {
        if (empty($data)) {
            return;
        }
        $system_options = wc2_get_option('system');
        $applyform = wc2_get_apply_addressform($system_options['addressform']);
        if (is_admin()) {
            switch ($type) {
                case 'member':
                case 'customer':
                    $values = $data;
                    break;
                case 'delivery':
                    $values = $data['delivery'][0];
                    break;
            }
            $essential_mark_off = $type == 'member' ? false : true;
        } else {
            switch ($type) {
                case 'member':
                    $values = $data;
                    break;
                case 'customer':
                    $values = $data['customer'];
                    break;
                case 'delivery':
                    $values = $data['delivery'];
                    break;
            }
            $essential_mark_off = false;
        }
        $values['country'] = !empty($values['country']) ? $values['country'] : wc2_get_local_addressform();
        $values = wc2_stripslashes_deep_post($values);
        $essential_mark = wc2_get_option('essential_mark');
        if ($essential_mark_off) {
            foreach ($essential_mark as $key => $value) {
                $essential_mark[$key] = '';
            }
        }
        $formtag = '';
        switch ($applyform) {
            case 'JP':
                $formtag .= self::get_custom_field_input($values, $type, 'head');
                if (is_admin() && ($type == 'member' || $type == 'customer')) {
                    $get_member = $type == 'customer' ? '<input type="button" id="get-member" class="button" value="' . __('会員情報取込', 'wc2') . '" />' : '';
                    $formtag .= '
				<tr class="' . $type . '-mail">
					<th>' . $essential_mark['email'] . 'e-mail</th>
					<td><input name="' . $type . '[email]" type="text" class="text long" value="' . esc_attr($values['email']) . '" />' . $get_member . apply_filters('wc2_filter_after_email', NULL, $values, $type) . '</td>
				</tr>';
                }
                $formtag .= self::get_custom_field_input($values, $type, 'beforename');
                $formtag .= '
			<tr class="' . $type . '-name">
				<th>' . $essential_mark['name1'] . __('Name', 'wc2') . '</th>
				<td>
					<input name="' . $type . '[name1]" type="text" class="text short" value="' . esc_attr($values['name1']) . '" placeholder="' . __('Last name', 'wc2') . '" />
					<input name="' . $type . '[name2]" type="text" class="text short" value="' . esc_attr($values['name2']) . '" placeholder="' . __('First name', 'wc2') . '" />' . apply_filters('wc2_filter_after_name2', NULL, $values, $type) . '
				</td>
			</tr>
			<tr class="' . $type . '-phonetic">
				<th>' . $essential_mark['name3'] . __('Kana', 'wc2') . '</th>
				<td>
					<input name="' . $type . '[name3]" type="text" class="text short" value="' . esc_attr($values['name3']) . '" placeholder="' . __('セイ', 'wc2') . '" />
					<input name="' . $type . '[name4]" type="text" class="text short" value="' . esc_attr($values['name4']) . '" placeholder="' . __('メイ', 'wc2') . '" />' . apply_filters('wc2_filter_after_name4', NULL, $values, $type) . '
				</td>
			</tr>';
                $formtag .= self::get_custom_field_input($values, $type, 'aftername');
                if (count($system_options['target_market']) == 1) {
                    $formtag .= '<input name="' . $type . '[country]" type="hidden" value="' . $system_options['target_market'][0] . '" />';
                } else {
                    $formtag .= '
					<tr class="' . $type . '-country">
						<th>' . $essential_mark['country'] . __('国', 'wc2') . '</th>
						<td>' . wc2_get_target_market_form($type, $values['country']) . apply_filters('wc2_filter_after_country', NULL, $values, $type) . '</td>
					</tr>';
                }
                $formtag .= '
			<tr class="' . $type . '-zipcode">
				<th>' . $essential_mark['zipcode'] . __('郵便番号', 'wc2') . '</th>
				<td>
					<input name="' . $type . '[zipcode]" type="text" class="text short" value="' . esc_attr($values['zipcode']) . '" />
					<input id="search-zipcode-' . $type . '" type="button" class="search-zipcode button" value="住所検索" />' . apply_filters('wc2_filter_after_zipcode', NULL, $values, $type) . '
				</td>
			</tr>
			<tr class="' . $type . '-pref">
				<th>' . $essential_mark['pref'] . __('都道府県', 'wc2') . '</th>
				<td>' . wc2_get_pref_select($type, $values) . apply_filters('wc2_filter_after_pref', NULL, $values, $type) . '</td>
			</tr>
			<tr class="' . $type . '-address1">
				<th>' . $essential_mark['address1'] . __('City/Ward/Town/Village/Street name, street number', 'wc2') . '</th>
				<td><input name="' . $type . '[address1]" type="text" class="text long" value="' . esc_attr($values['address1']) . '" />' . apply_filters('wc2_filter_after_address1', NULL, $values, $type) . '</td>
			</tr>
			<tr class="' . $type . '-address2">
				<th>' . $essential_mark['address2'] . __('Building name, floor, room number', 'wc2') . '</th>
				<td><input name="' . $type . '[address2]" type="text" class="text long" value="' . esc_attr($values['address2']) . '" />' . apply_filters('wc2_filter_after_address2', NULL, $values, $type) . '</td>
			</tr>
			<tr class="' . $type . '-tel">
				<th>' . $essential_mark['tel'] . __('電話番号', 'wc2') . '</th>
				<td><input name="' . $type . '[tel]" type="text" class="text short" value="' . esc_attr($values['tel']) . '" />' . apply_filters('wc2_filter_after_tel', NULL, $values, $type) . '</td>';
                $formtag .= '
				</td>
			</tr>
			<tr class="' . $type . '-fax">
				<th>' . $essential_mark['fax'] . __('FAX番号', 'wc2') . '</th>
				<td><input name="' . $type . '[fax]" type="text" class="text short" value="' . esc_attr($values['fax']) . '" />' . apply_filters('wc2_filter_after_fax', NULL, $values, $type) . '</td>
			</tr>';
                $formtag .= self::get_custom_field_input($values, $type, 'bottom');
                break;
        }
        return $formtag;
    }
Beispiel #2
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;
     }
 }
 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;
 }