WC_Helper::get_notices()
Retrieve notice for connected store.
Method of the class: WC_Helper{}
No Hooks.
Return
Array
. An array containing notice data.
Usage
$result = WC_Helper::get_notices();
WC_Helper::get_notices() WC Helper::get notices code WC 9.3.1
public static function get_notices() { $cache_key = '_woocommerce_helper_notices'; $cached_data = get_transient( $cache_key ); if ( false !== $cached_data ) { return $cached_data; } // Fetch notice data for connected store. $request = WC_Helper_API::get( 'notices', array( 'authenticated' => true, ) ); if ( 200 !== wp_remote_retrieve_response_code( $request ) ) { set_transient( $cache_key, array(), 15 * MINUTE_IN_SECONDS ); return array(); } $data = json_decode( wp_remote_retrieve_body( $request ), true ); if ( empty( $data ) || ! is_array( $data ) ) { $data = array(); } set_transient( $cache_key, $data, 1 * HOUR_IN_SECONDS ); return $data; }