woocommerce_before_calculate_totals挂钩不在购物车小部件中工作

时间:2016-09-12 08:05:52

标签: php wordpress woocommerce hook cart

我正在向woocommerce_before_calculate_totals提起诉讼

商品价格在购物车页面上成功更新。但购物车小工具的价格保持在0?只有购物车小部件中更改的内容才是小计。

这是我的功能

add_action('woocommerce_before_calculate_totals', 'add_custom_total_price', 99  );

function add_custom_total_price( $cart_object ) {
session_start();
global $woocommerce;

foreach ( $cart_object->cart_contents as $key => $value ) {

    if ($value['variation']['price-type'] == 'abonne') {
        $value['data']->price = 6;
        $value['data']->sale_price = 6;
        $value['data']->regular_price = 6;
    }else if ($value['variation']['price-type'] == 'jeune') {
        $value['data']->price = 4;
        $value['data']->sale_price = 4;
        $value['data']->regular_price = 4;
    }

    $value['line_total'] = intval($value['quantity'] * $value['data']->price);

    unset($value['variation']['price-type']);
}

}

结帐工作正常,订单生成正确... 我做错了什么?

感谢。

0 个答案:

没有答案