How to remove the Last name field from the My Account page in WooCommerce

In most e-commerce businesses, the last name field adds that the only value is that it sometimes simplifies the task of customer address lookup. In any case, we are using whether the address is an office or a non-residential address, the Last Name field ensures that the product reaches the right person, especially in cases where the same employee may share the same name. But what about a fully online business? How many times is the last name field really needed? remove the Last name field.

The My Account page in WooCommerce looks like this:

To hide this field we can add some CSS code (shown below), after submitting the form it will drop a validation error. Therefore, we need to make some further changes to remove the required clause.

.woocommerce-EditAccountForm .woocommerce-form-row--last {
display: none;

The code snippet given below, once entered in the functions.php file of your child theme,

add_filter('woocommerce_save_account_details_required_fields', 'ts_hide_last_name');
function ts_hide_last_name($required_fields)
return $required_fields;

Remove the Last name field.
if you need any field optional please using this code

The code snippet given below, once entered in the functions.php file of your child theme, simple working this code

// Billing and shipping addresses fields
add_filter( 'woocommerce_default_address_fields' , 'codemanHouse_filter_default_address_fields', 20, 1 );
function codemanHouse_filter_default_address_fields( $address_fields ) {
    // Only on checkout page
    if( ! is_checkout() ) return $address_fields;

    // All field keys in this array
    // $key_fields = array('country','first_name','last_name','company','address_1','address_2','city','state','postcode');
    $key_fields = array('last_name','company','state');

    // Loop through each address fields (billing and shipping)
    foreach( $key_fields as $key_field ){
        $address_fields[$key_field]['required'] = false;
    return $address_fields;




Round up cart total Woocommerce

I need to round up prices on my Woocommerce cart. It rounds up to 1. For example:

I believe this is what you’re looking for. This will round your cart total to the next dollar. You can also use WooCommerce settings to round displayed product prices before items are added to the cart.

add_filter( 'woocommerce_calculated_total', 'codemanHouse_calculated_total' );
function codemanHouse_calculated_total( $total ) {
$total = round( $total, 1 );
return ceil($total);