【问题标题】:Get cost value of chosen shipping method at checkout of Woocommerce在 Woocommerce 结账时获取所选运输方式的成本价值
【发布时间】:2020-03-08 10:41:55
【问题描述】:

在我的子主题的functions.php中,我有这样的自定义脚本:

add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process1'); 功能 my_custom_checkout_field_process1() {

//做某事

}

要进行一些计算,我需要获取所选运输方式的成本。该怎么做?

【问题讨论】:

    标签: woocommerce


    【解决方案1】:

    我明白了!

    $cart  = WC()->cart;
    $total = __( 'Free!', 'woocommerce' );
    if ( 0 < $cart->get_shipping_total() ) {
        if ( $cart->display_prices_including_tax() ) {
            $total = $cart->shipping_total + $cart->shipping_tax_total;
        } else {
            $total = $cart->shipping_total;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-19
      • 2018-12-04
      • 2020-10-08
      • 1970-01-01
      • 1970-01-01
      • 2017-11-09
      • 1970-01-01
      • 2020-11-19
      相关资源
      最近更新 更多