• Resolved manx89

    (@manx89)


    Hi I have this code in function.php

    add_filter( 'woocommerce_billing_fields' , 'make_order_notes_required_field' );
    function make_order_notes_required_field( $fields ) {
        // Set in the array your targeted product category term(s)
        $categories = array("company");
    
        if ( is_product_category_terms_in_cart( $categories ) ) {
            $fields['billing_company']['required'] = true;
        }
        return $fields;
    }

    It make Company name field required when “company” category product is in cart. And it works fine. But when I instaled your plugin (to add custom field) code stopped working. I tried “_billing_company” meta but without succes. How to make it work again with your plugin?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Tomasz WP Desk

    (@tomaszwp)

    Hello @manx89

    I am afraid it is not possible to combine both elements.
    The fields in our plugin are either required or optional. There is no function to change this setting based on the selected condition. So this custom code will be overwritten.

    We cannot guarantee that the plugin will be compatible with custom codes.

    Plugin Support Tomasz WP Desk

    (@tomaszwp)

    I am marking this topic as resolved as we have not received any new replies.

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

The topic ‘Make field required’ is closed to new replies.