Alternative for the wc_add_to_cart_message hook in Woocommerce for WP

后端 未结 5 519
轮回少年
轮回少年 2020-12-17 00:48

I used the add to cart message hook in Woocommerce to edit the text and remove some classes from certain buttons. It seems this hook is now deprecated in Woocommerce 2.1 and

5条回答
  •  旧时难觅i
    2020-12-17 01:05

    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('%s %s', $return_to, __('Continue Shopping', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') );
        return $message;
    }
    

    Edited: Thanks for the correction Kaarel Kaspar

提交回复
热议问题