Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set WooCommerce DB Update Notice as Actioned
<?php
/**
* Plugin Name: Remove WooCommerce DB Notice
* Plugin URI: https://woocommerce.com
* Description: Clears out any pending WooCommerce DB Update notices
* Author: WooCommerce
* Domain Path: /languages
* Version: 0.1
*/
function woocommerce_set_database_update_notice_as_actioned() {
// Bail if WoocCommerce notes class is not present.
if ( ! class_exists( 'WC_Notes_Run_Db_Update' ) ) {
return;
}
$woocommerce_notes_db = new WC_Notes_Run_Db_Update();
$woocommerce_notes_db->set_notice_actioned();
}
add_action( 'admin_notices', 'woocommerce_set_database_update_notice_as_actioned' );
@wwmummygrab
Copy link

wwmummygrab commented Apr 13, 2020

problem remain there

https://i.imgur.com/Po9Lxzl.png

@timmyc
Copy link
Author

timmyc commented Apr 17, 2020

@wwmummygrab is the notice still showing the wp-admin user interface? I see the database showing the note as actioned which means it should no longer be shown. This snippet doesn't delete the notification from the database, just updates the value of the actioned field.

@wwmummygrab
Copy link

wwmummygrab commented Apr 18, 2020

@pjrobertson
Copy link

pjrobertson commented May 7, 2020

I can confirm that activating this plugin doesn't solve the problem. The database is marked as updated -- if I run wp wc update from the command line using wp-cli, I get:

Success: No updates required. Database version is 4.1.0

However the message still persists after activating this plugin.

@timmyc
Copy link
Author

timmyc commented May 7, 2020

@pjrobertson - just to make certain - the Alert is still being shown in the admin UI? Or the entry is still in the notes table?

The gist here is just to mark the note as actioned, which should then per this code make it not appear in the admin UI.

@pjrobertson
Copy link

pjrobertson commented May 8, 2020

It was still visible in the admin UI. Although 12hrs on the notice seems to have changed to 'WooCommerce database update done'. If I click the 'Thanks' button, I get an error 'Action failed. Please refresh the page and retry.'

I perhaps wouldn't recommend this gist as a fix, it's possible that leaving WooCommerce to run its scripts/do its thing for a set amount of time (depending on database size I guess) first would be wise.

Edit: I can confirm that the note is marked as 'actioned' in the database (select * from $PREFIX_wc_admin_notes), but the message does not go away. Changing the status to 'unactioned' also didn't help.

My issue seems to be the same as that listed here: https://wordpress.org/support/topic/woocommerce-database-update-done/

Note: I am running WP Multisite.

@essmeier
Copy link

essmeier commented Aug 26, 2020

I'm still seeing the message even though the database field is shown as "actioned."

I've worked around it by adding code to my functions.php file:

`// Remove WooCommerce database update done message

add_action( 'admin_head', 'admin_css' );
function admin_css() {
echo "

<style type='text/css'>.is-alert-update {display: none;}</style>

";
}`

@ciprianpentelescu
Copy link

ciprianpentelescu commented May 13, 2022

Easy fix in sql:
update wp_wc_admin_notes SET status='actioned' where name='wc-update-db-reminder';

@smakhalov
Copy link

smakhalov commented May 17, 2022

Easy fix in sql: update wp_wc_admin_notes SET status='actioned' where name='wc-update-db-reminder';

This helped for "WooCommerce database update in progress" message, thanks!

However, I have another one too:
Is there anything similar can be done with "WooCommerce is updating product data in the background" message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment