0
Hi WooCommerce ninjas!隱藏/更改WooCommerce管理員通知
我正在開發WooCommerce插件,每當我提交表單(保存更改按鈕)在頂部顯示更新通知'您的設置已保存。'。如何隱藏或更改此通知,我使用woocommerce_show_admin_notice
過濾器,但不能在我的插件類中使用。以下是我的插件中的代碼的一部分。任何想法鉤誰會是有用的?
非常感謝!
<?php
class name_of_plugin extends WC_Payment_Gateway {
public $error = '';
// Setup our Gateway's id, description and other values
function __construct() {
$this->id = "name_of_plugin";
$this->method_title = __("Name", 'domain');
$this->method_description = __("Gateway Plug-in for WooCommerce", 'domain');
$this->title = __("TFS VPOS", 'domain');
$this->icon = null;
$this->has_fields = false;
$this->init_settings();
$this->init_form_fields();
$this->title = $this->get_option('title');
$this->testurl = 'https://example.com/payment/api';
$this->liveurl = 'https://example.com/payment/api';
// Save settings
if (is_admin()) {
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
}
// Disable Admin Notice
add_filter('woocommerce_show_admin_notice', array($this, 'shapeSpace_custom_admin_notice'), 10, 2);
// add the filter
add_filter('woocommerce_add_error', array($this, 'filter_woocommerce_add_notice_type'), 10, 1);
} // End __construct()
// display custom admin notice
public function filter_woocommerce_add_notice_type($true, $notice) {
// magic happen here...
return $true;
}
感謝您幫助@Reigel,實際上我使用css來隱藏無用部分,然後擴展了'display_notice'方法來繪製錯誤。 – htmlbrewery