1

我正在尝试更改 Storefront_shop_messages 在我的 Storefront (WooCommerce) 子主题中的位置。所以我在我的活动主题的functions.php中添加了这段代码:

remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
add_action('woocommerce_product_meta_end', 'storefront_shop_messages', 1 );

但它不起作用。

4

1 回答 1

1

在评论中获得您所期望的正确方法(意味着仅在产品单页上的添加到购物车按钮后显示 WooCommerce 通知):

add_action( 'wp_head', 'customize_notices' );
function customize_notices(){
    if( is_product() )
        remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
    remove_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
    add_action( 'woocommerce_single_product_summary', 'woocommerce_before_main_content', 34 );
}

代码在您的活动子主题(或主题)的 function.php 文件中或任何插件文件中。

使用 WooCommerce 3.1+ 测试和处理店面主题

于 2017-10-06T11:41:40.433 回答