Skip to content

Instantly share code, notes, and snippets.

@timmyc
Created April 10, 2020 21:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timmyc/ee0c6f4cb3ed82620efaa16386e62c6b to your computer and use it in GitHub Desktop.
Save timmyc/ee0c6f4cb3ed82620efaa16386e62c6b to your computer and use it in GitHub Desktop.
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' );
@pjrobertson
Copy link

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

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

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

@smakhalov
Copy link

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?

@crishnakh
Copy link

To hide the coupons notices the name on table xx_wc_admin_notes is 'wc-admin-coupon-page-moved' ;)

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