【发布时间】:2019-01-29 18:59:31
【问题描述】:
我想在 woocommerce 结帐页面上的订单总数中添加 300,但 woocommerce_calculate_totals 钩子不起作用...
如果我使用 var_dump($total),我会看到正确的结果 - int(number),但订单表中的总金额没有变化。
add_action( 'woocommerce_calculate_totals', 'action_cart_calculate_totals', 10, 1 );
function action_cart_calculate_totals( $cart_object) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
if ( !WC()->cart->is_empty() ):
$total = $cart_object->cart_contents_total += 300;
var_dump($total);
endif;
}
【问题讨论】:
标签: php wordpress woocommerce cart hook-woocommerce