woocommerce_customer_allowed_session_meta_keys хук-фильтрWC 8.7.0

Filter the allowed session meta data keys.

If the customer object contains any meta data with these keys, it will be stored within the WooCommerce session.

Использование

add_filter( 'woocommerce_customer_allowed_session_meta_keys', 'wp_kama_woocommerce_customer_allowed_session_meta_keys_filter', 10, 2 );

/**
 * Function for `woocommerce_customer_allowed_session_meta_keys` filter-hook.
 * 
 * @param array       $allowed_keys The allowed meta data keys.
 * @param WC_Customer $customer     The customer object.
 *
 * @return array
 */
function wp_kama_woocommerce_customer_allowed_session_meta_keys_filter( $allowed_keys, $customer ){

	// filter...
	return $allowed_keys;
}
$allowed_keys(массив)
The allowed meta data keys.
$customer(WC_Customer)
The customer object.

Список изменений

С версии 8.7.0 Введена.

Где вызывается хук

WC_Customer_Data_Store_Session::save_to_session()
woocommerce_customer_allowed_session_meta_keys
woocommerce/includes/data-stores/class-wc-customer-data-store-session.php 97
$allowed_keys  = apply_filters( 'woocommerce_customer_allowed_session_meta_keys', array(), $customer );

Где используется хук в WooCommerce

woocommerce/src/Blocks/Domain/Services/CheckoutFields.php 229
add_filter( 'woocommerce_customer_allowed_session_meta_keys', array( $this, 'add_session_meta_keys' ) );