plugin updates
This commit is contained in:
@@ -11,6 +11,8 @@ if ( class_exists( 'WC_Settings_Accounts', false ) ) {
|
||||
return new WC_Settings_Accounts();
|
||||
}
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils;
|
||||
|
||||
/**
|
||||
* WC_Settings_Accounts.
|
||||
*/
|
||||
@@ -50,8 +52,9 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||
'id' => 'account_registration_options',
|
||||
),
|
||||
array(
|
||||
'title' => __( 'Guest checkout', 'woocommerce' ),
|
||||
'desc' => __( 'Allow customers to place orders without an account', 'woocommerce' ),
|
||||
'title' => __( 'Checkout', 'woocommerce' ),
|
||||
'desc' => __( 'Enable guest checkout (recommended)', 'woocommerce' ),
|
||||
'desc_tip' => __( 'Allows customers to checkout without an account.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_guest_checkout',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
@@ -60,7 +63,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||
),
|
||||
array(
|
||||
'title' => __( 'Login', 'woocommerce' ),
|
||||
'desc' => __( 'Allow customers to log into an existing account during checkout', 'woocommerce' ),
|
||||
'desc' => __( 'Enable log-in during checkout', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_checkout_login_reminder',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
@@ -69,31 +72,38 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||
),
|
||||
array(
|
||||
'title' => __( 'Account creation', 'woocommerce' ),
|
||||
'desc' => __( 'Allow customers to create an account during checkout', 'woocommerce' ),
|
||||
'desc' => __( 'During checkout', 'woocommerce' ),
|
||||
'desc_tip' => __( 'Customers can create an account before placing their order.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_signup_and_login_from_checkout',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'legend' => __( 'Allow customers to create an account:', 'woocommerce' ),
|
||||
'autoload' => false,
|
||||
),
|
||||
array(
|
||||
'title' => __( 'Account creation', 'woocommerce' ),
|
||||
'desc' => __( 'On "My account" page', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_myaccount_registration',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
'autoload' => false,
|
||||
),
|
||||
array(
|
||||
'title' => __( 'Account creation options', 'woocommerce' ),
|
||||
'desc' => __( 'Use email address as account login (recommended)', 'woocommerce' ),
|
||||
'desc_tip' => __( 'If unchecked, customers will need to set a username during account creation.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_registration_generate_username',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'autoload' => false,
|
||||
),
|
||||
array(
|
||||
'desc' => __( 'Allow customers to create an account on the "My account" page', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_myaccount_registration',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
'autoload' => false,
|
||||
),
|
||||
array(
|
||||
'desc' => __( 'When creating an account, automatically generate an account username for the customer based on their name, surname or email', 'woocommerce' ),
|
||||
'id' => 'woocommerce_registration_generate_username',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
'autoload' => false,
|
||||
),
|
||||
array(
|
||||
'desc' => __( 'When creating an account, send the new user a link to set their password', 'woocommerce' ),
|
||||
'title' => __( 'Account creation options', 'woocommerce' ),
|
||||
'desc' => __( 'Send password setup link (recommended)', 'woocommerce' ),
|
||||
'desc_tip' => __( 'New customers receive an email to set up their password.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_registration_generate_password',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
@@ -118,7 +128,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||
'id' => 'woocommerce_erasure_request_removes_download_data',
|
||||
'type' => 'checkbox',
|
||||
'default' => 'no',
|
||||
'checkboxgroup' => 'end',
|
||||
'checkboxgroup' => '',
|
||||
'autoload' => false,
|
||||
),
|
||||
array(
|
||||
@@ -127,7 +137,7 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||
'desc_tip' => __( 'Adds an option to the orders screen for removing personal data in bulk. Note that removing personal data cannot be undone.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_allow_bulk_remove_personal_data',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'checkboxgroup' => 'end',
|
||||
'default' => 'no',
|
||||
'autoload' => false,
|
||||
),
|
||||
@@ -229,10 +239,71 @@ class WC_Settings_Accounts extends WC_Settings_Page {
|
||||
),
|
||||
);
|
||||
|
||||
return apply_filters(
|
||||
'woocommerce_' . $this->id . '_settings',
|
||||
$account_settings
|
||||
);
|
||||
// Change settings when using the block based checkout.
|
||||
if ( CartCheckoutUtils::is_checkout_block_default() ) {
|
||||
$account_settings = array_filter(
|
||||
$account_settings,
|
||||
function ( $setting ) {
|
||||
return 'woocommerce_registration_generate_username' !== $setting['id'];
|
||||
},
|
||||
);
|
||||
$account_settings = array_map(
|
||||
function ( $setting ) {
|
||||
if ( 'woocommerce_registration_generate_password' === $setting['id'] ) {
|
||||
unset( $setting['checkboxgroup'] );
|
||||
}
|
||||
return $setting;
|
||||
},
|
||||
$account_settings
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter account settings.
|
||||
*
|
||||
* @hook woocommerce_account_settings
|
||||
* @since 3.5.0
|
||||
* @param array $account_settings Account settings.
|
||||
*/
|
||||
return apply_filters( 'woocommerce_' . $this->id . '_settings', $account_settings );
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the HTML for the settings.
|
||||
*/
|
||||
public function output() {
|
||||
parent::output();
|
||||
|
||||
// The following code toggles disabled state on the account options based on other values.
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const checkboxes = [
|
||||
document.getElementById("woocommerce_enable_signup_and_login_from_checkout"),
|
||||
document.getElementById("woocommerce_enable_myaccount_registration"),
|
||||
document.getElementById("woocommerce_enable_signup_from_checkout_for_subscriptions")
|
||||
];
|
||||
const inputs = [
|
||||
document.getElementById("woocommerce_registration_generate_username"),
|
||||
document.getElementById("woocommerce_registration_generate_password")
|
||||
];
|
||||
|
||||
function updateInputs() {
|
||||
const isChecked = checkboxes.some(cb => cb && cb.checked);
|
||||
inputs.forEach(input => {
|
||||
if ( ! input ) {
|
||||
return;
|
||||
}
|
||||
input.disabled = !isChecked;
|
||||
input.closest('td').classList.toggle("disabled", !isChecked);
|
||||
});
|
||||
}
|
||||
|
||||
checkboxes.forEach(cb => cb && cb.addEventListener('change', updateInputs));
|
||||
updateInputs(); // Initial state
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user