user9739520
user9739520

Reputation:

Add custom notification when add & edit product in woocommerce admin

I need to display my custom notification in woocommerce product add page above the Product name.

Review below screen. Below marked section I need to show custom message.

Upvotes: 1

Views: 1190

Answers (2)

Akshay Shah
Akshay Shah

Reputation: 3504

Try with below code

function general_admin_notice() {
    global $pagenow;

    if ($pagenow == 'post-new.php' || $pagenow == 'edit.php' || $pagenow == 'post.php') {
        if ('product' === get_post_type($_GET['post'])) {
            echo '<div class="notice notice-warning is-dismissible">
            <p>This notice appears on the settings page.</p>
            </div>';
        }
    }
}
add_action('admin_notices', 'general_admin_notice');

Upvotes: 3

Chirag Rathore
Chirag Rathore

Reputation: 328

function filter_post_updated_messages( $message ) { 
  /***
  echo '<pre>';
  print_r($message['product']);
  echo '</pre>'; 
  ***/

  $publish_msg = $message['product'][6];
  $publish_msg = str_replace('Product published.', 'Hi Great your new product published.', $publish_msg);
  $message['product'][6] = $publish_msg;
  return $message; 
};          
add_filter( 'post_updated_messages', 'filter_post_updated_messages', 30, 1 ); 

Upvotes: 1

Related Questions