我有一个代码,可以在商品添加到购物车时生成消息。我希望消息上的按钮链接到www.melodylakerart。但我一辈子都不知道如何让它发挥作用。有人能帮忙吗?我相信这只是一个小小的改变。我确信这只是wc\\u get\\u checkout\\u url()位需要更改。但我无法接受纯网址。
感谢您的帮助。把头发扯下来!
function ace_add_to_cart_message_html( $message, $products ) {
$count = 0;
$titles = array();
foreach ( $products as $product_id => $qty ) {
$titles[] = ( $qty > 1 ? absint( $qty ) . \' × \' : \'\' ) . sprintf( _x( \'“%s”\', \'Item name in quotes\', \'woocommerce\' ), strip_tags( get_the_title( $product_id ) ) );
$count += $qty;
}
$titles = array_filter( $titles );
$added_text = sprintf( _n(
\'%s has been added to your cart - pay below, or keep shopping\', // Singular
\'%s has been added to your cart - pay below, or keep shopping\', // Plural
$count, // Number of products added
\'woocommerce\' // Textdomain
), wc_format_list_of_items( $titles ) );
$message = sprintf( \'<a href="%s" class="button wc-forward">%s</a> %s\', esc_url(wc_get_checkout_url () ), esc_html__( \'Keep shopping\', \'woocommerce\' ), esc_html( $added_text ) );
return $message;
}
add_filter( \'wc_add_to_cart_message_html\', \'ace_add_to_cart_message_html\', 10, 2 );