• Resolved sirbob77

    (@sirbob77)


    Whenever I try to hide a checkout field, like phone or company, it just moves that field below the last field in the checkout. The custom code I had is no longer working. I’ve removed all checkout plugins and custom code and tried using the customize method to set the phone and company fields to “Hidden”, but it just moves those fields to the bottom for some reason. This has only started happening after the recent updates.

    Any help would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • con

    (@conschneider)

    Engineer

    Hi there,

    This should be a straightforward task with something such as:

    // Hook in
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    
    // Remove the order comments field
    function custom_override_checkout_fields( $fields ) {
         unset($fields['order']['order_comments']);
    
         return $fields;
    }
    

    Based on: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

    I am marking this as resolved, but feel free to follow up or open a new thread anytime.

    Thread Starter sirbob77

    (@sirbob77)

    Thanks. I have attempted this, but it says, “Your PHP code changes were rolled back due to an error on line 78 of file wp-content/themes/bridge/framework/modules/woocommerce/woocommerce-config.php. Please fix and try saving again.

    Cannot redeclare custom_override_checkout_fields() (previously declared in wp-content/themes/bridge-child/functions.php:12)”

    The file that is mentioned, on line 78, has the following:

    function custom_override_checkout_fields($fields) {
    //billing fields
    $args_billing = array(
    ‘first_name’ => __(‘First name’,’qode’),
    ‘last_name’ => __(‘Last name’,’qode’),
    ‘company’ => __(‘Company name’,’qode’),
    ‘address_1’ => __(‘Address’,’qode’),
    ’email’ => __(‘Email’,’qode’),
    ‘phone’ => __(‘Phone’,’qode’),
    ‘postcode’ => __(‘Postcode / ZIP’,’qode’),
    ‘city’ => __(‘Town / City’,’qode’),
    ‘state’ => __(‘State’,’qode’)
    );

    //shipping fields
    $args_shipping = array(
    ‘first_name’ => __(‘First name’,’qode’),
    ‘last_name’ => __(‘Last name’,’qode’),
    ‘company’ => __(‘Company name’,’qode’),
    ‘address_1’ => __(‘Address’,’qode’),
    ‘postcode’ => __(‘Postcode / ZIP’,’qode’),
    ‘city’ => __(‘Town / City’,’qode’),
    ‘state’ => __(‘State’,’qode’)
    );

    //override billing placeholder values
    foreach ($args_billing as $key => $value) {
    $fields[“billing”][“billing_{$key}”][“placeholder”] = $value;
    }

    //override shipping placeholder values
    foreach ($args_shipping as $key => $value) {
    $fields[“shipping”][“shipping_{$key}”][“placeholder”] = $value;
    }

    return $fields;
    }

    Is there a means of working around this?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Checkout Fields Not Removing’ is closed to new replies.