wc_get_post_data_by_key()WC 3.0.9

Get an item of post data if set, otherwise return a default value.

No Hooks.

Return

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() code WC 8.6.1

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 ) ) );
}