在弹出窗口中显示WooCommerce通知

时间:2019-11-08 18:06:33

标签: wordpress woocommerce wordpress-hook

如何在弹出的所有wc_add_notice呼叫中显示自定义WooCommerce通知?

if (!$product_data -> is_started()) {
    wc_add_notice(sprintf(__('Sorry, the auction for "%s" has not started yet', 'wc_simple_auctions'), $product_data -> get_title()),'error');
    return false;
}

// Stock check - only check if we're managing stock and backorders are not allowed
if (!$product_data -> is_in_stock()) {
    wc_add_notice(sprintf(__('You cannot place a bid for "%s" because the product is out of stock.', 'wc_simple_auctions'), $product_data -> get_title()),'error');
    return false;
}

1 个答案:

答案 0 :(得分:0)

您需要查看主题中的wc_print_notices位置。在主题中,您可能需要用容器包装wc_print_notices,以容纳灯箱/弹出窗口来控制其显示。