WC_Helper::add_api_error_notice
Adds at most one note signaling that there was an error with the WCCOM API.
Method of the class: WC_Helper{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Helper::add_api_error_notice();
WC_Helper::add_api_error_notice() WC Helper::add api error notice code WC 10.3.3
protected static function add_api_error_notice() {
try {
$data_store = \WC_Data_Store::load( 'admin-note' );
} catch ( Exception $e ) {
return;
}
$note_ids = $data_store->get_notes_with_name( self::NOTE_NAME );
if ( ! empty( $note_ids ) ) {
$current_notice_id = array_shift( $note_ids );
foreach ( $note_ids as $note_id ) {
$note = new Note( $note_id );
if ( $note->get_id() ) {
$data_store->delete( $note );
}
}
$note = new Note( $current_notice_id );
} else {
$note = new Note();
}
$note->set_props(
array(
'title' => __( 'We’re having trouble connecting to WooCommerce.com', 'woocommerce' ),
'content' => __( 'Some subscription data may be temporarily unavailable. Please refresh the page in a few minutes to try again.', 'woocommerce' ),
'type' => Note::E_WC_ADMIN_NOTE_UPDATE,
'name' => self::NOTE_NAME,
'content_data' => (object) array(),
'source' => 'woocommerce-admin',
'status' => Note::E_WC_ADMIN_NOTE_UNACTIONED,
'is_deleted' => false,
)
);
$note->save();
}