public function edit_member_data($mem_id, $type = 'member') { global $wpdb; if (empty($mem_id) || !array_key_exists($type, $_POST)) { return false; } $wc2_db_member = WC2_DB_Member::get_instance(); //$wc2_db_member->get_member_data($mem_id); $_POST = WC2_Utils::stripslashes_deep_post($_POST); $passwd = is_admin() || !is_admin() && wc2_is_blank($_POST[$type]['passwd']) && wc2_is_blank($_POST[$type]['passwd2']) ? $wc2_db_member->get_value('passwd') : md5(trim($_POST[$type]['passwd'])); $point = is_admin() && isset($_POST['member']['point']) ? trim($_POST['member']['point']) : $wc2_db_member->get_value('rank'); $rank = is_admin() ? trim($_POST['member']['rank']) : $wc2_db_member->get_value('rank'); $wc2_db_member->clear_column(); $wc2_db_member->set_member_id($mem_id); $wc2_db_member->set_value('account', trim($_POST[$type]['account'])); $wc2_db_member->set_value('email', trim($_POST[$type]['email'])); $wc2_db_member->set_value('passwd', $passwd); $wc2_db_member->set_value('rank', $rank); $wc2_db_member->set_value('point', $point); $wc2_db_member->set_value('name1', trim($_POST[$type]['name1'])); $wc2_db_member->set_value('name2', trim($_POST[$type]['name2'])); $wc2_db_member->set_value('name3', trim($_POST[$type]['name3'])); $wc2_db_member->set_value('name4', trim($_POST[$type]['name4'])); $wc2_db_member->set_value('country', trim($_POST[$type]['country'])); $wc2_db_member->set_value('zipcode', trim($_POST[$type]['zipcode'])); $wc2_db_member->set_value('pref', trim($_POST[$type]['pref'])); $wc2_db_member->set_value('address1', trim($_POST[$type]['address1'])); $wc2_db_member->set_value('address2', trim($_POST[$type]['address2'])); $wc2_db_member->set_value('tel', trim($_POST[$type]['tel'])); $wc2_db_member->set_value('fax', trim($_POST[$type]['fax'])); if ($type == 'member') { //csmb $csmb_keys = wc2_get_custom_field_keys(WC2_CSMB); if (!empty($csmb_keys) && is_array($csmb_keys)) { $csmb = array(); foreach ($csmb_keys as $key) { list($pfx, $csmb_key) = explode('_', $key, 2); //$csmb_val = ( isset( $_POST[WC2_CUSTOM_MEMBER][$csmb_key] ) ) ? $_POST[WC2_CUSTOM_MEMBER][$csmb_key]: ''; $csmb[$csmb_key] = isset($_POST[WC2_CUSTOM_MEMBER][$csmb_key]) ? $_POST[WC2_CUSTOM_MEMBER][$csmb_key] : ''; } $wc2_db_member->set_value(WC2_CUSTOM_MEMBER, $csmb); } //meta //meta_typeあり //$wc2_db_member->set_meta_value($key, $value, $type); //meta_typeなし //$wc2_db_member->set_meta_value($key, $value); } elseif ($type == 'customer') { //cscs $cscs_keys = wc2_get_custom_field_keys(WC2_CSCS); if (!empty($cscs_keys) && is_array($cscs_keys)) { $cscs = array(); foreach ($cscs_keys as $key) { list($pfx, $cscs_key) = explode('_', $key, 2); //$cscs_val = ( isset( $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key] ) ) ? $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key]: ''; $cscs[$cscs_key] = isset($_POST[WC2_CUSTOM_CUSTOMER][$cscs_key]) ? $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key] : ''; } $wc2_db_member->set_value(WC2_CUSTOM_CUSTOMER, $cscs); } //meta //meta_typeあり //$wc2_db_member->set_meta_value($key, $value, $type); //meta_typeなし //$wc2_db_member->set_meta_value($key, $value); } do_action('wc2_action_edit_member_data', $mem_id, $type); $res = $wc2_db_member->update_member_data($mem_id); return $res; }
public function set_entry() { $_POST = wc2_stripslashes_deep_post( $_POST ); if( isset($_SESSION[WC2]['member']['ID']) && !empty($_SESSION[WC2]['member']['ID']) ) { if( $_REQUEST['cart'] != 'confirm' ) { foreach( $_SESSION[WC2]['member'] as $key => $value ) { switch( $key ) { case 'ID': case 'passwd': case 'rank': case 'point': case 'registered': break; case WC2_CUSTOM_MEMBER: foreach( $value as $mbkey => $mbvalue ) { if( empty($_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$mbkey]) ) { if( is_array($mbvalue) ) { foreach( $mbvalue as $k => $v ) { $_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$mbkey][$v] = $v; } } else { $_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$mbkey] = $mbvalue; } } } break; case 'country': $_SESSION[WC2]['entry']['customer'][$key] = ( empty($value) ) ? wc2_get_base_country() : $value; break; default: if( is_array($value) ) { foreach( $value as $k => $v ) { $_SESSION[WC2]['entry']['customer'][$k] = $v; } } else { $_SESSION[WC2]['entry']['customer'][$key] = $value; } } } } } if( isset($_POST['customer']) ) { foreach( $_POST['customer'] as $key => $value ) { if( 'passwd' == $key || 'passwd2' == $key ){ continue; } if( 'country' == $key && empty($value) ) { $_SESSION[WC2]['entry']['customer'][$key] = wc2_get_base_country(); } else { $_SESSION[WC2]['entry']['customer'][$key] = $value; } } } if( isset($_POST['delivery']) ) { foreach( $_POST['delivery'] as $key => $value ) { if( 'country' == $key && empty($value) ){ $_SESSION[WC2]['entry']['delivery'][$key] = wc2_get_base_country(); } else{ $_SESSION[WC2]['entry']['delivery'][$key] = $value; } } } if( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 0 ) { foreach( $_SESSION[WC2]['entry']['customer'] as $key => $value ) { if( 'country' == $key && empty($value) ) { $_SESSION[WC2]['entry']['delivery'][$key] = wc2_get_base_country(); } else { $_SESSION[WC2]['entry']['delivery'][$key] = $value; } } } if( isset($_POST['offer']) ) { foreach( $_POST['offer'] as $key => $value ) { $_SESSION[WC2]['entry']['order'][$key] = $value; } } if( isset($_SESSION[WC2]['entry']['delivery']['delivery_flag']) && $_SESSION[WC2]['entry']['delivery']['delivery_flag'] == 0 ) { self::set_custom_customer_delivery(); } /* if( isset($_POST[WC2_CUSTOM_ORDER]) ) { unset($_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER]); foreach( $_POST[WC2_CUSTOM_ORDER] as $key => $value ) { if( is_array($value) ) { foreach( $value as $k => $v ) { $_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER][$key][$v] = $v; } } else { $_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER][$key] = $value; } } } if( isset($_POST[WC2_CUSTOM_CUSTOMER]) ) { unset($_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER]); foreach( $_POST[WC2_CUSTOM_CUSTOMER] as $key => $value ) { if( is_array($value) ) { foreach( $value as $k => $v ) { $_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$key][$v] = $v; } } else { $_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$key] = $value; } } } if( isset($_POST[WC2_CUSTOM_DELIVERY]) ) { unset($_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY]); foreach( $_POST[WC2_CUSTOM_DELIVERY] as $key => $value ) { if( is_array($value) ) { foreach( $value as $k => $v ) { $_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY][$key][$v] = $v; } } else { $_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY][$key] = $value; } } } */ if( isset($_POST['wcaction']) && 'delivery_process' == $_POST['wcaction'] ){ //csod if( isset( $_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER] ) ){ unset($_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER]); } $csod_keys = wc2_get_custom_field_keys(WC2_CSOD); if( !empty($csod_keys) && is_array($csod_keys) ){ foreach($csod_keys as $key){ list( $pfx, $csod_key ) = explode('_', $key, 2); $csod_val = ( isset( $_POST[WC2_CUSTOM_ORDER][$csod_key] ) ) ? $_POST[WC2_CUSTOM_ORDER][$csod_key]: ''; $_SESSION[WC2]['entry'][WC2_CUSTOM_ORDER][$csod_key] = $csod_val; } } //csde if( isset( $_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY] ) ){ unset($_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY]); } $csde_keys = wc2_get_custom_field_keys(WC2_CSDE); if( !empty($csde_keys) && is_array($csde_keys) ){ foreach($csde_keys as $key){ list( $pfx, $csde_key ) = explode('_', $key, 2); $csde_val = ( isset( $_POST[WC2_CUSTOM_DELIVERY][$csde_key] ) ) ? $_POST[WC2_CUSTOM_DELIVERY][$csde_key]: ''; $_SESSION[WC2]['entry'][WC2_CUSTOM_DELIVERY][$csde_key] = $csde_val; } } }elseif( isset($_POST['wcaction']) && 'customer_process' == $_POST['wcaction'] ) { //cscs if( isset( $_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER] ) ){ unset($_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER]); } $cscs_keys = wc2_get_custom_field_keys(WC2_CSCS); if( !empty($cscs_keys) && is_array($cscs_keys) ){ foreach($cscs_keys as $key){ list( $pfx, $cscs_key ) = explode('_', $key, 2); $cscs_val = ( isset( $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key] ) ) ? $_POST[WC2_CUSTOM_CUSTOMER][$cscs_key]: ''; $_SESSION[WC2]['entry'][WC2_CUSTOM_CUSTOMER][$cscs_key] = $cscs_val; } } } if( ( isset($_SESSION[WC2]['entry']['delivery']['delivery_flag']) && $_SESSION[WC2]['entry']['delivery']['delivery_flag'] == 0 ) || ( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 0 ) ) { self::set_custom_customer_delivery(); } do_action( 'wc2_action_set_entry' ); }
function wc2_register_order_data() { $wc2_order = WC2_DB_Order::get_instance(); $cart = wc2_get_cart(); $entry_data = wc2_get_entry(); if (empty($cart)) { wc2_set_log('Session is empty.', 'register_orderdata'); return false; } if (empty($entry_data['customer']['name1']) || empty($entry_data['customer']['email']) || empty($entry_data) || empty($cart)) { wc2_set_log('Customer data is empty.', 'register_orderdata'); return false; } $general_options = wc2_get_option('general'); $payment = wc2_get_payment($entry_data['order']['payment_method']); foreach ($cart as $row) { $charges_type = wc2_get_item_charges_type($row['item_id']); if (!empty($charges_type)) { break; } } $args = array('cart' => $cart, 'entry_data' => $entry_data, 'member_id' => $entry_data['member_id'], 'payment' => $payment, 'charges_type' => $charges_type); $order_date = wc2_get_today_datetime_format(); $order_status = 'new'; $receipt_status = ''; $receipted_date = ''; if ('continue' == $charges_type) { $order_modified = $order_date; } else { $noreceipt_status_table = wc2_get_option('noreceipt_status'); if (in_array($payment['settlement'], $noreceipt_status_table)) { $receipt_status = 'unpaid'; } $order_modified = ''; } $order_status = apply_filters('wc2_filter_register_orderdata_status', $order_status, $args); $receipt_status = apply_filters('wc2_filter_register_orderdata_receipt_status', $receipt_status, $args); if (!preg_match('/pending|unpaid/', $receipt_status)) { $receipted_date = $order_date; } $order_type = ''; $order_check = array(); do_action('wc2_action_register_order_data_pre', $args); $data = array(); $data[ORDER_MEMBER_ID] = isset($entry_data['member_id']) ? $entry_data['member_id'] : ''; $data[ORDER_EMAIL] = isset($entry_data['customer']['email']) ? $entry_data['customer']['email'] : ''; $data[ORDER_NAME1] = isset($entry_data['customer']['name1']) ? $entry_data['customer']['name1'] : ''; $data[ORDER_NAME2] = isset($entry_data['customer']['name2']) ? $entry_data['customer']['name2'] : ''; $data[ORDER_NAME3] = isset($entry_data['customer']['name3']) ? $entry_data['customer']['name3'] : ''; $data[ORDER_NAME4] = isset($entry_data['customer']['name4']) ? $entry_data['customer']['name4'] : ''; $data[ORDER_COUNTRY] = isset($entry_data['customer']['country']) ? $entry_data['customer']['country'] : ''; $data[ORDER_ZIPCODE] = isset($entry_data['customer']['zipcode']) ? $entry_data['customer']['zipcode'] : ''; $data[ORDER_PREF] = isset($entry_data['customer']['pref']) ? $entry_data['customer']['pref'] : ''; $data[ORDER_ADDRESS1] = isset($entry_data['customer']['address1']) ? $entry_data['customer']['address1'] : ''; $data[ORDER_ADDRESS2] = isset($entry_data['customer']['address2']) ? $entry_data['customer']['address2'] : ''; $data[ORDER_TEL] = isset($entry_data['customer']['tel']) ? $entry_data['customer']['tel'] : ''; $data[ORDER_FAX] = isset($entry_data['customer']['fax']) ? $entry_data['customer']['fax'] : ''; $data[ORDER_NOTE] = isset($entry_data['order']['note']) ? $entry_data['order']['note'] : ''; $data[ORDER_DELIVERY_METHOD] = isset($entry_data['order']['delivery_method']) ? $entry_data['order']['delivery_method'] : -1; $data[ORDER_DELIVERY_NAME] = isset($entry_data['order']['delivery_name']) ? $entry_data['order']['delivery_name'] : ''; $data[ORDER_DELIVERY_DATE] = isset($entry_data['order']['delivery_date']) ? $entry_data['order']['delivery_date'] : ''; $data[ORDER_DELIVERY_TIME] = isset($entry_data['order']['delivery_time']) ? $entry_data['order']['delivery_time'] : ''; $data[ORDER_DELIDUE_DATE] = isset($entry_data['order']['delidue_date']) ? $entry_data['order']['delidue_date'] : ''; $data[ORDER_PAYMENT_METHOD] = isset($entry_data['order']['payment_method']) ? $entry_data['order']['payment_method'] : -1; $data[ORDER_PAYMENT_NAME] = isset($entry_data['order']['payment_name']) ? $entry_data['order']['payment_name'] : ''; $data[ORDER_CONDITION] = serialize(wc2_get_condition()); $data[ORDER_ITEM_TOTAL_PRICE] = isset($entry_data['order']['item_total_price']) ? $entry_data['order']['item_total_price'] : 0; $data[ORDER_GETPOINT] = isset($entry_data['order']['getpoint']) ? $entry_data['order']['getpoint'] : 0; $data[ORDER_USEDPOINT] = isset($entry_data['order']['usedpoint']) ? $entry_data['order']['usedpoint'] : 0; $data[ORDER_DISCOUNT] = isset($entry_data['order']['discount']) ? $entry_data['order']['discount'] : 0; $data[ORDER_SHIPPING_CHARGE] = isset($entry_data['order']['shipping_charge']) ? $entry_data['order']['shipping_charge'] : 0; $data[ORDER_COD_FEE] = isset($entry_data['order']['cod_fee']) ? $entry_data['order']['cod_fee'] : 0; $data[ORDER_TAX] = isset($entry_data['order']['tax']) ? $entry_data['order']['tax'] : 0; $data[ORDER_DATE] = $order_date; $data[ORDER_MODIFIED] = $order_modified; $data[ORDER_STATUS] = $order_status; $data[RECEIPT_STATUS] = $receipt_status; $data[RECEIPTED_DATE] = $receipted_date; $data[ORDER_TYPE] = $order_type; $data[ORDER_CHECK] = serialize($order_check); $cscs_keys = wc2_get_custom_field_keys(WC2_CSCS); if (!empty($cscs_keys) && is_array($cscs_keys)) { foreach ($cscs_keys as $key) { list($pfx, $cscs_key) = explode('_', $key, 2); if (array_key_exists(WC2_CUSTOM_CUSTOMER, $entry_data['customer']) and array_key_exists($cscs_key, $entry_data['customer'][WC2_CUSTOM_CUSTOMER])) { if (is_array($entry_data['customer'][WC2_CUSTOM_CUSTOMER][$cscs_key])) { $data[WC2_CUSTOM_CUSTOMER][$cscs_key] = serialize($entry_data['customer'][WC2_CUSTOM_CUSTOMER][$cscs_key]); } else { $data[WC2_CUSTOM_CUSTOMER][$cscs_key] = $entry_data['customer'][WC2_CUSTOM_CUSTOMER][$cscs_key]; } } else { $data[WC2_CUSTOM_CUSTOMER][$cscs_key] = ''; } } } $csod_keys = wc2_get_custom_field_keys(WC2_CSOD); if (!empty($csod_keys) && is_array($csod_keys)) { foreach ($csod_keys as $key) { list($pfx, $csod_key) = explode('_', $key, 2); if (array_key_exists(WC2_CUSTOM_ORDER, $entry_data['order']) and array_key_exists($csod_key, $entry_data['order'][WC2_CUSTOM_ORDER])) { if (is_array($entry_data['order'][WC2_CUSTOM_ORDER][$csod_key])) { $data[WC2_CUSTOM_ORDER][$csod_key] = serialize($entry_data['order'][WC2_CUSTOM_ORDER][$csod_key]); } else { $data[WC2_CUSTOM_ORDER][$csod_key] = $entry_data['order'][WC2_CUSTOM_ORDER][$csod_key]; } } else { $data[WC2_CUSTOM_ORDER][$csod_key] = ''; } } } $data[ORDER_CART] = array(); ksort($cart); foreach ($cart as $idx => $row) { //$data[ORDER_CART][$row_index][ORDER_CART_GROUP_ID] = 0; $data[ORDER_CART][$idx][ORDER_CART_ROW_INDEX] = $idx; $data[ORDER_CART][$idx][ORDER_CART_POST_ID] = $row['post_id']; $data[ORDER_CART][$idx][ORDER_CART_ITEM_ID] = $row['item_id']; $data[ORDER_CART][$idx][ORDER_CART_ITEM_CODE] = $row['item_code']; $data[ORDER_CART][$idx][ORDER_CART_ITEM_NAME] = $row['item_name']; $data[ORDER_CART][$idx][ORDER_CART_SKU_ID] = $row['sku_id']; $data[ORDER_CART][$idx][ORDER_CART_SKU_CODE] = $row['sku_code']; $data[ORDER_CART][$idx][ORDER_CART_SKU_NAME] = $row['sku_name']; $data[ORDER_CART][$idx][ORDER_CART_PRICE] = $row['price']; $data[ORDER_CART][$idx][ORDER_CART_CPRICE] = $row['cprice']; $data[ORDER_CART][$idx][ORDER_CART_QUANTITY] = $row['quantity']; $data[ORDER_CART][$idx][ORDER_CART_UNIT] = $row['unit']; $data[ORDER_CART][$idx][ORDER_CART_TAX] = $row['tax']; //$data[ORDER_CART][$idx][ORDER_CART_DESTINATION_ID] = 0; $data[ORDER_CART][$idx][ORDER_CART_META_TYPE] = maybe_unserialize($row['meta_type']); $data[ORDER_CART][$idx][ORDER_CART_META_KEY] = maybe_unserialize($row['meta_key']); } $data[ORDER_DELIVERY][0][ORDER_DELIVERY_ROW_INDEX] = 0; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_NAME1] = isset($entry_data['delivery']['name1']) ? $entry_data['delivery']['name1'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_NAME2] = isset($entry_data['delivery']['name2']) ? $entry_data['delivery']['name2'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_NAME3] = isset($entry_data['delivery']['name3']) ? $entry_data['delivery']['name3'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_NAME4] = isset($entry_data['delivery']['name4']) ? $entry_data['delivery']['name4'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_COUNTRY] = isset($entry_data['delivery']['country']) ? $entry_data['delivery']['country'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_ZIPCODE] = isset($entry_data['delivery']['zipcode']) ? $entry_data['delivery']['zipcode'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_PREF] = isset($entry_data['delivery']['pref']) ? $entry_data['delivery']['pref'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_ADDRESS1] = isset($entry_data['delivery']['address1']) ? $entry_data['delivery']['address1'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_ADDRESS2] = isset($entry_data['delivery']['address2']) ? $entry_data['delivery']['address2'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_TEL] = isset($entry_data['delivery']['tel']) ? $entry_data['delivery']['tel'] : ''; $data[ORDER_DELIVERY][0][ORDER_DELIVERY_FAX] = isset($entry_data['delivery']['fax']) ? $entry_data['delivery']['fax'] : ''; $csde_keys = wc2_get_custom_field_keys(WC2_CSDE); if (!empty($csde_keys) && is_array($csde_keys)) { foreach ($csde_keys as $key) { list($pfx, $csde_key) = explode('_', $key, 2); if (array_key_exists(WC2_CUSTOM_DELIVERY, $entry_data['delivery']) and array_key_exists($csde_key, $entry_data['delivery'][WC2_CUSTOM_DELIVERY])) { if (is_array($entry_data['delivery'][WC2_CUSTOM_DELIVERY][$csde_key])) { $data[ORDER_DELIVERY][0][WC2_CUSTOM_DELIVERY][$csde_key] = serialize($entry_data['delivery'][WC2_CUSTOM_DELIVERY][$csde_key]); } else { $data[ORDER_DELIVERY][0][WC2_CUSTOM_DELIVERY][$csde_key] = $entry_data['delivery'][WC2_CUSTOM_DELIVERY][$csde_key]; } } else { $data[ORDER_DELIVERY][0][WC2_CUSTOM_DELIVERY][$csde_key] = ''; } } } //wc2_log(print_r($data,true),"test.log"); $data = apply_filters('wc2_filter_register_order_entry_data', $data, $args); $wc2_order->set_order_data($data); $res = $wc2_order->add_order_data(); if (!$res) { wc2_set_log('Order data registration error.', 'register_orderdata'); return false; } $order_id = $wc2_order->get_the_order_id(); if ($entry_data['member_id'] && wc2_is_membersystem_state() && wc2_is_membersystem_point()) { $wc2_order->point_processing($order_id, $entry_data['member_id'], $entry_data['order']['payment_method'], $entry_data['order']['getpoint'], $entry_data['order']['usedpoint'], $receipt_status); } $args['order_id'] = $order_id; wc2_set_dec_order_id($args); do_action('wc2_action_register_order_data', $args, $data); return $order_id; }
public function admin_member_page() { if (!isset($this->plugin_screen_hook_suffix)) { return; } $screen = get_current_screen(); if ($this->plugin_screen_hook_suffix != $screen->id) { return; } if (isset($_REQUEST['action']) && '-1' != $_REQUEST['action']) { $this->mode = $_REQUEST['action']; } elseif (isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2']) { $this->mode = $_REQUEST['action2']; } else { $this->mode = 'list'; } $member_id = isset($_REQUEST['target']) ? trim($_REQUEST['target']) : ''; $wc2_db_member = WC2_DB_Member::get_instance(); switch ($this->mode) { case 'new': $this->page = 'member-post'; break; case 'edit': if (array_key_exists('addButton', $_POST)) { check_admin_referer('wc2_member_post', 'wc2_nonce'); $this->error_message = wc2_member_check('member', $member_id); if (array() == $this->error_message) { $res = wc2_new_member_data(); if (1 === $res) { $this->set_action_status('success', __('登録が完了しました。', 'wc2')); } else { $this->set_action_status('error', __('登録に失敗しました。', 'wc2')); } } else { $this->set_action_status('error', __('登録に失敗しました。', 'wc2')); } } //upmem_check if (array_key_exists('upButton', $_POST)) { check_admin_referer('wc2_member_post', 'wc2_nonce'); $this->error_message = wc2_member_check('member', $_REQUEST['target']); if (array() == $this->error_message) { $res = wc2_edit_member_data($member_id); if (1 === $res) { $this->set_action_status('success', __('登録が完了しました。', 'wc2')); } elseif (0 !== $res) { $this->set_action_status('error', __('登録に失敗しました。', 'wc2')); } } else { $this->set_action_status('error', __('登録に失敗しました。', 'wc2')); } } $this->page = 'member-post'; break; case 'delete': check_admin_referer('wc2_member_list', 'wc2_nonce'); $res = $wc2_db_member->delete_member_data($member_id); if (1 === $res) { $this->set_action_status('success', __('削除しました。', 'wc2')); } else { $this->set_action_status('error', __('削除に失敗しました。', 'wc2')); } $this->page = 'member-list'; break; case 'delete_batch': check_admin_referer('wc2_member_list', 'wc2_nonce'); if (isset($_REQUEST['member']) && !empty($_REQUEST['member'])) { $mem_ids = $_REQUEST['member']; $res = $this->delete_batch_member_data($mem_ids); if (1 === $res) { $this->set_action_status('success', __('削除しました。', 'wc2')); } else { $this->set_action_status('error', __('削除に失敗しました。', 'wc2')); } } $this->page = 'member-list'; break; case 'dlmemberlist': check_admin_referer('wc2_dl_memberlist', 'wc2_nonce'); $this->wc2_download_member_list(); $this->page = ''; break; case 'list': default: $this->page = 'member-list'; break; } if (!empty($this->page)) { $rank_type = wc2_get_option('rank_type'); if ($this->page == 'member-list') { $Member_List_Table = new Member_List_Table(); $Member_List_Table->prepare_items(); $status = $this->action_status; $message = $this->action_message; $this->action_status = 'none'; $this->action_message = ''; $search_column_key = isset($_REQUEST['search_column']) ? $_REQUEST['search_column'] : ''; $search_word = ''; $search_word_key = ''; switch ($search_column_key) { case 'none': break; case 'mem_rank': $search_word_key = isset($_REQUEST['search_word']['mem_rank']) ? $_REQUEST['search_word']['mem_rank'] : ''; if (array_key_exists($search_word_key, $rank_type)) { $search_word = $rank_type[$search_word_key]; } break; default: if (isset($_REQUEST['search_word']['keyword'])) { $search_word = $_REQUEST['search_word']['keyword']; } } $search_columns = $Member_List_Table->define_columns(); unset($search_columns['cb']); $search_columns = apply_filters('wc2_filter_admin_member_list_search_columns', $search_columns); $wc2_opt_member = wc2_get_option('wc2_opt_member'); $chk_mem = $wc2_opt_member['chk_mem']; } elseif ($this->page == 'member-post') { $wc2_options = wc2_get_option(); $status = $this->action_status; $message = $this->action_message; $this->action_status = 'none'; $this->action_message = ''; $member_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; if (array() != $this->error_message && array_key_exists('addButton', $_POST)) { $member_action = 'new'; } $data = array(); //$referer = wp_get_referer(); //新規会員登録ページ if ('new' == $member_action) { $title = '新規会員登録'; $page = 'wc2_member'; $oa = 'edit'; $data['ID'] = ''; $data['account'] = isset($_POST['member']['account']) ? $_POST['member']['account'] : ''; $data['email'] = isset($_POST['member']['email']) ? $_POST['member']['email'] : ''; $data['passwd'] = isset($_POST['member']['passwd']) ? $_POST['member']['passwd'] : ''; $data['rank'] = isset($_POST['member']['rank']) ? $_POST['member']['rank'] : ''; $data['point'] = isset($_POST['member']['point']) ? $_POST['member']['point'] : ''; $data['name1'] = isset($_POST['member']['name1']) ? $_POST['member']['name1'] : ''; $data['name2'] = isset($_POST['member']['name2']) ? $_POST['member']['name2'] : ''; $data['name3'] = isset($_POST['member']['name3']) ? $_POST['member']['name3'] : ''; $data['name4'] = isset($_POST['member']['name4']) ? $_POST['member']['name4'] : ''; $data['country'] = isset($_POST['member']['country']) ? $_POST['member']['country'] : ''; $data['zipcode'] = isset($_POST['member']['zipcode']) ? $_POST['member']['zipcode'] : ''; $data['pref'] = isset($_POST['member']['pref']) ? $_POST['member']['pref'] : ''; $data['address1'] = isset($_POST['member']['address1']) ? $_POST['member']['address1'] : ''; $data['address2'] = isset($_POST['member']['address2']) ? $_POST['member']['address2'] : ''; $data['tel'] = isset($_POST['member']['tel']) ? $_POST['member']['tel'] : ''; $data['fax'] = isset($_POST['member']['fax']) ? $_POST['member']['fax'] : ''; $data['registered'] = '--------------'; //csmb $csmb_keys = wc2_get_custom_field_keys(WC2_CSMB); if (!empty($csmb_keys) && is_array($csmb_keys)) { foreach ($csmb_keys as $key) { list($pfx, $csmb_key) = explode('_', $key, 2); $csmb_val = isset($_POST[WC2_CUSTOM_MEMBER][$csmb_key]) ? $_POST[WC2_CUSTOM_MEMBER][$csmb_key] : ''; $data[WC2_CUSTOM_MEMBER][$csmb_key] = $csmb_val; } } //履歴 //$wc2_member_history =array(); //会員情報編集ページ } elseif ('edit' == $member_action) { $title = '会員情報編集'; $page = 'wc2_member'; $oa = 'edit'; if (isset($_REQUEST['target'])) { $member_id = $_REQUEST['target']; } else { $member_id = $wc2_db_member->get_member_id(); } $data = $wc2_db_member->get_member_data($member_id); //履歴 // $wc2_member_history = wc2_get_member_history(); } else { die('不正なパラメータです'); } //$material = compact('data', 'meta_data'); } require_once WC2_PLUGIN_DIR . '/admin/views/' . $this->page . '.php'; } }
public function set_session_member_from_post_data(){ //固定 $member_id = $this->get_memberinfo('ID'); $rank = wc2_get_member_data_value($member_id, MEMBER_RANK); $point = wc2_get_member_data_value($member_id, MEMBER_POINT); $registered = wc2_get_member_data_value($member_id, MEMBER_REGISTERED); if( isset( $_SESSION[WC2]['member'] ) ){ unset($_SESSION[WC2]['member']); } $_SESSION[WC2]['member']['ID'] = $member_id; $_POST = WC2_Utils::stripslashes_deep_post($_POST); $base_member_key = array( 'account', 'email', 'email2' , 'rank' , 'point' , 'name1' , 'name2' , 'name3' , 'name4' , 'country' , 'zipcode' , 'pref' , 'address1' , 'address2' , 'tel' , 'fax' , 'registered' , ); foreach( $base_member_key as $mem_key ){ switch($mem_key){ case 'rank': $_SESSION[WC2]['member'][$mem_key] = $rank; break; case 'point': $_SESSION[WC2]['member'][$mem_key] = $point; break; case 'registered': $_SESSION[WC2]['member'][$mem_key] = $registered; break; default: $_SESSION[WC2]['member'][$mem_key] = ( isset( $_POST['member'][$mem_key] ) ) ? $_POST['member'][$mem_key]: ''; break; } } //csmb $csmb_keys = wc2_get_custom_field_keys(WC2_CSMB); if( !empty($csmb_keys) && is_array($csmb_keys) ){ foreach($csmb_keys as $key){ list( $pfx, $csmb_key ) = explode('_', $key, 2); $csmb_val = ( isset( $_POST[WC2_CUSTOM_MEMBER][$csmb_key] ) ) ? $_POST[WC2_CUSTOM_MEMBER][$csmb_key]: ''; $_SESSION[WC2]['member'][WC2_CUSTOM_MEMBER][$csmb_key] = $csmb_val; } } //meta do_action('wc2_action_set_session_member_from_post_data'); }
function wc2_custom_field_enter_check($type) { switch ($type) { case 'order': $label = WC2_CUSTOM_ORDER; $prefix = WC2_CSOD; break; case 'customer': $label = WC2_CUSTOM_CUSTOMER; $prefix = WC2_CSCS; break; case 'delivery': $label = WC2_CUSTOM_DELIVERY; $prefix = WC2_CSDE; break; case 'member': $label = WC2_CUSTOM_MEMBER; $prefix = WC2_CSMB; break; default: return; } $custome_field_keys = wc2_get_custom_field_keys($prefix); $mes = array(); foreach ($custome_field_keys as $csfd_key) { $custom_field = wc2_get_option($csfd_key); //必須カスタムフィールド入力チェック if (1 == $custom_field['essential']) { switch ($custom_field['means']) { case 'radio': case 'check': if (!isset($_POST[$label][$custom_field['key']])) { $mes[] = sprintf(__('%sが選択されていません。', 'wc2'), $custom_field['name']); } break; case 'select': case 'multi': if (!isset($_POST[$label][$custom_field['key']]) || '#NONE#' == $_POST[$label][$custom_field['key']]) { $mes[] = sprintf(__('%sが選択されていません。', 'wc2'), $custom_field['name']); } break; case 'text': case 'textarea': if (empty($_POST[$label][$custom_field['key']])) { $mes[] = sprintf(__('%sが入力されていません。', 'wc2'), $custom_field['name']); } break; } } } return $mes; }
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; }