Skip to content

Instantly share code, notes, and snippets.

@Kodzhesyan
Created March 5, 2023 17:22
Show Gist options
  • Save Kodzhesyan/5bc74837de4a5b51bf18671da5734047 to your computer and use it in GitHub Desktop.
Save Kodzhesyan/5bc74837de4a5b51bf18671da5734047 to your computer and use it in GitHub Desktop.
Отключение полей Checkout
<?
// Отключение обязательности полей
add_filter( 'woocommerce_billing_fields', 'wc_optional_billing_fields', 10, 1 );
function wc_optional_billing_fields( $address_fields ) {
$address_fields['billing_email']['required'] = false;
$address_fields['billing_address_1']['required'] = false;
$address_fields['billing_address_2']['required'] = false;
//$address_fields['billing_mrkvnp_street']['required'] = false;
$address_fields['billing_state']['required'] = false;
//$address_fields['billing_mrkvnp_house']['required'] = false;
$address_fields['billing_mrkvnp_patronymics']['required'] = false; // Делаем Отчество необязательным полем
return $address_fields;
}
// Отключение полей
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_mrkvnp_patronymics']); //Отключаем отчество
//unset($fields['billing']['billing_email']);
//unset($fields['billing']['billing_mrkvnp_street']);
unset($fields['billing']['billing_state']);
//unset($fields['billing']['billing_mrkvnp_house']);
//unset($fields['billing']['billing_mrkvnp_flat']);
//unset($fields['order']['order_comments']);
return $fields;
}
// Меняем порядок полей (https://rudrastyh.com/woocommerce/reorder-checkout-fields.html)
add_filter( 'woocommerce_checkout_fields', 'misha_email_first' );
function misha_email_first( $checkout_fields ) {
$checkout_fields[ 'billing' ][ 'billing_email' ][ 'priority' ] = 27;
$checkout_fields[ 'billing' ][ 'billing_phone' ][ 'priority' ] = 25;
return $checkout_fields;
}
// Отключаем комментарии к заказу в чекауте
add_filter( 'woocommerce_enable_order_notes_field', '__return_false', 9999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment