woocommerce_restored_session_data хук-фильтрWC 9.9.0

Filters the session data when restoring from storage during initialization.

This filter allows you to:

  1. Modify the session data before it's loaded, including adding or removing specific session data entries
  2. Clear the entire session by returning an empty array

Note: If the filtered data is empty, the session will be destroyed and the guest's session cookie will be removed. This can be useful for high-traffic sites that prioritize page caching over maintaining all session data.

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

add_filter( 'woocommerce_restored_session_data', 'wp_kama_woocommerce_restored_session_data_filter' );

/**
 * Function for `woocommerce_restored_session_data` filter-hook.
 * 
 * @param array $session_data The session data loaded from storage.
 *
 * @return array
 */
function wp_kama_woocommerce_restored_session_data_filter( $session_data ){
	// filter...
	return $session_data;
}
$session_data(массив)
The session data loaded from storage.

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

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

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

WC_Session_Handler::restore_session_data()
woocommerce_restored_session_data
woocommerce/includes/class-wc-session-handler.php 271
$this->_data = (array) apply_filters( 'woocommerce_restored_session_data', $session_data );

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

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