• Resolved angelvolos

    (@angelvolos)


    Hello there,

    When a customer is about to complete an order with PayPal as the payment option, it will never proceed because it asks for the ‘Billing Company Name’ field to be filled, even though I’ve set this field to be optional. If the customer selects any other payment method than PayPal, the order goes through without requiring to fill the ‘Billing Company Name’ field.

    I’ve tried adding the custom code shown below:

    add_filter( 'woocommerce_default_address_fields' , 'make_company_field_optional', 90, 1);
    function make_company_field_optional( $address_fields ) {
         $address_fields['company']['required'] = false;
    
         return $address_fields;
    }

    But it does absolutely nothing. I also tested to make other fields REQUIRED and it does work, so for some reason it won’t take the company name field as optional.

    Note for the code part:
    I also tried other filters such as woocommerce_billing_fields, woocommerce_shipping_fields and woocommerce_checkout_fields but it didn’t help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @angelvolos

    I don’t believe this is a bug with the plugin. Here is a screenshot showing a basic WooCommerce install with the PayPal plugin and the company name field blank and no notice is shown. In the screenshot, you can see that the PayPal popup opened, despite the company name field being blank.

    The filter you want to use is called woocommerce_checkout_fields. Your code isn’t working because it’s not targeting the correct key name for the field. Here is an example of what you would want to do:

    Example:

    add_filter('woocommerce_checkout_fields', function($fields){
    	$fields['billing']['billing_company']['required'] = false;
    	return $fields;
    });

    Kind Regards

    Thread Starter angelvolos

    (@angelvolos)

    You are correct indeed, it works now!

    Thanks and sorry for the late reply!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Billing Company Field is Required Bug’ is closed to new replies.