Example #1
0
 public function member_check($type, $member_id = '')
 {
     global $wpdb;
     //Variable "type" is "order" or "customer" or "delivery" or "member"
     $mes = array();
     $action = '';
     if (is_admin()) {
         if (isset($_POST['addButton'])) {
             $action = 'admin_add';
         } elseif (isset($_POST['upButton'])) {
             $action = 'admin_update';
         }
     } else {
         if (isset($_POST['wcaction'])) {
             if ('register_member' == $_POST['wcaction'] || 'customer_process' == $_POST['wcaction']) {
                 $action = 'front_add';
             } elseif ('update_member' == $_POST['wcaction']) {
                 //カートから編集あとで追加
                 $action = 'front_update';
             }
         }
     }
     if (empty($action)) {
         $mes[] = __('不正なデータが送信されました。', 'wc2');
         return $mes;
     }
     $general = wc2_get_option('general');
     $wc2_db_member = WC2_DB_Member::get_instance();
     $wc2_db_member->get_member_data($member_id);
     $account = $wc2_db_member->get_value('account');
     $email = $wc2_db_member->get_value('email');
     $member_pass_rule_min = $general['member_pass_rule_min'];
     $member_pass_rule_max = $general['member_pass_rule_max'];
     //アカウント
     if (WC2_Utils::is_blank($_POST[$type]['account'])) {
         $mes[] = __('ログインアカウントを入力してください。', 'wc2');
     } elseif (!preg_match("/^[a-zA-Z0-9]+\$/", trim($_POST[$type]['account']))) {
         $mes[] = __('ログインアカウントは半角英数字で入力してください。', 'wc2');
     } else {
         if (isset($_POST[$type]['account']) && trim($_POST[$type]['account']) != $account) {
             $mem_ID = $wc2_db_member->get_member_id_by_account(trim($_POST[$type]['account']));
             if (!empty($mem_ID) && $member_id != $mem_ID) {
                 $mes[] = __('このログインアカウントは既に使用されています。', 'wc2');
             }
         }
     }
     //パスワード
     if ('front_update' == $action) {
         if (!empty($_POST[$type]['passwd']) || !empty($_POST[$type]['passwd2'])) {
             //フロント更新
             if (trim($_POST[$type]['passwd']) != trim($_POST[$type]['passwd2'])) {
                 $mes[] = __('確認用パスワードと異なります。', 'wc2');
             } elseif (!preg_match("/^[a-zA-Z0-9]+\$/", trim($_POST[$type]['passwd']))) {
                 $mes[] = __('ログインパスワードは半角英数字で入力してください。', 'wc2');
             } else {
                 if (!empty($member_pass_rule_max)) {
                     if ($member_pass_rule_min > strlen(trim($_POST[$type]['passwd'])) || strlen(trim($_POST[$type]['passwd'])) > $member_pass_rule_max) {
                         $mes[] = sprintf(__('パスワードは%1$s文字以上%2$s文字以下で入力してください。', 'wc2'), $member_pass_rule_min, $member_pass_rule_max);
                     }
                 } else {
                     if ($member_pass_rule_min > strlen(trim($_POST[$type]['passwd']))) {
                         $mes[] = sprintf(__('パスワードは%s文字以上で入力してください。', 'wc2'), $member_pass_rule_min);
                     }
                 }
             }
         }
     } elseif ('front_add' == $action) {
         //フロント新規登録 (パスワード・パスワード確認項目有)
         if (WC2_Utils::is_blank($_POST[$type]['passwd']) || WC2_Utils::is_blank($_POST[$type]['passwd2'])) {
             $mes[] = __('ログインパスワードを入力してください。', 'wc2');
         } elseif (trim($_POST[$type]['passwd']) != trim($_POST[$type]['passwd2'])) {
             $mes[] = __('確認用パスワードと異なります。', 'wc2');
         } elseif (!preg_match("/^[a-zA-Z0-9]+\$/", trim($_POST[$type]['passwd']))) {
             $mes[] = __('ログインパスワードは半角英数字で入力してください。', 'wc2');
         } else {
             if (!empty($member_pass_rule_max)) {
                 if ($member_pass_rule_min > strlen(trim($_POST[$type]['passwd'])) || strlen(trim($_POST[$type]['passwd'])) > $member_pass_rule_max) {
                     $mes[] = sprintf(__('パスワードは%1$s文字以上%2$s文字以下で入力してください。', 'wc2'), $member_pass_rule_min, $member_pass_rule_max);
                 }
             } else {
                 if ($member_pass_rule_min > strlen(trim($_POST[$type]['passwd']))) {
                     $mes[] = sprintf(__('パスワードは%s文字以上で入力してください。', 'wc2'), $member_pass_rule_min);
                 }
             }
         }
     } elseif ('admin_add' == $action) {
         //管理画面新規 (パスワード有・パスワード確認無し)
         if (WC2_Utils::is_blank($_POST[$type]['passwd'])) {
             $mes[] = __('ログインパスワードを入力してください。', 'wc2');
         } elseif (!preg_match("/^[a-zA-Z0-9]+\$/", trim($_POST[$type]['passwd']))) {
             $mes[] = __('ログインパスワードは半角英数字で入力してください。', 'wc2');
         } else {
             if (!empty($member_pass_rule_max)) {
                 if ($member_pass_rule_min > strlen(trim($_POST[$type]['passwd'])) || strlen(trim($_POST[$type]['passwd'])) > $member_pass_rule_max) {
                     $mes[] = sprintf(__('パスワードは%1$s文字以上%2$s文字以下で入力してください。', 'wc2'), $member_pass_rule_min, $member_pass_rule_max);
                 }
             } else {
                 if ($member_pass_rule_min > strlen(trim($_POST[$type]['passwd']))) {
                     $mes[] = sprintf(__('パスワードは%s文字以上で入力してください。', 'wc2'), $member_pass_rule_min);
                 }
             }
         }
     }
     //メールアドレス&メールアドレス確認項目有
     if (array_key_exists('email', $_POST[$type]) && array_key_exists('email2', $_POST[$type])) {
         if (WC2_Utils::is_blank($_POST[$type]['email']) || WC2_Utils::is_blank($_POST[$type]['email2'])) {
             $mes[] = __('メールアドレスを入力してください。', 'wc2');
         } elseif (trim($_POST[$type]['email']) != trim($_POST[$type]['email2'])) {
             $mes[] = __('確認用メールアドレスと異なります。', 'wc2');
         } elseif (!is_email(trim($_POST[$type]['email']))) {
             $mes[] = __('メールアドレスの値が不正です。', 'wc2');
         } else {
             if (trim($_POST[$type]['email']) != $email) {
                 $mem_ID = $wc2_db_member->get_member_id_by_email($_POST[$type]['email']);
                 if (!empty($mem_ID)) {
                     $mes[] = __('このメールアドレスは既に使用されています。', 'wc2');
                 }
             }
         }
         //メールアドレス項目有 確認無し
     } elseif (array_key_exists('email', $_POST[$type]) && !array_key_exists('email2', $_POST[$type])) {
         if (WC2_Utils::is_blank($_POST[$type]['email'])) {
             $mes[] = __('メールアドレスを入力してください。', 'wc2');
         } elseif (!is_email(trim($_POST[$type]['email']))) {
             $mes[] = __('メールアドレスの値が不正です。', 'wc2');
         } else {
             if (trim($_POST[$type]['email']) != $email) {
                 $mem_ID = $wc2_db_member->get_member_id_by_email($_POST[$type]['email']);
                 if (!empty($mem_ID)) {
                     $mes[] = __('このメールアドレスは既に使用されています。', 'wc2');
                 }
             }
         }
     }
     //氏名
     if (WC2_Utils::is_blank($_POST[$type]['name1']) || WC2_Utils::is_blank($_POST[$type]['name2'])) {
         $mes[] = __('氏名を入力してください。', 'wc2');
     }
     //郵便番号
     if (WC2_Utils::is_blank($_POST[$type]['zipcode'])) {
         $mes[] = __('郵便番号が入力されていません。', 'wc2');
     } elseif (preg_match('/[^\\d-]/', trim($_POST[$type]['zipcode']))) {
         $mes[] = __('郵便番号は半角数字で入力してください。', 'wc2');
     }
     //都道府県
     if (WC2_UNSELECTED == $_POST[$type]['pref']) {
         $mes[] = __('都道府県が選択されていません。', 'wc2');
     }
     //市区町村・番地
     if (WC2_Utils::is_blank($_POST[$type]['address1'])) {
         $mes[] = __('市区町村・番地が入力されていません。', 'wc2');
     }
     //電話番号
     if (WC2_Utils::is_blank($_POST[$type]['tel'])) {
         $mes[] = __('電話番号が入力されていません。', 'wc2');
     } elseif (!WC2_Utils::is_blank($_POST[$type]['tel']) && preg_match('/[^\\d-]/', trim($_POST[$type]['tel']))) {
         $mes[] = __('電話番号は半角数字で入力してください。', 'wc2');
     }
     //FAX番号
     if (!WC2_Utils::is_blank($_POST[$type]['fax']) && preg_match('/[^\\d-]/', trim($_POST[$type]['fax']))) {
         $mes[] = __('FAX番号は半角数字で入力してください。', 'wc2');
     }
     //custom_field check
     $cstm_mes = wc2_custom_field_enter_check($type);
     foreach ($cstm_mes as $cstm_mes_val) {
         $mes[] = $cstm_mes_val;
     }
     $message = apply_filters('wc2_filter_member_check', $mes, $type, $action);
     return $message;
 }
Example #2
0
	/**
	 * Delivery input check
	 *
	 */
	public function delivery_check() {
		$mes = array();
		if( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == 1 ) {
			//氏名
			if ( WC2_Utils::is_blank($_POST['delivery']['name1']) || WC2_Utils::is_blank($_POST['delivery']['name2']) ){
				$mes[] = __('氏名を入力してください。', 'wc2');
			}
			//郵便番号
			if ( WC2_Utils::is_blank($_POST['delivery']['zipcode']) ){
				$mes[] = __('郵便番号が入力されていません。', 'wc2');
			}elseif( preg_match('/[^\d-]/', trim($_POST['delivery']['zipcode'])) ){
				$mes[] = __('郵便番号は半角数字で入力してください。', 'wc2');
			}
			//都道府県
			if ( WC2_UNSELECTED == ($_POST['delivery']['pref']) )
				$mes[] = __('都道府県が選択されていません。', 'wc2');
			//市区町村・番地
			if ( WC2_Utils::is_blank($_POST['delivery']['address1']) )
				$mes[] = __('市区町村・番地が入力されていません。', 'wc2');
			//電話番号
			if( WC2_Utils::is_blank($_POST['delivery']['tel']) ){
				$mes[] = __('電話番号が入力されていません。', 'wc2');
			}elseif( !WC2_Utils::is_blank($_POST['delivery']['tel']) && preg_match('/[^\d]/', trim($_POST['delivery']['tel'])) ){
				$mes[] = __('電話番号は半角数字で入力してください。', 'wc2');
			}
		}
		if( !isset($_POST['offer']['delivery_method']) || (empty($_POST['offer']['delivery_method']) && !WC2_Utils::is_zero($_POST['offer']['delivery_method'])) )
			$mes[] = __('配送方法を選択してください。', 'wc2');
		if( !isset($_POST['offer']['payment_method']) ) {
			$mes[] = __('支払方法を選択してください。', 'wc2');
		} else {
			$entry_data = wc2_get_entry();
			$delivery = wc2_get_option( 'delivery' );
			$general = wc2_get_option( 'general' );
			$payment = wc2_get_payment( $_POST['offer']['payment_method'] );
			if( 'COD' == $payment['settlement'] ) {
				$item_total_price = wc2_get_item_total_price();
				$materials = array(
					'total_price' => $item_total_price,
					'discount' => $entry_data['order']['discount'],
					'shipping_charge' => $entry_data['order']['shipping_charge'],
					'cod_fee' => $entry_data['order']['cod_fee'],
				);
				$item_total_price += wc2_get_tax( $materials );
				$cod_limit_amount = ( isset($general['cod_limit_amount']) && 0 < (int)$general['cod_limit_amount'] ) ? $general['cod_limit_amount'] : 0;
				if( 0 < $cod_limit_amount && $item_total_price > $cod_limit_amount )
					$mes[] = sprintf(__('商品合計金額が、代引きでご購入できる上限額(%s)を超えています。', 'wc2'), wc2_crform( $general['cod_limit_amount'], true, false ));
			}

			$d_method_index = wc2_get_delivery_method_index( (int)$_POST['offer']['delivery_method'] );
			if( $delivery['delivery_method'][$d_method_index]['nocod'] == 1 ) {
				if('COD' == $payment['settlement'])
					$mes[] = __('この配送方法では、代引きはご利用できません。', 'wc2');
			}

			$country = $entry_data['delivery']['country'];
			$local_country = wc2_get_base_country();
			if( $country == $local_country ) {
				if( $delivery['delivery_method'][$d_method_index]['intl'] == 1 ) {
					$mes[] = __('配送方法が誤っています。国際便は指定できません。', 'wc2');
				}
			} else {
				if( WC2_Utils::is_zero($delivery['delivery_method'][$d_method_index]['intl']) ) {
					$mes[] = __('配送方法が誤っています。国際便を指定してください。', 'wc2');
				}
			}
		}
	
		//custom_delivery check
		$csde_mes = wc2_custom_field_enter_check('delivery');
		foreach( $csde_mes as $csde_mes_val ){
			$mes[] = $csde_mes_val;
		}

		//custom_order check
		$csod_mes = wc2_custom_field_enter_check('order');
		foreach( $csod_mes as $csod_mes_val ){
			$mes[] = $csod_mes_val;
		}

		$mes = apply_filters( 'wc2_filter_delivery_check', $mes );
		return $mes;
	}