0

我正在尝试获取过滤器中的价格woocommerce_update_order_review_fragments,但无法了解它的位置

add_filter('woocommerce_update_order_review_fragments', 'price_bottom_checkout');
function price_bottom_checkout($arr) {
    $price = ? // how to get it over here?      
    $price_txt = '<span class="total-pay">'.$price.'</span>';
    $arr['.total-pay'] = $price;
    return $arr;
}
4

1 回答 1

0

设法找出如何。需要查看每次通过 ajax 刷新购物车时更新的会话购物车。

add_filter('woocommerce_update_order_review_fragments', 'price_bottom_checkout');
function price_bottom_checkout($arr) {
    global $woocommerce;
    $the_total = '';
    foreach ($woocommerce->cart->cart_contents as $cart_item) {
        $the_total = $cart_item['line_total'];
        break;
    }
    $price_txt = '<span class="total-pay">'.wc_price($the_total).'</span>';
    $arr['.total-pay'] = $price_txt;
    return $arr;
}
于 2017-01-23T07:29:04.787 回答