Alternative for the wc_add_to_cart_message hook in Woocommerce for WP

This worked for me

add_filter( 'wc_add_to_cart_message', 'custom_add_to_cart_message' );
function custom_add_to_cart_message() {
    global $woocommerce;

        $return_to  = get_permalink(woocommerce_get_page_id('shop'));
        $message    = sprintf('<a href="%s" class="button wc-forwards">%s</a> %s', $return_to, __('Continue Shopping', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') );
    return $message;
}

Edited: Thanks for the correction Kaarel Kaspar


Woocommerce 2.3+,

    add_filter( 'wc_add_to_cart_message', 'custom_add_to_cart_message' );
    function custom_add_to_cart_message( $message  ){
    global $woocommerce;

    $added_text = __( 'Product was successfully added to your Network Kit.', 'woocommerce' );
    // Output success messages
    if ( get_option( 'woocommerce_cart_redirect_after_add' ) == 'yes' ) :

        $return_to  = apply_filters( 'woocommerce_continue_shopping_redirect', wp_get_referer() ? wp_get_referer() : home_url() );

        $message    = sprintf('<a href="%s" class="button wc-forward">%s</a> %s', $return_to, __( 'Continue Shopping', 'woocommerce' ), $added_text );

    else :

        $message    = sprintf('<a href="%s" class="button wc-forward">%s</a> %s', wc_get_page_permalink( 'cart' ), __( 'View your Network Kit', 'woocommerce' ), $added_text );

    endif;

    return $message;
}

Although this thread is a bit old, I found the link to my same question about deprecated since version 3.0! from the first link on G search engine, so here is what fixed my errors.

Errors:

Notice: The wc_add_to_cart_message filter is deprecated since version 3.0! Use wc_add_to_cart_message_html instead. in /sitepath.com/wp-includes/functions.php on line 4329

Notice: woocommerce_get_page_id is deprecated since version 3.0! Use wc_get_page_id instead. in /sitepath.com/wp-includes/functions.php on line 4329

As you can see the solution is in the problem (error message).

Use wc_add_to_cart_message_html

Use wc_get_page_id instead