woocommerce_get_default_value_for_(missing_field) filter-hookWC 8.9.0

Allow providing a default value for additional fields if no value is already set.

Usage

add_filter( 'woocommerce_get_default_value_for_(missing_field)', 'wp_kama_woocommerce_get_default_value_for_missing_field_filter', 10, 3 );

/**
 * Function for `woocommerce_get_default_value_for_(missing_field)` filter-hook.
 * 
 * @param null    $value     The default value for the filter, always null.
 * @param string  $group     The group of this key (shipping|billing|other).
 * @param WC_Data $wc_object The object to get the field value for.
 *
 * @return null
 */
function wp_kama_woocommerce_get_default_value_for_missing_field_filter( $value, $group, $wc_object ){

	// filter...
	return $value;
}
$value(null)
The default value for the filter, always null.
$group(string)
The group of this key (shipping|billing|other).
$wc_object(WC_Data)
The object to get the field value for.

Changelog

Since 8.9.0 Introduced.

Where the hook is called

CheckoutFields::get_all_fields_from_object()
woocommerce_get_default_value_for_(missing_field)
woocommerce/src/Blocks/Domain/Services/CheckoutFields.php 1188
$value = apply_filters( "woocommerce_get_default_value_for_{$missing_field}", null, $group, $wc_object );

Where the hook is used in WooCommerce

Usage not found.