woocommerce_get_default_value_for_(missing_field)
Allow providing a default value for additional fields if no value is already set.
Использование
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(строка)
- 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_(missing_field)
woocommerce/src/Blocks/Domain/Services/CheckoutFields.php 1314
$value = apply_filters( "woocommerce_get_default_value_for_{$missing_field}", null, $group, $wc_object );