wc_get_post_data_by_key()
Get an item of post data if set, otherwise return a default value.
No Hooks.
Returns
Mixed. Value sanitized by wc_clean.
Usage
wc_get_post_data_by_key( $key, $default );
- $key(string) (required)
- Meta key.
- $default(string)
- Default value.
Default: ''
Changelog
| Since 3.0.9 | Introduced. |
wc_get_post_data_by_key() wc get post data by key code WC 10.4.3
function wc_get_post_data_by_key( $key, $default = '' ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput, WordPress.Security.NonceVerification.Missing
return wc_clean( wp_unslash( wc_get_var( $_POST[ $key ], $default ) ) );
}