woocommerce_get_default_value_for_(key)
Allow providing a default value for additional fields if no value is already set.
Использование
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(строка)
- The group of this key (shipping|billing|other).
- $wc_object(WC_Data)
- The object to get the field value for.
Список изменений
С версии 8.9.0 | Введена. |
Где вызывается хук
woocommerce_get_default_value_for_(key)
woocommerce/src/Blocks/Domain/Services/CheckoutFields.php 1135
$value = apply_filters( "woocommerce_get_default_value_for_{$key}", null, $group, $wc_object );