WooCommerce Notice Messages, how do I edit them?

前端 未结 5 1487
别那么骄傲
别那么骄傲 2021-02-01 05:40

I\'m trying to figure out where WooCommerce creates it\'s messages for when there is a success, error or notice in WooCommerce. I want to edit those messages to fit the scenario

5条回答
  •  不知归路
    2021-02-01 06:22

    Open the plugin files and search for wc_add_notice:

    This function has a filter:

    apply_filters( 'woocommerce_add_' . $notice_type, $message );
    

    The $notice_type is the second argument passed in all those occurrences.

    Using something like this should work:

    add_filter( 'woocommerce_add_error', function( $message ) {
        if( $message == 'Some message' )
            $message = '';
    
        return $message;
    });
    

提交回复
热议问题