How do you make checkout fields optional?

By default, Masteriyo marks specific billing fields as required based on your Settings > Payments > Checkout Fields. If you’d instead let customers skip any of these, you can hook into the masteriyo_checkout_fields filter and clear the required flag.

Example 1: Make all built-in field optional

add_filter( 'masteriyo_checkout_fields', 'make_all_fields_optional', 10, 1 );    

function make_all_fields_optional( $fields ) {    

    foreach ( $fields as $key => &$field ) {    

        // turn off the “required” flag    

        $field['required'] = false;    

    }    

    return $fields;   

}

Example 2: Only make Company and Phone optional

add_filter( 'masteriyo_checkout_fields', 'optional_company_phone', 10, 1 );     
function optional_company_phone( $fields ) {   
    $fields['billing_company']['required'] = false;     
    $fields['billing_phone']['required']   = false;   
        return $fields;    
    }    

All Available Field Keys

Target any of these keys in your filter to change their required status:

KeyLabel
billing_countryCountry
billing_address_1Address line 1
billing_address_2Address line 2
billing_companyCompany name
billing_phonePhone number
billing_cityCity
billing_stateState / Province
billing_postcodePostal / ZIP code
customer_noteOrder notes
attachment_uploadFile upload
gdprGDPR consent checkbox

Hiding fields entirely

If you don’t just want to make a field optional, but remove it from the form:

add_filter( 'masteriyo_checkout_fields', 'remove_postcode_field', 20, 1 );    
function remove_postcode_field( $fields ) {    
    unset( $fields['billing_postcode'] );    
    return $fields;    
}

Tip: This filter runs after Masteriyo’s internal maybe_skip_field() logic so you can override any Settings‑based toggle. Just clear the required (set to false or '') or unset() the key entirely.



Was this article helpful to you?
Give us Rating

Last edited on June 30, 2025.
Edit this page