我在wordpress中创建了一个自定义的“谢谢”页面,其中包含以下段落:
Thank you so much for your order!
After paying off
[cart_total]
via XYZ website, please fill out this form and inform us about your payment.
并尝试了这个自定义的简码:
// Total Price Shortcode
function cart_wctotal(){
global $woocommerce;
$wctotal = $woocommerce->cart->get_cart_total();
return "<span class='cart-total'> ".$wctotal."</span>";
}
add_shortcode( 'cart_total', 'cart_wctotal' );
但是,当我签出订单时,输出将返回零总价格:
非常感谢您的订购! 通过XYZ网站支付€0.00后,请填写此表单,并 通知我们您的付款。
See comment from @xhynk why your code is not going to work.
通过用户ID获取最后的订单(和订单总数)