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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / admin / settings / class-wc-settings-accounts.php
woocommerce / includes / admin / settings Last commit date
views 1 month ago class-wc-settings-accounts.php 5 months ago class-wc-settings-advanced.php 1 month ago class-wc-settings-checkout.php 5 years ago class-wc-settings-emails.php 1 month ago class-wc-settings-general.php 1 month ago class-wc-settings-integrations.php 1 year ago class-wc-settings-page.php 1 week ago class-wc-settings-payment-gateways.php 1 week ago class-wc-settings-point-of-sale.php 3 months ago class-wc-settings-products.php 1 month ago class-wc-settings-shipping.php 3 months ago class-wc-settings-site-visibility.php 2 years ago class-wc-settings-tax.php 5 months ago
class-wc-settings-accounts.php
431 lines
1 <?php
2 /**
3 * WooCommerce Account Settings.
4 *
5 * @package WooCommerce\Admin
6 */
7
8 defined( 'ABSPATH' ) || exit;
9
10 if ( class_exists( 'WC_Settings_Accounts', false ) ) {
11 return new WC_Settings_Accounts();
12 }
13
14 use Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils;
15 use Automattic\WooCommerce\Admin\Features\Features;
16
17 /**
18 * WC_Settings_Accounts.
19 */
20 class WC_Settings_Accounts extends WC_Settings_Page {
21
22 /**
23 * Constructor.
24 */
25 public function __construct() {
26 $this->id = 'account';
27 $this->label = __( 'Accounts &amp; Privacy', 'woocommerce' );
28 parent::__construct();
29 }
30
31 /**
32 * Setting page icon.
33 *
34 * @var string
35 */
36 public $icon = 'people';
37
38 /**
39 * Get settings array.
40 *
41 * @return array
42 */
43 protected function get_settings_for_default_section() {
44
45 $erasure_text = esc_html__( 'account erasure request', 'woocommerce' );
46 $privacy_text = esc_html__( 'privacy page', 'woocommerce' );
47 if ( current_user_can( 'manage_privacy_options' ) ) {
48 if ( version_compare( get_bloginfo( 'version' ), '5.3', '<' ) ) {
49 $erasure_text = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'tools.php?page=remove_personal_data' ) ), $erasure_text );
50 } else {
51 $erasure_text = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'erase-personal-data.php' ) ), $erasure_text );
52 }
53 $privacy_text = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'options-privacy.php' ) ), $privacy_text );
54 }
55
56 $account_settings = array(
57 array(
58 'title' => '',
59 'type' => 'title',
60 'id' => 'account_registration_options',
61 ),
62 array(
63 'title' => __( 'Checkout', 'woocommerce' ),
64 'desc' => __( 'Enable guest checkout (recommended)', 'woocommerce' ),
65 'desc_tip' => __( 'Allows customers to checkout without an account.', 'woocommerce' ),
66 'id' => 'woocommerce_enable_guest_checkout',
67 'default' => 'yes',
68 'type' => 'checkbox',
69 'checkboxgroup' => 'start',
70 'autoload' => false,
71 ),
72 array(
73 'title' => __( 'Login', 'woocommerce' ),
74 'desc' => __( 'Enable log-in during checkout', 'woocommerce' ),
75 'id' => 'woocommerce_enable_checkout_login_reminder',
76 'default' => 'no',
77 'type' => 'checkbox',
78 'checkboxgroup' => 'end',
79 'autoload' => false,
80 ),
81 array(
82 'title' => __( 'Account creation', 'woocommerce' ),
83 'desc' => __( 'After checkout (recommended)', 'woocommerce' ),
84 'desc_tip' => sprintf(
85 /* Translators: %1$s and %2$s are opening and closing <a> tags respectively. */
86 __( 'Customers can create an account after their order is placed. Customize messaging %1$shere%2$s.', 'woocommerce' ),
87 '<a target="_blank" class="delayed-account-creation-customize-link" href="' . esc_url( admin_url( 'site-editor.php?postId=woocommerce%2Fwoocommerce%2F%2Forder-confirmation&postType=wp_template&canvas=edit' ) ) . '">',
88 '</a>'
89 ),
90 'id' => 'woocommerce_enable_delayed_account_creation',
91 'default' => 'no',
92 'type' => 'checkbox',
93 'checkboxgroup' => 'start',
94 'autoload' => false,
95 'custom_attributes' => array(
96 'disabled-tooltip' => __( 'Enable guest checkout to use this feature.', 'woocommerce' ),
97 ),
98 'legend' => __( 'Allow customers to create an account', 'woocommerce' ),
99 ),
100 array(
101 'title' => __( 'Account creation', 'woocommerce' ),
102 'desc' => __( 'During checkout', 'woocommerce' ),
103 'desc_tip' => __( 'Customers can create an account before placing their order.', 'woocommerce' ),
104 'id' => 'woocommerce_enable_signup_and_login_from_checkout',
105 'default' => 'no',
106 'type' => 'checkbox',
107 'checkboxgroup' => '',
108 'autoload' => false,
109 ),
110 array(
111 'title' => __( 'Account creation', 'woocommerce' ),
112 'desc' => __( 'On "My account" page', 'woocommerce' ),
113 'id' => 'woocommerce_enable_myaccount_registration',
114 'default' => 'no',
115 'type' => 'checkbox',
116 'checkboxgroup' => 'end',
117 'autoload' => false,
118 ),
119 array(
120 'title' => __( 'Account creation options', 'woocommerce' ),
121 'desc' => __( 'Send password setup link (recommended)', 'woocommerce' ),
122 'desc_tip' => __( 'New users receive an email to set up their password.', 'woocommerce' ),
123 'id' => 'woocommerce_registration_generate_password',
124 'default' => 'yes',
125 'type' => 'checkbox',
126 'checkboxgroup' => 'start',
127 'autoload' => false,
128 'custom_attributes' => array(
129 'disabled-tooltip' => __( 'Enable an account creation method to use this feature.', 'woocommerce' ),
130 ),
131 ),
132 array(
133 'title' => __( 'Account creation options', 'woocommerce' ),
134 'desc' => __( 'Generate account login (recommended)', 'woocommerce' ),
135 'desc_tip' => __( 'Generate a login for the account using first and/or last name. If neither is usable (e.g. invalid or missing) the email address will be used. If this option is unchecked, customers will need to set a username during account creation', 'woocommerce' ),
136 'id' => 'woocommerce_registration_generate_username',
137 'default' => 'yes',
138 'type' => 'checkbox',
139 'checkboxgroup' => 'end',
140 'autoload' => false,
141 'custom_attributes' => array(
142 'disabled-tooltip' => __( 'Enable an account creation method to use this feature.', 'woocommerce' ),
143 ),
144 ),
145 array(
146 'title' => __( 'Account erasure requests', 'woocommerce' ),
147 'desc' => __( 'Remove personal data from orders on request', 'woocommerce' ),
148 /* Translators: %s URL to erasure request screen. */
149 'desc_tip' => sprintf( esc_html__( 'When handling an %s, should personal data within orders be retained or removed?', 'woocommerce' ), $erasure_text ),
150 'id' => 'woocommerce_erasure_request_removes_order_data',
151 'type' => 'checkbox',
152 'default' => 'no',
153 'checkboxgroup' => 'start',
154 'autoload' => false,
155 ),
156 array(
157 'desc' => __( 'Remove access to downloads on request', 'woocommerce' ),
158 /* Translators: %s URL to erasure request screen. */
159 'desc_tip' => sprintf( esc_html__( 'When handling an %s, should access to downloadable files be revoked and download logs cleared?', 'woocommerce' ), $erasure_text ),
160 'id' => 'woocommerce_erasure_request_removes_download_data',
161 'type' => 'checkbox',
162 'default' => 'no',
163 'checkboxgroup' => '',
164 'autoload' => false,
165 ),
166 array(
167 'title' => __( 'Personal data removal', 'woocommerce' ),
168 'desc' => __( 'Allow personal data to be removed in bulk from orders', 'woocommerce' ),
169 'desc_tip' => __( 'Adds an option to the orders screen for removing personal data in bulk. Note that removing personal data cannot be undone.', 'woocommerce' ),
170 'id' => 'woocommerce_allow_bulk_remove_personal_data',
171 'type' => 'checkbox',
172 'checkboxgroup' => 'end',
173 'default' => 'no',
174 'autoload' => false,
175 ),
176 array(
177 'type' => 'sectionend',
178 'id' => 'account_registration_options',
179 ),
180 array(
181 'title' => __( 'Privacy policy', 'woocommerce' ),
182 'type' => 'title',
183 'id' => 'privacy_policy_options',
184 /* translators: %s: privacy page link. */
185 'desc' => sprintf( esc_html__( 'This section controls the display of your website privacy policy. The privacy notices below will not show up unless a %s is set.', 'woocommerce' ), $privacy_text ),
186 ),
187
188 array(
189 'title' => __( 'Registration privacy policy', 'woocommerce' ),
190 'desc_tip' => __( 'Optionally add some text about your store privacy policy to show on account registration forms.', 'woocommerce' ),
191 'id' => 'woocommerce_registration_privacy_policy_text',
192 /* translators: %s privacy policy page name and link */
193 'default' => sprintf( __( 'Your personal data will be used to support your experience throughout this website, to manage access to your account, and for other purposes described in our %s.', 'woocommerce' ), '[privacy_policy]' ),
194 'type' => 'textarea',
195 'css' => 'min-width: 50%; height: 75px;',
196 ),
197
198 array(
199 'title' => __( 'Checkout privacy policy', 'woocommerce' ),
200 'desc_tip' => __( 'Optionally add some text about your store privacy policy to show during checkout.', 'woocommerce' ),
201 'id' => 'woocommerce_checkout_privacy_policy_text',
202 /* translators: %s privacy policy page name and link */
203 'default' => sprintf( __( 'Your personal data will be used to process your order, support your experience throughout this website, and for other purposes described in our %s.', 'woocommerce' ), '[privacy_policy]' ),
204 'type' => 'textarea',
205 'css' => 'min-width: 50%; height: 75px;',
206 ),
207 array(
208 'type' => 'sectionend',
209 'id' => 'privacy_policy_options',
210 ),
211 array(
212 'title' => __( 'Personal data retention', 'woocommerce' ),
213 'desc' => __( 'Choose how long to retain personal data when it\'s no longer needed for processing. Leave the following options blank to retain this data indefinitely.', 'woocommerce' ),
214 'type' => 'title',
215 'id' => 'personal_data_retention',
216 ),
217 array(
218 'title' => __( 'Retain inactive accounts ', 'woocommerce' ),
219 'desc_tip' => __( 'Inactive accounts are those which have not logged in, or placed an order, for the specified duration. They will be deleted. Any orders will be converted into guest orders.', 'woocommerce' ),
220 'id' => 'woocommerce_delete_inactive_accounts',
221 'type' => 'relative_date_selector',
222 'placeholder' => __( 'N/A', 'woocommerce' ),
223 'default' => array(
224 'number' => '',
225 'unit' => 'months',
226 ),
227 'autoload' => false,
228 ),
229 array(
230 'title' => __( 'Retain pending orders ', 'woocommerce' ),
231 'desc_tip' => __( 'Pending orders are unpaid and may have been abandoned by the customer. They will be trashed after the specified duration.', 'woocommerce' ),
232 'id' => 'woocommerce_trash_pending_orders',
233 'type' => 'relative_date_selector',
234 'placeholder' => __( 'N/A', 'woocommerce' ),
235 'default' => '',
236 'autoload' => false,
237 ),
238 array(
239 'title' => __( 'Retain failed orders', 'woocommerce' ),
240 'desc_tip' => __( 'Failed orders are unpaid and may have been abandoned by the customer. They will be trashed after the specified duration.', 'woocommerce' ),
241 'id' => 'woocommerce_trash_failed_orders',
242 'type' => 'relative_date_selector',
243 'placeholder' => __( 'N/A', 'woocommerce' ),
244 'default' => '',
245 'autoload' => false,
246 ),
247 array(
248 'title' => __( 'Retain cancelled orders', 'woocommerce' ),
249 'desc_tip' => __( 'Cancelled orders are unpaid and may have been cancelled by the store owner or customer. They will be trashed after the specified duration.', 'woocommerce' ),
250 'id' => 'woocommerce_trash_cancelled_orders',
251 'type' => 'relative_date_selector',
252 'placeholder' => __( 'N/A', 'woocommerce' ),
253 'default' => '',
254 'autoload' => false,
255 ),
256 array(
257 'title' => __( 'Retain refunded orders', 'woocommerce' ),
258 'desc_tip' => __( 'Retain refunded orders for a specified duration before anonymizing the personal data within them.', 'woocommerce' ),
259 'id' => 'woocommerce_anonymize_refunded_orders',
260 'type' => 'relative_date_selector',
261 'placeholder' => __( 'N/A', 'woocommerce' ),
262 'default' => array(
263 'number' => '',
264 'unit' => 'months',
265 ),
266 'autoload' => false,
267 ),
268 array(
269 'title' => __( 'Retain completed orders', 'woocommerce' ),
270 'desc_tip' => __( 'Retain completed orders for a specified duration before anonymizing the personal data within them.', 'woocommerce' ),
271 'id' => 'woocommerce_anonymize_completed_orders',
272 'type' => 'relative_date_selector',
273 'placeholder' => __( 'N/A', 'woocommerce' ),
274 'default' => array(
275 'number' => '',
276 'unit' => 'months',
277 ),
278 'autoload' => false,
279 ),
280 array(
281 'type' => 'sectionend',
282 'id' => 'personal_data_retention',
283 ),
284 );
285
286 // Feature requires a block theme. Re-order settings if not using a block theme.
287 if ( ! wp_is_block_theme() ) {
288 $account_settings = array_map(
289 function ( $setting ) {
290 if ( 'woocommerce_enable_signup_and_login_from_checkout' === $setting['id'] ) {
291 $setting['checkboxgroup'] = 'start';
292 $setting['legend'] = __( 'Allow customers to create an account', 'woocommerce' );
293 }
294 return $setting;
295 },
296 $account_settings
297 );
298 $account_settings = array_filter(
299 $account_settings,
300 function ( $setting ) {
301 return 'woocommerce_enable_delayed_account_creation' !== $setting['id'];
302 },
303 );
304 }
305
306 // Change settings when using the block based checkout.
307 if ( CartCheckoutUtils::is_checkout_block_default() ) {
308 $account_settings = array_filter(
309 $account_settings,
310 function ( $setting ) {
311 return 'woocommerce_registration_generate_username' !== $setting['id'];
312 },
313 );
314 $account_settings = array_map(
315 function ( $setting ) {
316 if ( 'woocommerce_registration_generate_password' === $setting['id'] ) {
317 unset( $setting['checkboxgroup'] );
318 }
319 return $setting;
320 },
321 $account_settings
322 );
323 } else {
324 $account_settings = array_map(
325 function ( $setting ) {
326 if ( 'woocommerce_enable_delayed_account_creation' === $setting['id'] ) {
327 $setting['desc_tip'] = sprintf(
328 /* Translators: %1$s and %2$s are opening and closing <a> tags respectively. */
329 __( 'This feature is only available with the Cart & Checkout blocks. %1$sLearn more%2$s.', 'woocommerce' ),
330 '<a href="https://woocommerce.com/document/woocommerce-store-editing/customizing-cart-and-checkout">',
331 '</a>'
332 );
333 $setting['disabled'] = true;
334 $setting['value'] = 0;
335 $setting['custom_attributes']['disabled-tooltip'] = __( 'Your store is using shortcode checkout. Use the Checkout blocks to activate this option.', 'woocommerce' );
336 }
337 return $setting;
338 },
339 $account_settings
340 );
341 }
342
343 /**
344 * Filter account settings.
345 *
346 * @hook woocommerce_account_settings
347 * @since 3.5.0
348 * @param array $account_settings Account settings.
349 */
350 return apply_filters( 'woocommerce_' . $this->id . '_settings', $account_settings );
351 }
352
353 /**
354 * Output the HTML for the settings.
355 */
356 public function output() {
357 parent::output();
358
359 // The following code toggles disabled state on the account options based on other values.
360 $script =
361 '
362 // Move tooltips to label element. This is not possible through the settings field API so this is a workaround
363 // until said API is refactored.
364 document.querySelectorAll("input[disabled-tooltip]").forEach(function(element) {
365 const label = element.closest("label");
366 label.setAttribute("disabled-tooltip", element.getAttribute("disabled-tooltip"));
367 });
368
369 // This handles settings that are enabled/disabled based on other settings.
370 const checkboxes = [
371 document.getElementById("woocommerce_enable_signup_and_login_from_checkout"),
372 document.getElementById("woocommerce_enable_myaccount_registration"),
373 document.getElementById("woocommerce_enable_delayed_account_creation"),
374 document.getElementById("woocommerce_enable_signup_from_checkout_for_subscriptions")
375 ];
376 const inputs = [
377 document.getElementById("woocommerce_registration_generate_username"),
378 document.getElementById("woocommerce_registration_generate_password")
379 ];
380 checkboxes.forEach(cb => cb && cb.addEventListener("change", function() {
381 const isChecked = checkboxes.some(cb => cb && cb.checked);
382 inputs.forEach(input => {
383 if ( ! input ) {
384 return;
385 }
386 input.disabled = !isChecked;
387 });
388 }));
389 checkboxes[0].dispatchEvent(new Event("change")); // Initial state
390
391 // Tracks for customize link.
392 if ( typeof window?.wcTracks?.recordEvent === "function" ) {
393 const customizeLink = document.querySelector("a.delayed-account-creation-customize-link");
394 if ( customizeLink ) {
395 customizeLink.addEventListener("click", function() {
396 window.wcTracks.recordEvent("delayed_account_creation_customize_link_clicked");
397 });
398 }
399 }
400 ';
401
402 // If the checkout block is not default, delayed account creation is always disabled. Otherwise its based on other settings.
403 if ( CartCheckoutUtils::is_checkout_block_default() ) {
404 $script .=
405 '
406 // Guest checkout should toggle off some options.
407 const guestCheckout = document.getElementById("woocommerce_enable_guest_checkout");
408
409 if ( guestCheckout ) {
410 guestCheckout.addEventListener("change", function() {
411 const isChecked = this.checked;
412 const input = document.getElementById("woocommerce_enable_delayed_account_creation");
413 if ( ! input ) {
414 return;
415 }
416 input.disabled = !isChecked;
417 });
418 guestCheckout.dispatchEvent(new Event("change")); // Initial state
419 }
420 ';
421 }
422
423 $handle = 'wc-admin-settings-accounts';
424 wp_register_script( $handle, '', array(), WC_VERSION, array( 'in_footer' => true ) );
425 wp_enqueue_script( $handle );
426 wp_add_inline_script( $handle, $script );
427 }
428 }
429
430 return new WC_Settings_Accounts();
431