|
@@ -6,7 +6,7 @@ discard block |
|
|
block discarded – undo |
|
6
|
6
|
* @subpackage Customer |
|
7
|
7
|
*/ |
|
8
|
8
|
|
|
9
|
|
-if ( ! defined( 'ABSPATH' ) ) { |
|
|
9
|
+if (!defined('ABSPATH')) { |
|
10
|
10
|
exit; |
|
11
|
11
|
} |
|
12
|
12
|
|
|
@@ -29,31 +29,31 @@ discard block |
|
|
block discarded – undo |
|
29
|
29
|
*/ |
|
30
|
30
|
public function __construct() { |
|
31
|
31
|
/** Create customer entity type on wordpress initilisation */ |
|
32
|
|
- add_action( 'init', array( $this, 'create_customer_entity' ) ); |
|
|
32
|
+ add_action('init', array($this, 'create_customer_entity')); |
|
33
|
33
|
|
|
34
|
34
|
// add_action( 'admin_init', array( $this, 'redirect_new_user' ) ); |
|
35
|
35
|
|
|
36
|
|
- add_filter( 'wp_redirect', array( $this, 'wp_redirect_after_user_new' ), 1 ); |
|
|
36
|
+ add_filter('wp_redirect', array($this, 'wp_redirect_after_user_new'), 1); |
|
37
|
37
|
|
|
38
|
38
|
/** When a wordpress user is created, create a customer (post type) */ |
|
39
|
|
- add_action( 'user_register', array( $this, 'create_entity_customer_when_user_is_created' ) ); |
|
40
|
|
- add_action( 'edit_user_profile_update', array( $this, 'update_entity_customer_when_profile_user_is_update' ) ); |
|
|
39
|
+ add_action('user_register', array($this, 'create_entity_customer_when_user_is_created')); |
|
|
40
|
+ add_action('edit_user_profile_update', array($this, 'update_entity_customer_when_profile_user_is_update')); |
|
41
|
41
|
|
|
42
|
42
|
/** Add filters for customer list */ |
|
43
|
|
- add_filter( 'bulk_actions-edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array( $this, 'customer_list_table_bulk_actions' ) ); |
|
44
|
|
- add_filter( 'manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . '_columns', array( $this, 'list_table_header' ) ); |
|
45
|
|
- add_action( 'manage_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . '_posts_custom_column', array( $this, 'list_table_column_content' ), 10, 2 ); |
|
46
|
|
- add_action( 'restrict_manage_posts', array( &$this, 'list_table_filters' ) ); |
|
47
|
|
- add_filter( 'parse_query', array( &$this, 'list_table_filter_parse_query' ) ); |
|
|
43
|
+ add_filter('bulk_actions-edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array($this, 'customer_list_table_bulk_actions')); |
|
|
44
|
+ add_filter('manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . '_columns', array($this, 'list_table_header')); |
|
|
45
|
+ add_action('manage_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . '_posts_custom_column', array($this, 'list_table_column_content'), 10, 2); |
|
|
46
|
+ add_action('restrict_manage_posts', array(&$this, 'list_table_filters')); |
|
|
47
|
+ add_filter('parse_query', array(&$this, 'list_table_filter_parse_query')); |
|
48
|
48
|
|
|
49
|
49
|
/** Filter search for customers */ |
|
50
|
50
|
//add_filter( 'pre_get_posts', array( $this, 'customer_search' ) ); |
|
51
|
51
|
|
|
52
|
52
|
/** Customer options for the shop */ |
|
53
|
|
- add_action( 'wsphop_options', array( &$this, 'declare_options' ), 8 ); |
|
54
|
|
- add_action( 'wp_ajax_wps_customer_search', array( $this, 'ajax_search_customer' ) ); |
|
|
53
|
+ add_action('wsphop_options', array(&$this, 'declare_options'), 8); |
|
|
54
|
+ add_action('wp_ajax_wps_customer_search', array($this, 'ajax_search_customer')); |
|
55
|
55
|
|
|
56
|
|
- add_action( 'wp_login', array( $this, 'hook_login_for_setting_customer_id' ), 10, 2 ); |
|
|
56
|
+ add_action('wp_login', array($this, 'hook_login_for_setting_customer_id'), 10, 2); |
|
57
|
57
|
} |
|
58
|
58
|
|
|
59
|
59
|
/** |
|
@@ -65,13 +65,13 @@ discard block |
|
|
block discarded – undo |
|
65
|
65
|
* |
|
66
|
66
|
* @return string L'affichage de la lsite déroulanet contenant les clients de la boutique / THe select list of customers |
|
67
|
67
|
*/ |
|
68
|
|
- public static function customer_select( $selected_user = 0, $multiple = false, $disabled = false ) { |
|
|
68
|
+ public static function customer_select($selected_user = 0, $multiple = false, $disabled = false) { |
|
69
|
69
|
$content_output = ''; |
|
70
|
70
|
|
|
71
|
71
|
$wps_customer_mdl = new wps_customer_mdl(); |
|
72
|
72
|
$customers = $wps_customer_mdl->get_customer_list( -1 ); |
|
73
|
73
|
|
|
74
|
|
- require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'common', 'customer', 'select' ) ); |
|
|
74
|
+ require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'common', 'customer', 'select')); |
|
75
|
75
|
|
|
76
|
76
|
return $content_output; |
|
77
|
77
|
} |
|
@@ -82,20 +82,20 @@ discard block |
|
|
block discarded – undo |
|
82
|
82
|
* @param string $user_login le nom d'utilisateur de l'utilisateur actuellement connecté / Username of current connected user. |
|
83
|
83
|
* @param WP_Object $user l'objet WP_User correspond à l'utilisateur actuellement connecté / Current connected user WP_Object definition. |
|
84
|
84
|
*/ |
|
85
|
|
- public function hook_login_for_setting_customer_id( $user_login, $user ) { |
|
86
|
|
- setcookie( 'wps_current_connected_customer', self::get_customer_id_by_author_id( $user->ID ), strtotime( '+30 days' ), SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl() ); |
|
|
85
|
+ public function hook_login_for_setting_customer_id($user_login, $user) { |
|
|
86
|
+ setcookie('wps_current_connected_customer', self::get_customer_id_by_author_id($user->ID), strtotime('+30 days'), SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl()); |
|
87
|
87
|
} |
|
88
|
88
|
|
|
89
|
89
|
/** |
|
90
|
90
|
* AJAX callback for customer search |
|
91
|
91
|
*/ |
|
92
|
92
|
public function ajax_search_customer() { |
|
93
|
|
- check_ajax_referer( 'wps_customer_search' ); |
|
|
93
|
+ check_ajax_referer('wps_customer_search'); |
|
94
|
94
|
|
|
95
|
|
- $term = ! empty( $_GET ) && ! empty( $_GET['term'] ) && is_string( (string) $_GET['term'] ) ? (string) $_GET['term'] : $term; |
|
96
|
|
- $list = $this->search_customer( $term ); |
|
|
95
|
+ $term = !empty($_GET) && !empty($_GET['term']) && is_string((string)$_GET['term']) ? (string)$_GET['term'] : $term; |
|
|
96
|
+ $list = $this->search_customer($term); |
|
97
|
97
|
|
|
98
|
|
- wp_die( wp_json_encode( $list ) ); |
|
|
98
|
+ wp_die(wp_json_encode($list)); |
|
99
|
99
|
} |
|
100
|
100
|
|
|
101
|
101
|
/** |
|
@@ -103,23 +103,23 @@ discard block |
|
|
block discarded – undo |
|
103
|
103
|
* |
|
104
|
104
|
* @param string $term The term we have to search into database for getting existing users / Le terme qu'il faut rechercher pour retrouver les utilisateurs dans la base de données. |
|
105
|
105
|
*/ |
|
106
|
|
- public function search_customer( $term ) { |
|
|
106
|
+ public function search_customer($term) { |
|
107
|
107
|
$users = array(); |
|
108
|
|
- $search_users = new WP_User_Query( array( |
|
109
|
|
- 'search' => '*' . esc_attr( $term ) . '*', |
|
110
|
|
- 'search_columns' => array( 'user_login', 'user_url', 'user_email', 'user_nicename', 'display_name' ), |
|
111
|
|
- ) ); |
|
|
108
|
+ $search_users = new WP_User_Query(array( |
|
|
109
|
+ 'search' => '*' . esc_attr($term) . '*', |
|
|
110
|
+ 'search_columns' => array('user_login', 'user_url', 'user_email', 'user_nicename', 'display_name'), |
|
|
111
|
+ )); |
|
112
|
112
|
$user_query_results = $search_users->get_results(); |
|
113
|
|
- if ( ! empty( $user_query_results ) ) { |
|
114
|
|
- foreach ( $user_query_results as $user ) { |
|
115
|
|
- $users[ $user->ID ]['id'] = $user->ID; |
|
116
|
|
- $users[ $user->ID ]['display_name'] = $user->display_name; |
|
117
|
|
- $users[ $user->ID ]['email'] = $user->user_email; |
|
118
|
|
- $users[ $user->ID ]['last_name'] = $user->last_name; |
|
119
|
|
- $users[ $user->ID ]['first_name'] = $user->first_name; |
|
|
113
|
+ if (!empty($user_query_results)) { |
|
|
114
|
+ foreach ($user_query_results as $user) { |
|
|
115
|
+ $users[$user->ID]['id'] = $user->ID; |
|
|
116
|
+ $users[$user->ID]['display_name'] = $user->display_name; |
|
|
117
|
+ $users[$user->ID]['email'] = $user->user_email; |
|
|
118
|
+ $users[$user->ID]['last_name'] = $user->last_name; |
|
|
119
|
+ $users[$user->ID]['first_name'] = $user->first_name; |
|
120
|
120
|
} |
|
121
|
121
|
} |
|
122
|
|
- $search_users_in_meta = new WP_User_Query( array( |
|
|
122
|
+ $search_users_in_meta = new WP_User_Query(array( |
|
123
|
123
|
'meta_query' => array( |
|
124
|
124
|
'relation' => 'OR', |
|
125
|
125
|
array( |
|
@@ -133,21 +133,21 @@ discard block |
|
|
block discarded – undo |
|
133
|
133
|
'compare' => 'LIKE', |
|
134
|
134
|
), |
|
135
|
135
|
), |
|
136
|
|
- ) ); |
|
|
136
|
+ )); |
|
137
|
137
|
$user_query_results_2 = $search_users_in_meta->get_results(); |
|
138
|
|
- if ( ! empty( $user_query_results_2 ) ) { |
|
139
|
|
- foreach ( $user_query_results_2 as $user ) { |
|
140
|
|
- $users[ $user->ID ]['id'] = $user->ID; |
|
141
|
|
- $users[ $user->ID ]['display_name'] = $user->display_name; |
|
142
|
|
- $users[ $user->ID ]['email'] = $user->user_email; |
|
143
|
|
- $users[ $user->ID ]['last_name'] = $user->last_name; |
|
144
|
|
- $users[ $user->ID ]['first_name'] = $user->first_name; |
|
|
138
|
+ if (!empty($user_query_results_2)) { |
|
|
139
|
+ foreach ($user_query_results_2 as $user) { |
|
|
140
|
+ $users[$user->ID]['id'] = $user->ID; |
|
|
141
|
+ $users[$user->ID]['display_name'] = $user->display_name; |
|
|
142
|
+ $users[$user->ID]['email'] = $user->user_email; |
|
|
143
|
+ $users[$user->ID]['last_name'] = $user->last_name; |
|
|
144
|
+ $users[$user->ID]['first_name'] = $user->first_name; |
|
145
|
145
|
} |
|
146
|
146
|
} |
|
147
|
|
- if ( empty( $users ) ) { |
|
|
147
|
+ if (empty($users)) { |
|
148
|
148
|
$users[] = array( |
|
149
|
149
|
'id' => null, |
|
150
|
|
- 'label' => __( 'Create a new user', 'wpshop' ), |
|
|
150
|
+ 'label' => __('Create a new user', 'wpshop'), |
|
151
|
151
|
); |
|
152
|
152
|
} |
|
153
|
153
|
|
|
@@ -161,13 +161,13 @@ discard block |
|
|
block discarded – undo |
|
161
|
161
|
* |
|
162
|
162
|
* @return int $customer_id |
|
163
|
163
|
*/ |
|
164
|
|
- public static function get_customer_id_by_author_id( $author_id ) { |
|
165
|
|
- if ( ! isset( self::$customer_user_identifier_cache[ $author_id ] ) ) { |
|
166
|
|
- $query = $GLOBALS['wpdb']->prepare( "SELECT ID FROM {$GLOBALS['wpdb']->posts} WHERE post_author = %d AND post_type = %s ORDER BY ID ASC", $author_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
167
|
|
- self::$customer_user_identifier_cache[ $author_id ] = $GLOBALS['wpdb']->get_var( $query ); |
|
|
164
|
+ public static function get_customer_id_by_author_id($author_id) { |
|
|
165
|
+ if (!isset(self::$customer_user_identifier_cache[$author_id])) { |
|
|
166
|
+ $query = $GLOBALS['wpdb']->prepare("SELECT ID FROM {$GLOBALS['wpdb']->posts} WHERE post_author = %d AND post_type = %s ORDER BY ID ASC", $author_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
|
167
|
+ self::$customer_user_identifier_cache[$author_id] = $GLOBALS['wpdb']->get_var($query); |
|
168
|
168
|
} |
|
169
|
169
|
|
|
170
|
|
- return self::$customer_user_identifier_cache[ $author_id ]; |
|
|
170
|
+ return self::$customer_user_identifier_cache[$author_id]; |
|
171
|
171
|
} |
|
172
|
172
|
|
|
173
|
173
|
/** |
|
@@ -178,15 +178,15 @@ discard block |
|
|
block discarded – undo |
|
178
|
178
|
* |
|
179
|
179
|
* @return int |
|
180
|
180
|
*/ |
|
181
|
|
- public static function get_author_id_by_customer_id( $customer_id ) { |
|
182
|
|
- $flipped = ! empty( self::$customer_user_identifier_cache ) ? array_flip( self::$customer_user_identifier_cache ) : ''; |
|
183
|
|
- if ( ! isset( $flipped[ $customer_id ] ) ) { |
|
184
|
|
- $author_id = $GLOBALS['wpdb']->get_var( $GLOBALS['wpdb']->prepare( "SELECT post_author FROM {$GLOBALS['wpdb']->posts} WHERE ID = %d", $customer_id ) ); |
|
185
|
|
- self::$customer_user_identifier_cache[ $author_id ] = $customer_id; |
|
186
|
|
- $flipped[ $customer_id ] = $author_id; |
|
|
181
|
+ public static function get_author_id_by_customer_id($customer_id) { |
|
|
182
|
+ $flipped = !empty(self::$customer_user_identifier_cache) ? array_flip(self::$customer_user_identifier_cache) : ''; |
|
|
183
|
+ if (!isset($flipped[$customer_id])) { |
|
|
184
|
+ $author_id = $GLOBALS['wpdb']->get_var($GLOBALS['wpdb']->prepare("SELECT post_author FROM {$GLOBALS['wpdb']->posts} WHERE ID = %d", $customer_id)); |
|
|
185
|
+ self::$customer_user_identifier_cache[$author_id] = $customer_id; |
|
|
186
|
+ $flipped[$customer_id] = $author_id; |
|
187
|
187
|
} |
|
188
|
188
|
|
|
189
|
|
- return $flipped[ $customer_id ]; |
|
|
189
|
+ return $flipped[$customer_id]; |
|
190
|
190
|
} |
|
191
|
191
|
|
|
192
|
192
|
/** |
|
@@ -194,26 +194,26 @@ discard block |
|
|
block discarded – undo |
|
194
|
194
|
*/ |
|
195
|
195
|
public function create_customer_entity() { |
|
196
|
196
|
global $wpdb; |
|
197
|
|
- $query = $wpdb->prepare( "SELECT P.post_title, PM.meta_value FROM {$wpdb->posts} AS P INNER JOIN {$wpdb->postmeta} AS PM ON (PM.post_id = P.ID) WHERE P.post_name = %s AND PM.meta_key = %s", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, '_wpshop_entity_params' ); |
|
198
|
|
- $customer_entity_definition = $wpdb->get_row( $query ); // WPCS: unprepared sql ok. |
|
199
|
|
- $current_entity_params = ! empty( $customer_entity_definition ) && ! empty( $customer_entity_definition->meta_value ) ? unserialize( $customer_entity_definition->meta_value ) : null; |
|
|
197
|
+ $query = $wpdb->prepare("SELECT P.post_title, PM.meta_value FROM {$wpdb->posts} AS P INNER JOIN {$wpdb->postmeta} AS PM ON (PM.post_id = P.ID) WHERE P.post_name = %s AND PM.meta_key = %s", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, '_wpshop_entity_params'); |
|
|
198
|
+ $customer_entity_definition = $wpdb->get_row($query); // WPCS: unprepared sql ok. |
|
|
199
|
+ $current_entity_params = !empty($customer_entity_definition) && !empty($customer_entity_definition->meta_value) ? unserialize($customer_entity_definition->meta_value) : null; |
|
200
|
200
|
|
|
201
|
201
|
$post_type_params = array( |
|
202
|
202
|
'labels' => array( |
|
203
|
|
- 'name' => __( 'Customers', 'wpshop' ), |
|
204
|
|
- 'singular_name' => __( 'Customer', 'wpshop' ), |
|
205
|
|
- 'add_new_item' => __( 'New customer', 'wpshop' ), |
|
206
|
|
- 'add_new' => __( 'New customer', 'wpshop' ), |
|
207
|
|
- 'edit_item' => __( 'Edit customer', 'wpshop' ), |
|
208
|
|
- 'new_item' => __( 'New customer', 'wpshop' ), |
|
209
|
|
- 'view_item' => __( 'View customer', 'wpshop' ), |
|
210
|
|
- 'search_items' => __( 'Search in customers', 'wpshop' ), |
|
211
|
|
- 'not_found' => __( 'No customer found', 'wpshop' ), |
|
212
|
|
- 'not_found_in_trash' => __( 'No customer founded in trash', 'wpshop' ), |
|
|
203
|
+ 'name' => __('Customers', 'wpshop'), |
|
|
204
|
+ 'singular_name' => __('Customer', 'wpshop'), |
|
|
205
|
+ 'add_new_item' => __('New customer', 'wpshop'), |
|
|
206
|
+ 'add_new' => __('New customer', 'wpshop'), |
|
|
207
|
+ 'edit_item' => __('Edit customer', 'wpshop'), |
|
|
208
|
+ 'new_item' => __('New customer', 'wpshop'), |
|
|
209
|
+ 'view_item' => __('View customer', 'wpshop'), |
|
|
210
|
+ 'search_items' => __('Search in customers', 'wpshop'), |
|
|
211
|
+ 'not_found' => __('No customer found', 'wpshop'), |
|
|
212
|
+ 'not_found_in_trash' => __('No customer founded in trash', 'wpshop'), |
|
213
|
213
|
'parent_item_colon' => '', |
|
214
|
214
|
), |
|
215
|
215
|
'description' => '', |
|
216
|
|
- 'supports' => ! empty( $current_entity_params['support'] ) ? $current_entity_params['support'] : array( 'title' ), |
|
|
216
|
+ 'supports' => !empty($current_entity_params['support']) ? $current_entity_params['support'] : array('title'), |
|
217
|
217
|
'hierarchical' => false, |
|
218
|
218
|
'public' => false, |
|
219
|
219
|
'show_ui' => true, |
|
@@ -238,22 +238,22 @@ discard block |
|
|
block discarded – undo |
|
238
|
238
|
), |
|
239
|
239
|
); |
|
240
|
240
|
|
|
241
|
|
- register_post_type( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $post_type_params ); |
|
|
241
|
+ register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $post_type_params); |
|
242
|
242
|
} |
|
243
|
243
|
|
|
244
|
244
|
/** |
|
245
|
245
|
* Customer options for the shop |
|
246
|
246
|
*/ |
|
247
|
247
|
public static function declare_options() { |
|
248
|
|
- if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) { |
|
249
|
|
- $wpshop_shop_type = ! empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : ''; |
|
250
|
|
- $old_wpshop_shop_type = ! empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : ''; |
|
|
248
|
+ if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') { |
|
|
249
|
+ $wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : ''; |
|
|
250
|
+ $old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : ''; |
|
251
|
251
|
|
|
252
|
|
- if ( ( $wpshop_shop_type == '' || $wpshop_shop_type != 'presentation' ) |
|
253
|
|
- && ( $old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation' ) ) { |
|
|
252
|
+ if (($wpshop_shop_type == '' || $wpshop_shop_type != 'presentation') |
|
|
253
|
+ && ($old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation')) { |
|
254
|
254
|
/** Add module option to wpshop general options */ |
|
255
|
|
- register_setting( 'wpshop_options', 'wpshop_cart_option', array( 'wps_customer_ctr', 'wpshop_options_validate_customers_newsleters' ) ); |
|
256
|
|
- add_settings_field( 'display_newsletters_subscriptions', __( 'Display newsletters subscriptions', 'wpshop' ), array( 'wps_customer_ctr', 'display_newsletters_subscriptions' ), 'wpshop_cart_info', 'wpshop_cart_info' ); |
|
|
255
|
+ register_setting('wpshop_options', 'wpshop_cart_option', array('wps_customer_ctr', 'wpshop_options_validate_customers_newsleters')); |
|
|
256
|
+ add_settings_field('display_newsletters_subscriptions', __('Display newsletters subscriptions', 'wpshop'), array('wps_customer_ctr', 'display_newsletters_subscriptions'), 'wpshop_cart_info', 'wpshop_cart_info'); |
|
257
|
257
|
} |
|
258
|
258
|
} |
|
259
|
259
|
} |
|
@@ -265,7 +265,7 @@ discard block |
|
|
block discarded – undo |
|
265
|
265
|
* |
|
266
|
266
|
* @return array Les réglages des clients qui ont été vérifiés |
|
267
|
267
|
*/ |
|
268
|
|
- public static function wpshop_options_validate_customers_newsleters( $input ) { |
|
|
268
|
+ public static function wpshop_options_validate_customers_newsleters($input) { |
|
269
|
269
|
return $input; |
|
270
|
270
|
} |
|
271
|
271
|
|
|
@@ -273,7 +273,7 @@ discard block |
|
|
block discarded – undo |
|
273
|
273
|
* Affichage des champs permettant les réglages concernant les newsletters des clients dans les réglages de la boutique |
|
274
|
274
|
*/ |
|
275
|
275
|
public static function display_newsletters_subscriptions() { |
|
276
|
|
- $cart_option = get_option( 'wpshop_cart_option', array() ); |
|
|
276
|
+ $cart_option = get_option('wpshop_cart_option', array()); |
|
277
|
277
|
$output = ''; |
|
278
|
278
|
|
|
279
|
279
|
$input_def = array(); |
|
@@ -281,18 +281,18 @@ discard block |
|
|
block discarded – undo |
|
281
|
281
|
$input_def['id'] = 'wpshop_cart_option_display_newsletter_site_subscription'; |
|
282
|
282
|
$input_def['type'] = 'checkbox'; |
|
283
|
283
|
$input_def['valueToPut'] = 'index'; |
|
284
|
|
- $input_def['value'] = ! empty( $cart_option['display_newsletter']['site_subscription'] ) ? $cart_option['display_newsletter']['site_subscription'][0] : 'no'; |
|
|
284
|
+ $input_def['value'] = !empty($cart_option['display_newsletter']['site_subscription']) ? $cart_option['display_newsletter']['site_subscription'][0] : 'no'; |
|
285
|
285
|
$input_def['possible_value'] = 'yes'; |
|
286
|
|
- $output .= wpshop_form::check_input_type( $input_def, 'wpshop_cart_option[display_newsletter][site_subscription]' ) . '<label for="' . $input_def['id'] . '">' . __( 'Newsletters of the site', 'wpshop' ) . '</label><a href="#" title="' . __( 'Check this box if you want display newsletter site subscription', 'wpshop' ) . '" class="wpshop_infobulle_marker">?</a><br>'; |
|
|
286
|
+ $output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[display_newsletter][site_subscription]') . '<label for="' . $input_def['id'] . '">' . __('Newsletters of the site', 'wpshop') . '</label><a href="#" title="' . __('Check this box if you want display newsletter site subscription', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br>'; |
|
287
|
287
|
|
|
288
|
288
|
$input_def = array(); |
|
289
|
289
|
$input_def['name'] = ''; |
|
290
|
290
|
$input_def['id'] = 'wpshop_cart_option_display_newsletter_partner_subscription'; |
|
291
|
291
|
$input_def['type'] = 'checkbox'; |
|
292
|
292
|
$input_def['valueToPut'] = 'index'; |
|
293
|
|
- $input_def['value'] = ! empty( $cart_option['display_newsletter']['partner_subscription'] ) ? $cart_option['display_newsletter']['partner_subscription'][0] : 'no'; |
|
|
293
|
+ $input_def['value'] = !empty($cart_option['display_newsletter']['partner_subscription']) ? $cart_option['display_newsletter']['partner_subscription'][0] : 'no'; |
|
294
|
294
|
$input_def['possible_value'] = 'yes'; |
|
295
|
|
- $output .= wpshop_form::check_input_type( $input_def, 'wpshop_cart_option[display_newsletter][partner_subscription]' ) . '<label for="' . $input_def['id'] . '">' . __( 'Newsletters of the partners', 'wpshop' ) . '</label><a href="#" title="' . __( 'Check this box if you want display newsletter partners subscription', 'wpshop' ) . '" class="wpshop_infobulle_marker">?</a><br>'; |
|
|
295
|
+ $output .= wpshop_form::check_input_type($input_def, 'wpshop_cart_option[display_newsletter][partner_subscription]') . '<label for="' . $input_def['id'] . '">' . __('Newsletters of the partners', 'wpshop') . '</label><a href="#" title="' . __('Check this box if you want display newsletter partners subscription', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br>'; |
|
296
|
296
|
|
|
297
|
297
|
echo $output; // WPCS: XSS ok. |
|
298
|
298
|
} |
|
@@ -304,17 +304,17 @@ discard block |
|
|
block discarded – undo |
|
304
|
304
|
global $pagenow; |
|
305
|
305
|
|
|
306
|
306
|
/* Check current admin page. */ |
|
307
|
|
- if ( $pagenow != 'user-new.php' && isset( $_SESSION['redirect_to_customer'] ) ) { |
|
|
307
|
+ if ($pagenow != 'user-new.php' && isset($_SESSION['redirect_to_customer'])) { |
|
308
|
308
|
$redirect = $_SESSION['redirect_to_customer']; |
|
309
|
|
- unset( $_SESSION['redirect_to_customer'] ); |
|
310
|
|
- if ( $pagenow == 'users.php' ) { |
|
311
|
|
- wp_redirect( admin_url( $redirect, 'http' ) ); |
|
|
309
|
+ unset($_SESSION['redirect_to_customer']); |
|
|
310
|
+ if ($pagenow == 'users.php') { |
|
|
311
|
+ wp_redirect(admin_url($redirect, 'http')); |
|
312
|
312
|
exit; |
|
313
|
313
|
} |
|
314
|
314
|
} |
|
315
|
315
|
|
|
316
|
316
|
/* Redirect to new user */ |
|
317
|
|
- $post_type = ! empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
|
317
|
+ $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
318
|
318
|
if ($pagenow == 'post-new.php' && isset($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) { |
|
319
|
319
|
$_SESSION['redirect_to_customer'] = 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS; |
|
320
|
320
|
wp_redirect(admin_url('user-new.php', 'http'), 301); |
|
@@ -327,15 +327,15 @@ discard block |
|
|
block discarded – undo |
|
327
|
327
|
} |
|
328
|
328
|
} |
|
329
|
329
|
|
|
330
|
|
- public function wp_redirect_after_user_new( $location ) { |
|
|
330
|
+ public function wp_redirect_after_user_new($location) { |
|
331
|
331
|
global $pagenow; |
|
332
|
332
|
|
|
333
|
|
- if ( is_admin() && $pagenow === 'user-new.php' ) { |
|
334
|
|
- $user_details = get_user_by( 'email', $_REQUEST[ 'email' ] ); |
|
|
333
|
+ if (is_admin() && $pagenow === 'user-new.php') { |
|
|
334
|
+ $user_details = get_user_by('email', $_REQUEST['email']); |
|
335
|
335
|
$user_id = $user_details->ID; |
|
336
|
336
|
|
|
337
|
|
- if( $location == 'users.php?update=add&id=' . $user_id ) |
|
338
|
|
- return add_query_arg( array( 'user_id' => $user_id ), 'user-edit.php' ); |
|
|
337
|
+ if ($location == 'users.php?update=add&id=' . $user_id) |
|
|
338
|
+ return add_query_arg(array('user_id' => $user_id), 'user-edit.php'); |
|
339
|
339
|
} |
|
340
|
340
|
|
|
341
|
341
|
return $location; |
|
@@ -353,25 +353,25 @@ discard block |
|
|
block discarded – undo |
|
353
|
353
|
* |
|
354
|
354
|
* @param integer $user_id L'identifiant de l'utilisateur qui vient d'être créé et pour qui on va créer le client. |
|
355
|
355
|
*/ |
|
356
|
|
- public static function create_entity_customer_when_user_is_created( $user_id ) { |
|
357
|
|
- if ( ! is_admin() || strpos( $_SERVER['REQUEST_URI'], 'admin-ajax.php' ) ) { |
|
358
|
|
- $user_data = get_userdata( $user_id ); |
|
359
|
|
- $user_info = array_merge( get_object_vars( $user_data->data ), array_map( 'self::array_map_create_entity_customer_when_user_is_created', get_user_meta( $user_id ) ) ); |
|
360
|
|
- $customer_post_ID = wp_insert_post( array( 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'post_author' => $user_id, 'post_title' => $user_data->user_nicename ) ); |
|
361
|
|
- self::save_customer_synchronize( $customer_post_ID, $user_id, $user_info ); |
|
|
356
|
+ public static function create_entity_customer_when_user_is_created($user_id) { |
|
|
357
|
+ if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) { |
|
|
358
|
+ $user_data = get_userdata($user_id); |
|
|
359
|
+ $user_info = array_merge(get_object_vars($user_data->data), array_map('self::array_map_create_entity_customer_when_user_is_created', get_user_meta($user_id))); |
|
|
360
|
+ $customer_post_ID = wp_insert_post(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'post_author' => $user_id, 'post_title' => $user_data->user_nicename)); |
|
|
361
|
+ self::save_customer_synchronize($customer_post_ID, $user_id, $user_info); |
|
362
|
362
|
|
|
363
|
363
|
/** Change metabox Hidden Nav Menu Definition to display WPShop categories' metabox */ |
|
364
|
|
- $usermeta = get_post_meta( $user_id, 'metaboxhidden_nav-menus', true ); |
|
365
|
|
- if ( ! empty( $usermeta ) && is_array( $usermeta ) ) { |
|
366
|
|
- $data_to_delete = array_search( 'add-wpshop_product_category', $usermeta ); |
|
367
|
|
- if ( false !== $data_to_delete ) { |
|
368
|
|
- unset( $usermeta[ $data_to_delete ] ); |
|
369
|
|
- update_user_meta( $user_id, 'metaboxhidden_nav-menus', $usermeta ); |
|
|
364
|
+ $usermeta = get_post_meta($user_id, 'metaboxhidden_nav-menus', true); |
|
|
365
|
+ if (!empty($usermeta) && is_array($usermeta)) { |
|
|
366
|
+ $data_to_delete = array_search('add-wpshop_product_category', $usermeta); |
|
|
367
|
+ if (false !== $data_to_delete) { |
|
|
368
|
+ unset($usermeta[$data_to_delete]); |
|
|
369
|
+ update_user_meta($user_id, 'metaboxhidden_nav-menus', $usermeta); |
|
370
|
370
|
} |
|
371
|
371
|
} |
|
372
|
372
|
} |
|
373
|
373
|
} |
|
374
|
|
- private static function array_map_create_entity_customer_when_user_is_created( $a ) { |
|
|
374
|
+ private static function array_map_create_entity_customer_when_user_is_created($a) { |
|
375
|
375
|
return $a[0]; |
|
376
|
376
|
} |
|
377
|
377
|
|
|
@@ -380,14 +380,14 @@ discard block |
|
|
block discarded – undo |
|
380
|
380
|
* |
|
381
|
381
|
* @param integer $user_id |
|
382
|
382
|
*/ |
|
383
|
|
- public static function update_entity_customer_when_profile_user_is_update( $user_id ) { |
|
|
383
|
+ public static function update_entity_customer_when_profile_user_is_update($user_id) { |
|
384
|
384
|
$user_data = get_userdata($user_id); |
|
385
|
385
|
$user_info = array_merge(get_object_vars($user_data->data), array_map('self::array_map_create_entity_customer_when_user_is_created', get_user_meta($user_id))); |
|
386
|
386
|
$customer_post_ID = self::get_customer_id_by_author_id($user_id); |
|
387
|
387
|
self::save_customer_synchronize($customer_post_ID, $user_id, $user_info); |
|
388
|
388
|
} |
|
389
|
389
|
|
|
390
|
|
- private static function array_map_update_entity_customer_when_profile_user_is_update( $a ) { |
|
|
390
|
+ private static function array_map_update_entity_customer_when_profile_user_is_update($a) { |
|
391
|
391
|
return $a[0]; |
|
392
|
392
|
} |
|
393
|
393
|
|
|
@@ -396,7 +396,7 @@ discard block |
|
|
block discarded – undo |
|
396
|
396
|
return false; |
|
397
|
397
|
} |
|
398
|
398
|
|
|
399
|
|
- public static function save_customer_synchronize( $customer_post_ID, $user_id, $user_info ) { |
|
|
399
|
+ public static function save_customer_synchronize($customer_post_ID, $user_id, $user_info) { |
|
400
|
400
|
global $wpdb; |
|
401
|
401
|
global $wpshop; |
|
402
|
402
|
$exclude_user_meta = array('user_login', 'user_nicename', 'user_email', 'user_pass', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name'); |
|
@@ -405,7 +405,7 @@ discard block |
|
|
block discarded – undo |
|
405
|
405
|
$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $element_id); |
|
406
|
406
|
$attribute_set_id = $wpdb->get_var($query); |
|
407
|
407
|
$attributes_default = array(); |
|
408
|
|
- if (! empty($attribute_set_id)) { |
|
|
408
|
+ if (!empty($attribute_set_id)) { |
|
409
|
409
|
$group = wps_address::get_addresss_form_fields_by_type($attribute_set_id); |
|
410
|
410
|
foreach ($group as $attribute_sets) { |
|
411
|
411
|
foreach ($attribute_sets as $attribute_set_field) { |
|
@@ -425,10 +425,10 @@ discard block |
|
|
block discarded – undo |
|
425
|
425
|
} |
|
426
|
426
|
} |
|
427
|
427
|
$user_info = array_merge($attributes_default, $user_info); |
|
428
|
|
- add_filter( 'send_password_change_email', array( get_class(), 'prevent_send_mail_from_wordpress' ) ); |
|
|
428
|
+ add_filter('send_password_change_email', array(get_class(), 'prevent_send_mail_from_wordpress')); |
|
429
|
429
|
foreach ($user_info as $user_meta => $user_meta_value) { |
|
430
|
430
|
$attribute_def = wpshop_attributes::getElement($user_meta, "'valid'", 'code'); |
|
431
|
|
- if (! empty($attribute_def)) { |
|
|
431
|
+ if (!empty($attribute_def)) { |
|
432
|
432
|
//Save data in user meta |
|
433
|
433
|
if (in_array($user_meta, $exclude_user_meta)) { |
|
434
|
434
|
if ($user_meta == 'user_pass') { |
|
@@ -444,7 +444,7 @@ discard block |
|
|
block discarded – undo |
|
444
|
444
|
//Save data in attribute tables, ckeck first if exist to know if Insert or Update |
|
445
|
445
|
$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . strtolower($attribute_def->data_type) . ' WHERE entity_type_id = %d AND entity_id = %d AND attribute_id = %d', $element_id, $customer_post_ID, $attribute_def->id); |
|
446
|
446
|
$checking_attribute_exist = $wpdb->get_results($query); |
|
447
|
|
- if (! empty($checking_attribute_exist)) { |
|
|
447
|
+ if (!empty($checking_attribute_exist)) { |
|
448
|
448
|
$wpdb->update( |
|
449
|
449
|
WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . strtolower($attribute_def->data_type), |
|
450
|
450
|
array( |
|
@@ -471,7 +471,7 @@ discard block |
|
|
block discarded – undo |
|
471
|
471
|
} |
|
472
|
472
|
} |
|
473
|
473
|
} |
|
474
|
|
- remove_filter( 'send_password_change_email', array( get_class(), 'prevent_send_mail_from_wordpress' ) ); |
|
|
474
|
+ remove_filter('send_password_change_email', array(get_class(), 'prevent_send_mail_from_wordpress')); |
|
475
|
475
|
} |
|
476
|
476
|
|
|
477
|
477
|
/** |
|
@@ -481,17 +481,17 @@ discard block |
|
|
block discarded – undo |
|
481
|
481
|
* |
|
482
|
482
|
* @return array The new header to display |
|
483
|
483
|
*/ |
|
484
|
|
- public function list_table_header( $current_header ) { |
|
485
|
|
- unset( $current_header['title'] ); |
|
486
|
|
- unset( $current_header['date'] ); |
|
|
484
|
+ public function list_table_header($current_header) { |
|
|
485
|
+ unset($current_header['title']); |
|
|
486
|
+ unset($current_header['date']); |
|
487
|
487
|
|
|
488
|
|
- $current_header['customer_identifier'] = __( 'Customer ID', 'wpshop' ); |
|
489
|
|
- $current_header['customer-name'] = __( 'Customer name', 'wpshop' ); |
|
|
488
|
+ $current_header['customer_identifier'] = __('Customer ID', 'wpshop'); |
|
|
489
|
+ $current_header['customer-name'] = __('Customer name', 'wpshop'); |
|
490
|
490
|
// $current_header['customer_name'] = '<span class="wps-customer-last_name" >' . __('Last-name', 'wpshop') . '</span><span class="wps-customer-first_name" >' . __('First-name', 'wpshop') . '</span>'; |
|
491
|
491
|
// $current_header['customer_email'] = __('E-mail', 'wpshop'); |
|
492
|
|
- $current_header['customer-contacts'] = __( 'Contacts', 'wpshop' ); |
|
493
|
|
- $current_header['customer-orders'] = __( 'Customer last order', 'wpshop' ); |
|
494
|
|
- $current_header['customer_date_subscription'] = __( 'Subscription', 'wpshop' ); |
|
|
492
|
+ $current_header['customer-contacts'] = __('Contacts', 'wpshop'); |
|
|
493
|
+ $current_header['customer-orders'] = __('Customer last order', 'wpshop'); |
|
|
494
|
+ $current_header['customer_date_subscription'] = __('Subscription', 'wpshop'); |
|
495
|
495
|
// $current_header['customer_date_lastlogin'] = __( 'Last login date', 'wpshop' ); |
|
496
|
496
|
|
|
497
|
497
|
return $current_header; |
|
@@ -503,43 +503,43 @@ discard block |
|
|
block discarded – undo |
|
503
|
503
|
* @param string $column THe column identifier to modify output for. |
|
504
|
504
|
* @param integer $post_id The current post identifier. |
|
505
|
505
|
*/ |
|
506
|
|
- public function list_table_column_content( $column, $post_id ) { |
|
|
506
|
+ public function list_table_column_content($column, $post_id) { |
|
507
|
507
|
global $wpdb; |
|
508
|
508
|
|
|
509
|
509
|
/** Get wp_users identifier from customer id */ |
|
510
|
|
- $customer_post_author = self::get_author_id_by_customer_id( $post_id ); |
|
|
510
|
+ $customer_post_author = self::get_author_id_by_customer_id($post_id); |
|
511
|
511
|
|
|
512
|
512
|
/** Get current post informations */ |
|
513
|
|
- $customer_post = get_post( $post_id ); |
|
|
513
|
+ $customer_post = get_post($post_id); |
|
514
|
514
|
|
|
515
|
515
|
/** Switch current column for custom case */ |
|
516
|
516
|
$use_template = true; |
|
517
|
|
- switch ( $column ) { |
|
|
517
|
+ switch ($column) { |
|
518
|
518
|
case 'customer_identifier' : |
|
519
|
519
|
echo $post_id; |
|
520
|
520
|
$use_template = false; |
|
521
|
521
|
break; |
|
522
|
522
|
|
|
523
|
523
|
case 'customer_date_subscription' : |
|
524
|
|
- echo mysql2date( get_option( 'date_format' ), $customer_post->post_date, true ); |
|
|
524
|
+ echo mysql2date(get_option('date_format'), $customer_post->post_date, true); |
|
525
|
525
|
$use_template = false; |
|
526
|
526
|
break; |
|
527
|
527
|
|
|
528
|
528
|
case 'customer_date_lastlogin' : |
|
529
|
|
- $last_login = get_user_meta( $customer_post_author, 'last_login_time', true ); |
|
530
|
|
- if ( ! empty( $last_login ) ) : |
|
531
|
|
- echo mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $last_login, true ); |
|
|
529
|
+ $last_login = get_user_meta($customer_post_author, 'last_login_time', true); |
|
|
530
|
+ if (!empty($last_login)) : |
|
|
531
|
+ echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $last_login, true); |
|
532
|
532
|
else : |
|
533
|
|
- _e( 'Never logged in', 'wpshop' ); |
|
|
533
|
+ _e('Never logged in', 'wpshop'); |
|
534
|
534
|
endif; |
|
535
|
535
|
$use_template = false; |
|
536
|
536
|
break; |
|
537
|
537
|
} |
|
538
|
538
|
|
|
539
|
539
|
/** Require the template for displaying the current column */ |
|
540
|
|
- if ( $use_template ) { |
|
|
540
|
+ if ($use_template) { |
|
541
|
541
|
$template = wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . '/templates/', 'backend', 'customer_listtable/' . $column); |
|
542
|
|
- if ( is_file( $template ) ) { |
|
|
542
|
+ if (is_file($template)) { |
|
543
|
543
|
require $template; |
|
544
|
544
|
} |
|
545
|
545
|
} |
|
@@ -552,23 +552,23 @@ discard block |
|
|
block discarded – undo |
|
552
|
552
|
* |
|
553
|
553
|
* @return array The new action list to use into customer list table |
|
554
|
554
|
*/ |
|
555
|
|
- public function customer_list_table_bulk_actions( $actions ) { |
|
556
|
|
- unset( $actions['edit'] ); |
|
557
|
|
- unset( $actions['trash'] ); |
|
|
555
|
+ public function customer_list_table_bulk_actions($actions) { |
|
|
556
|
+ unset($actions['edit']); |
|
|
557
|
+ unset($actions['trash']); |
|
558
|
558
|
|
|
559
|
559
|
return $actions; |
|
560
|
560
|
} |
|
561
|
561
|
|
|
562
|
562
|
public function list_table_filters() |
|
563
|
563
|
{ |
|
564
|
|
- $post_type = ! empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
|
564
|
+ $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
565
|
565
|
if (isset($post_type)) { |
|
566
|
566
|
if (post_type_exists($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS)) { |
|
567
|
567
|
$filter_possibilities = array(); |
|
568
|
568
|
$filter_possibilities[''] = __('-- Select Filter --', 'wpshop'); |
|
569
|
569
|
$filter_possibilities['orders'] = __('List customers with orders', 'wpshop'); |
|
570
|
570
|
$filter_possibilities['no_orders'] = __('List customers without orders', 'wpshop'); |
|
571
|
|
- echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, (! empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''), '', 'index'); |
|
|
571
|
+ echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, (!empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''), '', 'index'); |
|
572
|
572
|
} |
|
573
|
573
|
} |
|
574
|
574
|
} |
|
@@ -576,9 +576,9 @@ discard block |
|
|
block discarded – undo |
|
576
|
576
|
public function list_table_filter_parse_query($query) |
|
577
|
577
|
{ |
|
578
|
578
|
global $pagenow, $wpdb; |
|
579
|
|
- $post_type = ! empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
580
|
|
- $entity_filter = ! empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
581
|
|
- if (is_admin() && ($pagenow == 'edit.php') && ! empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) && ! empty($entity_filter)) { |
|
|
579
|
+ $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
|
580
|
+ $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
|
581
|
+ if (is_admin() && ($pagenow == 'edit.php') && !empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) && !empty($entity_filter)) { |
|
582
|
582
|
$check = null; |
|
583
|
583
|
switch ($entity_filter) { |
|
584
|
584
|
case 'orders': |
|
@@ -617,7 +617,7 @@ discard block |
|
|
block discarded – undo |
|
617
|
617
|
break; |
|
618
|
618
|
} |
|
619
|
619
|
|
|
620
|
|
- if (! empty($check)) { |
|
|
620
|
+ if (!empty($check)) { |
|
621
|
621
|
$results = $wpdb->get_results($sql_query); |
|
622
|
622
|
$user_id_list = array(); |
|
623
|
623
|
foreach ($results as $item) { |
|
@@ -657,13 +657,13 @@ discard block |
|
|
block discarded – undo |
|
657
|
657
|
public static function quick_add_customer($form) |
|
658
|
658
|
{ |
|
659
|
659
|
$return = 1; |
|
660
|
|
- if (! empty($form)) { |
|
|
660
|
+ if (!empty($form)) { |
|
661
|
661
|
global $wpdb; |
|
662
|
662
|
$customer_type_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
663
|
663
|
$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $customer_type_id); |
|
664
|
664
|
$customer_entity_id = $wpdb->get_var($query); |
|
665
|
665
|
$attributes_set = wpshop_attributes_set::getElement($customer_entity_id); |
|
666
|
|
- $account_attributes = wpshop_attributes_set::getAttributeSetDetails((! empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
|
666
|
+ $account_attributes = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
667
|
667
|
|
|
668
|
668
|
$customer_attributes_to_save = $customer_attributes_to_save_temp = array(); |
|
669
|
669
|
|