質問編集履歴
2
function member_check()の中身を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,6 +24,117 @@
|
|
24
24
|
|
25
25
|
```usceshop.class.php```を直接編集して該当項目を消す等をすれば対応できそうなのですが、できればプラグインファイルを直接触ることはしたくないため、フックで対応を進めたいです。
|
26
26
|
|
27
|
+
### function member_check()の中身
|
28
|
+
|
29
|
+
```php
|
30
|
+
function member_check() {
|
31
|
+
do_action( 'usces_action_before_member_check' );
|
32
|
+
|
33
|
+
$mes = '';
|
34
|
+
$usces_member_old = $_SESSION['usces_member'];
|
35
|
+
foreach ( $_POST['member'] as $key => $vlue ) {
|
36
|
+
if( 'password1' !== $key && 'password2' !== $key ){
|
37
|
+
$_SESSION['usces_member'][$key] = trim($vlue);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
if( $_POST['member_regmode'] == 'newmemberform' || ($_POST['member_regmode'] === 'editmemberform' && !( WCUtils::is_blank($_POST['member']['password1']) && WCUtils::is_blank($_POST['member']['password2']))) ){
|
41
|
+
$mes = $this->get_pwd_errors($_POST['member']['password1']);
|
42
|
+
}
|
43
|
+
|
44
|
+
if ( $_POST['member_regmode'] == 'editmemberform' ) {
|
45
|
+
if ( trim($_POST['member']['password1']) != trim($_POST['member']['password2']) ) {
|
46
|
+
$mes .= __('Password confirm does not match.', 'usces') . "<br />";
|
47
|
+
}
|
48
|
+
if ( !is_email($_POST['member']['mailaddress1']) || WCUtils::is_blank($_POST['member']['mailaddress1']) ) {
|
49
|
+
$mes .= __('e-mail address is not correct', 'usces') . "<br />";
|
50
|
+
} else {
|
51
|
+
$this->get_current_member();
|
52
|
+
$mem_id = $this->current_member['id'];
|
53
|
+
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
|
54
|
+
if( !empty( $id ) && $id != $mem_id ) {
|
55
|
+
$mes .= __( 'This e-mail address can not be registered.', 'usces' ) . "<br />";
|
56
|
+
}
|
57
|
+
}
|
58
|
+
} else if ( $_POST['member_regmode'] == 'newmemberform' ){
|
59
|
+
if ( trim($_POST['member']['password1']) != trim($_POST['member']['password2']) ) {
|
60
|
+
$mes .= __('Password confirm does not match.', 'usces') . "<br />";
|
61
|
+
}
|
62
|
+
if ( !is_email($_POST['member']['mailaddress1']) || WCUtils::is_blank($_POST['member']['mailaddress1']) || WCUtils::is_blank($_POST['member']['mailaddress2']) || trim($_POST['member']['mailaddress1']) != trim($_POST['member']['mailaddress2']) ) {
|
63
|
+
$mes .= __('e-mail address is not correct', 'usces') . "<br />";
|
64
|
+
} else {
|
65
|
+
$id = $this->check_member_email( $_POST['member']['mailaddress1'] );
|
66
|
+
if( !empty( $id ) ) {
|
67
|
+
$mes .= __( 'This e-mail address can not be registered.', 'usces' ) . "<br />";
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}else{
|
71
|
+
$mes .= __('ERROR: I was not able to complete collective operation', 'usces') . "<br />";
|
72
|
+
}
|
73
|
+
if ( WCUtils::is_blank($_POST["member"]["name1"]) ){
|
74
|
+
$mes .= __('Name is not correct', 'usces') . "<br />";
|
75
|
+
}
|
76
|
+
$zip_check = false;
|
77
|
+
$addressform = $this->options['system']['addressform'];
|
78
|
+
$applyform = usces_get_apply_addressform($addressform);
|
79
|
+
if ( $applyform === "JP") {
|
80
|
+
if ( isset( $_POST["member"]["country"] ) ) {
|
81
|
+
if ( $_POST["member"]["country"] === "JP") {
|
82
|
+
$zip_check = true;
|
83
|
+
}
|
84
|
+
} else {
|
85
|
+
$base = usces_get_base_country();
|
86
|
+
if ( $base === "JP") {
|
87
|
+
$zip_check = true;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
$zip_check = apply_filters( 'usces_filter_zipcode_check', $zip_check );
|
92
|
+
if ( WCUtils::is_blank($_POST["member"]["zipcode"]) ) {
|
93
|
+
if ( usces_is_required_field('zipcode') ) {
|
94
|
+
$mes .= __('postal code is not correct', 'usces') . "<br />";
|
95
|
+
}
|
96
|
+
} else {
|
97
|
+
if ( $zip_check ) {
|
98
|
+
if (!preg_match("/^[a-zA-Z0-9]+$/", $_POST["member"]["zipcode"] ) ) {
|
99
|
+
$_SESSION['usces_member']["zipcode"] = usces_convert_zipcode($_POST["member"]["zipcode"]);
|
100
|
+
}
|
101
|
+
if (!preg_match('/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_member']["zipcode"])) {
|
102
|
+
$mes .= __('postal code is not correct', 'usces') . "<br />";
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
if ( $_POST["member"]["pref"] == __('-- Select --', 'usces_dual') && usces_is_required_field('states') ){
|
107
|
+
$mes .= __('enter the prefecture', 'usces') . "<br />";
|
108
|
+
}
|
109
|
+
if ( WCUtils::is_blank($_POST["member"]["address1"]) && usces_is_required_field('address1') ){
|
110
|
+
$mes .= __('enter the city name', 'usces') . "<br />";
|
111
|
+
}
|
112
|
+
if ( WCUtils::is_blank($_POST["member"]["address2"]) && usces_is_required_field('address2') ){
|
113
|
+
$mes .= __('enter house numbers', 'usces') . "<br />";
|
114
|
+
}
|
115
|
+
if ( WCUtils::is_blank($_POST["member"]["tel"]) && usces_is_required_field('tel') ){
|
116
|
+
$mes .= __('enter phone numbers', 'usces') . "<br />";
|
117
|
+
}
|
118
|
+
if( !WCUtils::is_blank($_POST['member']["tel"]) && preg_match("/[^\d\-+]/", trim($_POST["member"]["tel"])) && usces_is_required_field('tel') ){
|
119
|
+
$mes .= __('Please input a phone number with a half size number.', 'usces') . "<br />";
|
120
|
+
}
|
121
|
+
|
122
|
+
if( $_POST['member_regmode'] !== 'editmemberform' && isset( $this->options['agree_member']) && 'activate' === $this->options['agree_member'] ){
|
123
|
+
if( !isset($_POST['agree_member_check']) ){
|
124
|
+
$mes .= __('Please accept the membership agreement.', 'usces') . "<br />";
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
$mes = apply_filters('usces_filter_member_check', $mes);
|
129
|
+
|
130
|
+
if ( $_POST['member_regmode'] == 'editmemberform' && '' != $mes ) {
|
131
|
+
$_SESSION['usces_member'] = $usces_member_old;
|
132
|
+
}
|
133
|
+
|
134
|
+
return $mes;
|
135
|
+
}
|
136
|
+
```
|
137
|
+
|
27
138
|
### バージョン情報
|
28
139
|
|
29
140
|
- PHP 7.4
|
1
丸投げだったため質問内容を変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
【welcart】会員登録時・購入時のお客様情報から
|
1
|
+
【welcart】会員登録時・購入時のお客様情報から住所の必須を外したい
|
test
CHANGED
@@ -1,19 +1,28 @@
|
|
1
|
-
###
|
1
|
+
### やりたいこと
|
2
|
-
welcartで会員登録時・購入時のお客様情報から
|
2
|
+
welcartで会員登録時・購入時のお客様情報から住所の必須を外したい。
|
3
3
|
|
4
|
+
### やったことと質問内容
|
5
|
+
https://analyzegear.co.jp/blog/1207
|
6
|
+
上記の記事で任意項目を必須にする方法は見つかりました。
|
4
|
-
|
7
|
+
こちらを参考に、
|
5
|
-
- 住所全て
|
6
|
-
|
8
|
+
```usces_filter_member_check```
|
7
|
-
|
9
|
+
```usces_filter_customer_check```
|
8
|
-
|
10
|
+
このフックを使用することで必須のコントロールをすることができそうなのですが、デフォで必須になっている項目(今回は住所)を任意にする方法がわかりませんでした。
|
9
11
|
|
10
|
-
### 背景
|
11
|
-
|
12
|
+
プラグインファイルの```classes/usceshop.class.php```の中の```function member_check()```を参考に、とりあえず試しに郵便番号を任意にしようと思い、
|
12
|
-
購入時は住所が必要になるため、会員登録時のみ住所の項目を削除したいです。
|
13
13
|
|
14
|
+
```php
|
15
|
+
add_filter('usces_filter_member_check_fromcart', 'my_filter_customer_check', 10);
|
16
|
+
add_filter('usces_filter_member_check', 'my_filter_customer_check', 10);
|
17
|
+
function my_filter_customer_check() {
|
18
|
+
$zip_check = false;
|
19
|
+
}
|
20
|
+
```
|
14
|
-
|
21
|
+
この内容でfunctions.phpに書いてみたところ、郵便番号以外も全て任意になってしまいました。
|
15
22
|
|
23
|
+
チェックがこの内容で上書きされるため、全て任意になってしまったと推測し、一旦前述の```function member_check()```の中身をそのままコピペしてみたところ、class内の記述のため```$this```が使われており、そこの対処方法がわかりませんでした。
|
24
|
+
|
16
|
-
|
25
|
+
```usceshop.class.php```を直接編集して該当項目を消す等をすれば対応できそうなのですが、できればプラグインファイルを直接触ることはしたくないため、フックで対応を進めたいです。
|
17
26
|
|
18
27
|
### バージョン情報
|
19
28
|
|
@@ -21,3 +30,7 @@
|
|
21
30
|
- WordPress 6.1.1
|
22
31
|
- Welcart e-Commerce 2.8.11
|
23
32
|
- 使用テーマ:EGO for Welcart(バージョン: 1.7)
|
33
|
+
|
34
|
+
### 2/11追記
|
35
|
+
丸投げになってしまっていたため、質問内容を変更しました。
|
36
|
+
必須さえ外れれば後は項目を消すだけになるので、必須の外し方をご教授いただければ幸いです。
|