コード例 #1
0
ファイル: class-page.php プロジェクト: nanbu-collne/test2
	/**
	 * Checkout
	 *
	 */
	public function checkout() {
		$mes = $this->checkout_check();
		if( 0 < count($mes) ) {
			foreach( $mes as $error )
				$this->set_error( $error, 'checkout' );
			$this->current_page_type = 'cart';
			$this->current_page = 'top';
			$this->page_redirect();
		}

		if( $this->is_member_logged_in() ) {
			$member_id = wc2_memberinfo( 'ID' );
			$member = wc2_get_member_data( $member_id );
			//SET SESSION
			wc2_set_session_current_member( $member );
		}
	//	wc2_clear_entry();
		wc2_set_entry();
		$mes = $this->stock_check();
		if( 0 < count($mes) ) {
			foreach( $mes as $error )
				$this->set_error( $error, 'checkout' );
			$this->current_page_type = 'cart';
			$this->current_page = 'top';
			$this->page_redirect();
		}

		if( $this->is_member_logged_in() ) {
			$this->current_page_type = 'cart';
			$this->current_page = 'delivery';
			$this->page_redirect();
		}
	}
コード例 #2
0
 public function wc2_download_member_list()
 {
     global $wpdb;
     $wc2_options = wc2_get_option();
     $locale_options = wc2_get_option('locale_options');
     $applyform = WC2_Funcs::get_apply_addressform($wc2_options['system']['addressform']);
     $target_market = $wc2_options['system']['target_market'];
     $MLT = new Member_List_Table();
     //1ぺーじあたりのテーブルの行数
     $per_page = $MLT->get_items_per_page(self::$per_page_slug);
     //ソート
     $args = $MLT->sort_culum_order_by($per_page);
     //データ
     $rows = $MLT->get_list_data($args);
     $ext = $_REQUEST['ftype'];
     if ($ext == 'csv') {
         //CSV
         $table_h = "";
         $table_f = "";
         $tr_h = "";
         $tr_f = "";
         $th_h1 = '"';
         $th_h = ',"';
         $th_f = '"';
         $td_h1 = '"';
         $td_h = ',"';
         $td_f = '"';
         $nb = " ";
         $lf = "\n";
     } else {
         exit;
     }
     $wc2_opt_member = wc2_get_option('wc2_opt_member');
     if (!is_array($wc2_opt_member)) {
         $wc2_opt_member = array();
     }
     $wc2_opt_member['ftype_mem'] = $ext;
     //---------------------- checkbox Check -----------------------//
     $chk_mem = array();
     $chk_mem['ID'] = 1;
     //$chk_mem['code'] = 1;
     $chk_mem['account'] = 1;
     //head
     $hd_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'head');
     if (!empty($hd_keys)) {
         foreach ($hd_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $chk_mem['email'] = isset($_REQUEST['check']['email']) ? 1 : 0;
     //beforename
     $bn_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'beforename');
     if (!empty($bn_keys)) {
         foreach ($bn_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $chk_mem['name'] = 1;
     $chk_mem['kana'] = isset($_REQUEST['check']['kana']) ? 1 : 0;
     //aftername
     $an_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'aftername');
     if (!empty($an_keys)) {
         foreach ($an_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $chk_mem['country'] = isset($_REQUEST['check']['country']) ? 1 : 0;
     $chk_mem['zipcode'] = isset($_REQUEST['check']['zipcode']) ? 1 : 0;
     $chk_mem['pref'] = 1;
     $chk_mem['address1'] = 1;
     $chk_mem['address2'] = 1;
     $chk_mem['tel'] = isset($_REQUEST['check']['tel']) ? 1 : 0;
     $chk_mem['fax'] = isset($_REQUEST['check']['fax']) ? 1 : 0;
     //bottom
     $btm_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'bottom');
     if (!empty($btm_keys)) {
         foreach ($btm_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $chk_mem['registered'] = isset($_REQUEST['check']['registered']) ? 1 : 0;
     $chk_mem['point'] = isset($_REQUEST['check']['point']) ? 1 : 0;
     $chk_mem['rank'] = isset($_REQUEST['check']['rank']) ? 1 : 0;
     //other
     $oth_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'other');
     if (!empty($oth_keys)) {
         foreach ($oth_keys as $csmb_key) {
             $chk_mem[$csmb_key] = isset($_REQUEST['check'][$csmb_key]) ? 1 : 0;
         }
     }
     $wc2_opt_member['chk_mem'] = apply_filters('wc2_filter_chk_mem', $chk_mem);
     //		update_option('wc2_opt_member', $wc2_opt_member);
     wc2_update_option('wc2_opt_member', $wc2_opt_member);
     //---------------------- TITLE -----------------------//
     $line = $table_h;
     $line .= $tr_h;
     $line .= $th_h1 . __('Membership ID', 'wc2') . $th_f;
     $line .= $th_h . __('Login account', 'wc2') . $th_f;
     //csmb head
     $hd_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'head');
     if (!empty($hd_keys)) {
         foreach ($hd_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     if (isset($_REQUEST['check']['email'])) {
         $line .= $th_h . __('E-mail', 'wc2') . $th_f;
     }
     //csmb beforename
     $bn_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'beforename');
     if (!empty($bn_keys)) {
         foreach ($bn_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     $line .= $th_h . __('Name', 'wc2') . $th_f;
     if ('JP' == $applyform) {
         if (isset($_REQUEST['check']['kana'])) {
             $line .= $th_h . __('Kana', 'wc2') . $th_f;
         }
     }
     //csmb aftername
     $an_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'aftername');
     if (!empty($an_keys)) {
         foreach ($an_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     switch ($applyform) {
         case 'JP':
             if (isset($_REQUEST['check']['country'])) {
                 $line .= $th_h . __('Country', 'wc2') . $th_f;
             }
             if (isset($_REQUEST['check']['zipcode'])) {
                 $line .= $th_h . __('Postal Code', 'wc2') . $th_f;
             }
             $line .= $th_h . __('Prefecture', 'wc2') . $th_f;
             $line .= $th_h . __('City', 'wc2') . $th_f;
             $line .= $th_h . __('Building name, floor, room number', 'wc2') . $th_f;
             if (isset($_REQUEST['check']['tel'])) {
                 $line .= $th_h . __('Phone number', 'wc2') . $th_f;
             }
             if (isset($_REQUEST['check']['fax'])) {
                 $line .= $th_h . __('FAX number', 'wc2') . $th_f;
             }
             break;
         case 'US':
         default:
             $line .= $th_h . __('Building name, floor, room number', 'wc2') . $th_f;
             $line .= $th_h . __('City', 'wc2') . $th_f;
             $line .= $th_h . __('Prefecture', 'wc2') . $th_f;
             $line .= $th_h . __('Postal Code', 'wc2') . $th_f;
             if (isset($_REQUEST['check']['country'])) {
                 $line .= $th_h . __('Country', 'wc2') . $th_f;
             }
             if (isset($_REQUEST['check']['tel'])) {
                 $line .= $th_h . __('Phone number', 'wc2') . $th_f;
             }
             if (isset($_REQUEST['check']['fax'])) {
                 $line .= $th_h . __('FAX number', 'wc2') . $th_f;
             }
             break;
     }
     //csmb bottom
     $btm_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'bottom');
     if (!empty($btm_keys)) {
         foreach ($btm_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     if (isset($_REQUEST['check']['rank'])) {
         $line .= $th_h . __('ランク', 'wc2') . $th_f;
     }
     if (isset($_REQUEST['check']['point'])) {
         $line .= $th_h . __('保有ポイント', 'wc2') . $th_f;
     }
     if (isset($_REQUEST['check']['registered'])) {
         $line .= $th_h . __('Started date', 'wc2') . $th_f;
     }
     //csmb other
     $oth_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'other');
     if (!empty($oth_keys)) {
         foreach ($oth_keys as $csmb_key) {
             if (isset($_REQUEST['check'][$csmb_key])) {
                 $line .= $th_h . wc2_entity_decode($wc2_options[$csmb_key]['name'], $ext) . $th_f;
             }
         }
     }
     $line .= apply_filters('wc2_filter_chk_mem_label', NULL, $wc2_opt_member, $rows);
     $line .= $tr_f . $lf;
     //---------------------- DATA -----------------------//
     foreach ((array) $rows as $array) {
         $member_id = $array['ID'];
         $data = wc2_get_member_data($member_id);
         //$meta_data = wc2_get_member_data($member_id);
         $line .= $tr_h;
         $line .= $td_h1 . $member_id . $td_f;
         $line .= $td_h . wc2_entity_decode($data['account'], $ext) . $td_f;
         //csmb head
         $hd_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'head');
         if (!empty($hd_keys)) {
             foreach ($hd_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         if (isset($_REQUEST['check']['email'])) {
             $line .= $td_h . wc2_entity_decode($data['email'], $ext) . $td_f;
         }
         //csmb beforename
         $bn_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'beforename');
         if (!empty($bn_keys)) {
             foreach ($bn_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         switch ($applyform) {
             case 'JP':
                 $line .= $td_h . wc2_entity_decode($data['name1'] . ' ' . $data['name2'], $ext) . $td_f;
                 if (isset($_REQUEST['check']['kana'])) {
                     $line .= $td_h . wc2_entity_decode($data['name3'] . ' ' . $data['name4'], $ext) . $td_f;
                 }
                 break;
             default:
                 $line .= $td_h . wc2_entity_decode($data['name2'] . ' ' . $data['name1'], $ext) . $td_f;
                 break;
         }
         //csmb aftername
         $an_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'aftername');
         if (!empty($an_keys)) {
             foreach ($an_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         $address_info = '';
         switch ($applyform) {
             case 'JP':
                 if (isset($_REQUEST['check']['country'])) {
                     $country_code = $data['country'];
                     $member_country = !empty($country_code) ? $locale_options['country'][$country_code] : '';
                     $address_info .= $td_h . $member_country . $td_f;
                 }
                 if (isset($_REQUEST['check']['zipcode'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['zipcode'], $ext) . $td_f;
                 }
                 $address_info .= $td_h . wc2_entity_decode($data['pref'], $ext) . $td_f;
                 $address_info .= $td_h . wc2_entity_decode($data['address1'], $ext) . $td_f;
                 $address_info .= $td_h . wc2_entity_decode($data['address2'], $ext) . $td_f;
                 if (isset($_REQUEST['check']['tel'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['tel'], $ext) . $td_f;
                 }
                 if (isset($_REQUEST['check']['fax'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['fax'], $ext) . $td_f;
                 }
                 break;
             case 'US':
             default:
                 $address_info .= $td_h . wc2_entity_decode($data['address2'], $ext) . $td_f;
                 $address_info .= $td_h . wc2_entity_decode($data['address1'], $ext) . $td_f;
                 $address_info .= $td_h . wc2_entity_decode($data['pref'], $ext) . $td_f;
                 if (isset($_REQUEST['check']['zipcode'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['zipcode'], $ext) . $td_f;
                 }
                 if (isset($_REQUEST['check']['country'])) {
                     $country_code = $data['country'];
                     $member_country = !empty($country_code) ? $locale_options['country'][$country_code] : '';
                     $address_info .= $td_h . $member_country . $td_f;
                 }
                 if (isset($_REQUEST['check']['tel'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['tel'], $ext) . $td_f;
                 }
                 if (isset($_REQUEST['check']['fax'])) {
                     $address_info .= $td_h . wc2_entity_decode($data['fax'], $ext) . $td_f;
                 }
                 break;
         }
         $address_info_args = compact('td_h', 'td_f', 'ext', 'member_id', 'applyform');
         $line .= apply_filters('wc2_filter_mem_csv_address_info', $address_info, $data, $address_info_args);
         //csmb bottom
         $btm_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'bottom');
         if (!empty($btm_keys)) {
             foreach ($btm_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         if (isset($_REQUEST['check']['rank'])) {
             $rank_num = $data['rank'];
             $line .= $td_h . $wc2_options['rank_type'][$rank_num] . $td_f;
         }
         if (isset($_REQUEST['check']['point'])) {
             $line .= $td_h . $data['point'] . $td_f;
         }
         if (isset($_REQUEST['check']['registered'])) {
             $line .= $td_h . $data['registered'] . $td_f;
         }
         //csmb other
         $oth_keys = WC2_Funcs::get_custom_field_keys(WC2_CSMB, 'other');
         if (!empty($oth_keys)) {
             foreach ($oth_keys as $csmb_key) {
                 if (isset($_REQUEST['check'][$csmb_key])) {
                     $meta_value = isset($data[WC2_CUSTOM_MEMBER][$csmb_key]) ? $data[WC2_CUSTOM_MEMBER][$csmb_key] : '';
                     $line .= $td_h . wc2_entity_decode($meta_value, $ext) . $td_f;
                 }
             }
         }
         $line .= apply_filters('wc2_filter_chk_mem_data', NULL, $wc2_opt_member, $member_id, $data);
         $line .= $tr_f . $lf;
     }
     $line .= $table_f . $lf;
     if ($ext == 'xls') {
         header("Content-Type: application/vnd.ms-excel; charset=Shift-JIS");
     } elseif ($ext == 'csv') {
         header("Content-Type: application/octet-stream");
     }
     header("Content-Disposition: attachment; filename=wc2_member_list." . $ext);
     mb_http_output('pass');
     print mb_convert_encoding($line, "SJIS-win", "UTF-8");
     exit;
 }