. , :
2.1- "wc_add_to_cart_message"
add_filter( 'wc_add_to_cart_message', 'foo' );
function foo() {
$product_id = $_REQUEST[ 'product_id' ];
if ( is_array( $product_id ) ) {
$titles = array();
foreach ( $product_id as $id ) {
$titles[] = get_the_title( $id );
}
$added_text = sprintf( __( 'Added "%s" to your cart.', 'woocommerce' ), join( __( '" and "', 'woocommerce' ), array_filter( array_merge( array( join( '", "', array_slice( $titles, 0, -1 ) ) ), array_slice( $titles, -1 ) ) ) ) );
} else {
$added_text = sprintf( __( '"%s" was successfully added to your cart.', 'woocommerce' ), get_the_title( $product_id ) );
}
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="alert-link">%s →</a> %s',
$return_to, __( 'Continue Shopping', 'woocommerce' ),
$added_text
);
else :
$message = sprintf(
'<a href="%s" class="alert-link">%s →</a> %s',
get_permalink( wc_get_page_id( 'cart' ) ),
__( 'View Cart', 'woocommerce' ),
$added_text );
endif;
return $message;
}
, .