woocommerce_get_default_value_for_(key) 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_(key)', 'wp_kama_woocommerce_get_default_value_for_key_filter', 10, 3 );

/**
 * Function for `woocommerce_get_default_value_for_(key)` 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_key_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_field_from_object()
woocommerce_get_default_value_for_(key)
woocommerce/src/Blocks/Domain/Services/CheckoutFields.php 1130
$value = apply_filters( "woocommerce_get_default_value_for_{$key}", null, $group, $wc_object );

Where the hook is used in WooCommerce

Usage not found.