我不确定到底该怎么做,是的,我已经在网上到处找了.我确实找到了各种解决方案,但它们都不允许我有限的经验独自解决这个问题.
我需要的是:
"您刚刚在购物车中添加了数量产品名称.您的订单小计是小计.要 checkout 还是要继续购物?按钮|按钮"
因此,为了进一步解释它: "您刚刚在购物车中添加了3个蓝牙耳机.您的订单小计为299美元.您想 checkout 还是想继续购物?继续|转到 checkout "
换句话说,它应该计算添加了多少产品,并应该显示小计.在右侧,"继续"按钮链接到store 页面," checkout "按钮链接到" checkout "页面.
现在--这就是我的问题所在.. 在手机上时,总体布局有点混乱,所以我决定做一个相同的两个版本,允许文本和按钮以不同的方式对齐/放置.
这是我的代码,我肯定它来自其他地方--但我尽了最大努力修改它,尽我最大努力让它正常工作.
如果有人能帮帮我--谢谢!
add_filter( 'wc_add_to_cart_message_html', 'atcm_with_checkout_button_including_mobile_control', 10, 3 );
function atcm_with_checkout_button_including_mobile_control( $message, $qty, $count ) {
$subtotal = wc_price(WC()->cart->subtotal);
$count += $qty;
$direct_to_shop = wc_get_shop_url();
$direct_checkout = is_checkout() ? '#customer_details' : wc_get_checkout_url() . '#customer_details';
if ( wp_is_mobile() && !is_checkout() ) {
return sprintf (__( '
<div style="font-size:20px">You just placed QTY of PRODUCT NAME in your cart.
Your order total right now is %s. Wanna continue shopping %s or do you want to checkout %s?
</div>
' ),
$count, $subtotal,
'<a style="width:100%; border-left:none; margin-bottom:10%;"
class="shopping button alt" href="' . $direct_to_shop . '">' . __(" Continue Shopping ") . '</a>' );
'<a style="width:100%; border-left:none; margin-top:10%;"
class="checkout button alt" href="' . $direct_checkout . '">' . __(" Go to Checkout ") . '</a>' );
} else {
if ( ! wp_is_mobile() && ! is_checkout() ) {
return sprintf(__('
<div style="font-size:20px">Your just placed QTY of PRODUCT NAME in your cart, brining your order total to %s.
Wanna continue shopping%s or do you want to checkout?%s
</div>
'),
$count, $subtotal,
'<a class="shopping button alt" href="' . $direct_to_shop . '">' . __(" Continue Shopping ") . '</a>' );
'<a class="checkout button alt" href="' . $direct_checkout . '">' . __(" Go to Checkout ") . '</a>' );
}
}
}
我搜索并try 了不同的 Select ,试图自己学习和修改.我就是做不到这一点.