Exemple #1
0
 public function print_process()
 {
     if (!class_exists('FPDI')) {
         require_once WC2_PLUGIN_DIR . '/common/includes/pdf/tcpdf/config/lang/jpn.php';
         require_once WC2_PLUGIN_DIR . '/common/includes/pdf/tcpdf/tcpdf.php';
         require_once WC2_PLUGIN_DIR . '/common/includes/pdf/fpdi/fpdi.php';
         //require_once(WC2_PLUGIN_DIR.'/classes/orderData.class.php');
         //用紙サイズ(B5)
         $pdf = new FPDI('P', 'mm', 'B5', true, array(182, 257), 'UTF-8');
     }
     //Custom return $pdf->addTTFfont( WC2_PLUGIN_DIR .'/common/includes/pdf/tcpdf/fonts/add_font_name.php');
     $this->font = apply_filters('wc2_filter_pdf_font', 'msgothic', $pdf);
     //$wc2_pdfo = new orderDataObject($_REQUEST['order_id']);
     $wc2_order = WC2_DB_Order::get_instance();
     $order_id = $_GET['order_id'];
     $order_data = $wc2_order->get_order_data($order_id);
     $this->pdf_out($pdf, $order_data);
     die;
 }
 function get_list_data($args)
 {
     $wc2_order = WC2_DB_Order::get_instance();
     if (isset($_REQUEST['search_refine'])) {
         //絞り込み検索
         $_SESSION[WC2]['order-list']['search_period'] = $_REQUEST['search_period'];
         $_SESSION[WC2]['order-list']['startdate'] = $_REQUEST['startdate'];
         $_SESSION[WC2]['order-list']['enddate'] = $_REQUEST['enddate'];
     }
     $search_period = isset($_SESSION[WC2]['order-list']['search_period']) ? $_SESSION[WC2]['order-list']['search_period'] : 3;
     switch ($search_period) {
         case 0:
             //今月
             $thismonth = date_i18n('Y-m-01 00:00:00');
             $args['where'] = "order_date >= '{$thismonth}' ";
             break;
         case 1:
             //先月
             $thismonth = date_i18n('Y-m-01 00:00:00');
             $lastmonth = date_i18n('Y-m-01 00:00:00', mktime(0, 0, 0, date('m') - 1, 1, date('Y')));
             $args['where'] = "order_date >= '{$lastmonth}' AND order_date < '{$thismonth}' ";
             break;
         case 2:
             //過去1週間
             $lastweek = date_i18n('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d') - 7, date('Y')));
             $args['where'] = "order_date >= '{$lastweek}' ";
             break;
         case 3:
             //過去30日間
             $last30 = date_i18n('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d') - 30, date('Y')));
             $args['where'] = "order_date >= '{$last30}' ";
             break;
         case 4:
             //過去90日間
             $last90 = date_i18n('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d') - 90, date('Y')));
             $args['where'] = "order_date >= '{$last90}' ";
             break;
         case 5:
             //期間指定
             if (isset($_REQUEST['startdate'])) {
                 $startdate = $_REQUEST['startdate'];
             } elseif (isset($_SESSION[WC2]['order-list']['startdate'])) {
                 $startdate = $_SESSION[WC2]['order-list']['startdate'];
             } else {
                 $startdate = '';
             }
             if (isset($_REQUEST['enddate'])) {
                 $enddate = $_REQUEST['enddate'];
             } elseif (isset($_SESSION[WC2]['order-list']['enddate'])) {
                 $enddate = $_SESSION[WC2]['order-list']['enddate'];
             } else {
                 $enddate = '';
             }
             if ('' != $startdate or '' != $enddate) {
                 if ('' == $enddate) {
                     $args['where'] = "order_date >= '{$startdate}'";
                 } elseif ('' == $startdate) {
                     $args['where'] = "order_date < '{$enddate}'";
                 } else {
                     $args['where'] = "order_date >= '{$startdate}' AND order_date < '{$enddate}'";
                 }
             }
             break;
         case 6:
             //全て
         //全て
         default:
             $args['where'] = "";
             break;
     }
     $args = apply_filters('wc2_filter_admin_order_list_data_args', $args);
     $results = $wc2_order->get_order_list_data($args);
     return $results;
 }
    public function member_history_rows()
    {
        $wc2_db_member = WC2_DB_Member::get_instance();
        $wc2_order = WC2_DB_Order::get_instance();
        $wc2_item = WC2_DB_Item::get_instance();
        if (is_admin()) {
            $member_id = $wc2_db_member->get_member_id();
        } else {
            if (wc2_is_login() && 0 != $_SESSION[WC2]['member']['ID']) {
                $member_id = $_SESSION[WC2]['member']['ID'];
            } else {
                return false;
            }
        }
        $member_history = $wc2_order->get_member_history($member_id);
        $colspan = wc2_is_membersystem_point() ? 9 : 7;
        $html = '<div class="history-area">
					<table>';
        if (!count($member_history)) {
            $html .= '<tr>
			<td>' . __('There is no your purchase history.', 'wc2') . '</td>
			</tr>';
        }
        foreach ($member_history as $umhs) {
            $cart = $umhs['cart'];
            $history_member_head = '<tr>
				<th class="historyrow">' . __('Order number', 'wc2') . '</th>
				<th class="historyrow">' . __('Order status', 'wc2') . '</th>
				<th class="historyrow">' . __('Purchase date', 'wc2') . '</th>
				<th class="historyrow">' . __('Purchase amount', 'wc2') . '</th>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<th class="historyrow">' . __('Used points', 'wc2') . '</th>';
            }
            $history_member_head .= '<th class="historyrow">' . apply_filters('wc2_filter_discount_label', __('Discount', 'wc2'), $umhs) . '</th>
				<th class="historyrow">' . __('Shipping charges', 'wc2') . '</th>
				<th class="historyrow">' . apply_filters('wc2_filter_cod_label', __('COD fee', 'wc2')) . '</th>
				<th class="historyrow">' . __('Consumption tax', 'wc2') . '</th>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<th class="historyrow">' . __('Acquired points', 'wc2') . '</th>';
            }
            $history_member_head .= '</tr>
				<tr>
				<td class="rightnum"><a href="' . WC2_ADMIN_URL . '?page=wc2_order&action=edit&target=' . $umhs['ID'] . '">' . $umhs['dec_order_id'] . '</a></td>
				<td class="aleft">' . wc2_get_order_status_name($umhs['order_status']) . '</td>
				<td class="date">' . $umhs['order_date'] . '</td>
				<td class="rightnum">' . wc2_crform($umhs['item_total_price'] - $umhs['usedpoint'] + $umhs['discount'] + $umhs['shipping_charge'] + $umhs['cod_fee'] + $umhs['tax'], true, false) . '</td>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<td class="rightnum">' . number_format($umhs['usedpoint']) . '</td>';
            }
            $history_member_head .= '<td class="rightnum">' . wc2_crform($umhs['discount'], true, false) . '</td>
				<td class="rightnum">' . wc2_crform($umhs['shipping_charge'], true, false) . '</td>
				<td class="rightnum">' . wc2_crform($umhs['cod_fee'], true, false) . '</td>
				<td class="rightnum">' . wc2_crform($umhs['tax'], true, false) . '</td>';
            if (wc2_is_membersystem_point()) {
                $history_member_head .= '<td class="rightnum">' . number_format($umhs['getpoint']) . '</td>';
            }
            $history_member_head .= '</tr>';
            $html .= apply_filters('wc2_filter_history_member_head', $history_member_head, $umhs);
            $html .= apply_filters('wc2_filter_member_history_header', NULL, $umhs);
            $html .= '<tr>
				<td class="retail" colspan="' . $colspan . '">
					<table id="retail_table_' . $umhs['ID'] . '" class="retail">';
            $history_cart_head = '<tr>
					<th scope="row" class="num">No.</th>
					<th class="thumbnail">&nbsp;</th>
					<th>' . __('Items', 'wc2') . '</th>
					<th class="price ">' . __('Unit price', 'wc2') . '(' . wc2_crcode() . ')' . '</th>
					<th class="quantity">' . __('Quantity', 'wc2') . '</th>
					<th class="subtotal">' . __('Amount', 'wc2') . '(' . wc2_crcode() . ')' . '</th>
					</tr>';
            $html .= apply_filters('wc2_filter_history_cart_head', $history_cart_head, $umhs);
            $i = 1;
            foreach ($cart as $cart_row) {
                $ordercart_id = $cart_row['cart_id'];
                $post_id = $cart_row['post_id'];
                $item_id = $cart_row['item_id'];
                $sku_id = $cart_row['sku_id'];
                $quantity = $cart_row['quantity'];
                $options = isset($cart_row['options']) ? $cart_row['options'] : '';
                //$options = wc2_get_ordercart_meta_value( 'option', $ordercart_id );
                //$options = wc2_get_ordercart_meta( 'option', $ordercart_id );
                $item_name = $cart_row['item_name'];
                $item_code = $cart_row['item_code'];
                $sku_name = $cart_row['sku_name'];
                $sku_code = $cart_row['sku_code'];
                $cart_item_name = wc2_get_cart_item_name($item_name, $item_code, $sku_name, $sku_code);
                $skuPrice = $cart_row['price'];
                $pictid = (int) $wc2_item->get_mainpictid($item_code);
                $optstr = '';
                if (is_array($options) && count($options) > 0) {
                    $optstr = '';
                    foreach ($options as $key => $value) {
                        if (!empty($key)) {
                            $key = urldecode($key);
                            $value = maybe_unserialize($value);
                            if (is_array($value)) {
                                $c = '';
                                $optstr .= esc_html($key) . ' : ';
                                foreach ($value as $v) {
                                    $optstr .= $c . nl2br(esc_html(urldecode($v)));
                                    $c = ', ';
                                }
                                $optstr .= "<br />\n";
                            } else {
                                $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
                            }
                        }
                    }
                    $optstr = apply_filters('wc2_filter_option_history', $optstr, $options);
                }
                $optstr = apply_filters('wc2_filter_option_info_history', $optstr, $umhs, $cart_row, $i);
                $permalink = apply_filters('wc2_filter_link_item_history', get_permalink($post_id), $cart_row);
                $history_cart_row = '<tr>
					<td>' . $i . '</td>
					<td>';
                if ($pictid) {
                    $cart_thumbnail = '<a href="' . esc_url($permalink) . '">' . wp_get_attachment_image($pictid, array(60, 60), true) . '</a>';
                } else {
                    $cart_thumbnail = '<p>' . wc2_no_image() . '</p>';
                }
                $history_cart_row .= apply_filters('wc2_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
                $history_cart_row .= '</td>
					<td class="aleft"><a href="' . esc_url($permalink) . '">' . esc_html($cart_item_name) . '<br />' . $optstr . '</a>' . apply_filters('wc2_filter_history_item_name', NULL, $umhs, $cart_row, $i) . '</td>
					<td class="rightnum">' . wc2_crform($skuPrice, true, false) . '</td>
					<td class="rightnum">' . number_format($cart_row['quantity']) . '</td>
					<td class="rightnum">' . wc2_crform($skuPrice * $cart_row['quantity'], true, false) . '</td>
					</tr>';
                $materials = compact('cart_thumbnail', 'post_id', 'pictid', 'cart_item_name', 'optstr');
                $html .= apply_filters('wc2_filter_history_cart_row', $history_cart_row, $umhs, $cart_row, $i, $materials);
                $i++;
            }
            $html .= '</table>
				</td>
				</tr>';
        }
        $html .= '</table>
		</div>';
        $html = apply_filters('wc2_filter_member_history_rows', $html, $member_id, $member_history, $colspan);
        return $html;
    }
function wc2_update_order_check($order_id, $checked)
{
    $wc2_order = WC2_DB_Order::get_instance();
    return $wc2_order->update_order_check($order_id, $checked);
}
 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;
 }