Change the position of of WooCommerce notices in storefront theme

送分小仙女□ 提交于 2019-12-08 05:22:28

问题


I am trying to change the position of storefront_shop_messages in my Storefront (WooCommerce) child theme. So I have added this code in the functions.php of my active theme:

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

But it doesn't work.


回答1:


The correct way to get what you are expecting in your comments (meaning displaying WooCommerce notices after add to cart button on product single page only):

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 );
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and works on storefront theme with WooCommerce 3.1+



来源:https://stackoverflow.com/questions/46565865/change-the-position-of-of-woocommerce-notices-in-storefront-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!