CODE CODIFY.CLUB

WooCommerce CHEKCKOUT FIELDS PLAY GROUND

// Billing Fields.
add_filter( ‘woocommerce_billing_fields’ , ‘woocommerce_billing_fields_custom’ );
function woocommerce_billing_fields_custom( $fields ) {

$fields[‘billing_phone’][‘required’] = false;
$fields[‘billing_phone’][‘maxlength’] = 10;
$fields[‘billing_state’][‘class’] = array( ‘form-row-first’ );
$fields[‘billing_postcode’][‘maxlength’] = 4;
$fields[‘billing_postcode’][‘class’] = array( ‘form-row-last’ );

//Order Billing fields
$fields[‘billing_email’][‘priority’] = 33;
$fields[‘billing_phone’][‘priority’] = 37;
$fields[‘billing_country’][‘priority’] = 100;

return $fields;

}



// Shipping Fields.

add_filter( ‘woocommerce_shipping_fields’ , ‘woocommerce_shipping_fields_custom’ );

function woocommerce_shipping_fields_custom( $fields ) {

$fields[‘shipping_state’][‘class’] = array( ‘form-row-first’ );
$fields[‘shipping_postcode’][‘maxlength’] = 4;
$fields[‘shipping_postcode’][‘class’] = array( ‘form-row-last’ );

//Order Shipping fields
$fields[‘shipping_country’][‘priority’] = 100;
$fields[‘shipping_country’][‘priority’] = 100;

return $fields;
}

// ———– CHANGE FIELDS PRIORITY EN ——



// ———– UNSET CHECKOUT FIELDS ST ——
add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );
function custom_override_checkout_fields( $fields ) {

/*
unset($fields[‘billing’][‘billing_first_name’]);
unset($fields[‘billing’][‘billing_last_name’]);
unset($fields[‘billing’][‘billing_company’]);
unset($fields[‘billing’][‘billing_address_1’]);
unset($fields[‘billing’][‘billing_address_2’]);
unset($fields[‘billing’][‘billing_city’]);
unset($fields[‘billing’][‘billing_postcode’]);
unset($fields[‘billing’][‘billing_country’]);
unset($fields[‘billing’][‘billing_state’]);
unset($fields[‘billing’][‘billing_email’]);
unset($fields[‘account’][‘account_username’]);
unset($fields[‘account’][‘account_password’]);
unset($fields[‘account’][‘account_password-2’]);
*/

unset($fields[‘billing’][‘billing_phone’]);
unset($fields[‘shipping’][‘shipping_phone’]);
unset($fields[‘order’][‘order_comments’]);

unset($fields[‘billing’][‘billing_email’]);
unset($fields[‘shipping’][‘shipping_email’]);
unset($fields[‘billing’][‘billing_state’]);
unset($fields[‘shipping’][‘shipping_state’]);

return $fields;
}
// ———– UNSET CHECKOUT FIELDS EN ——

V!ral

Developer, Technology aficionado, Beer Lover and founder of codify.club Network. Who shares a keen interest about website development, health issues, cancer awareness and other fun stuff.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed