Woocommerce 在电子商务结帐时获取所选运输方式的成本值

Woocommerce 在电子商务结帐时获取所选运输方式的成本值,woocommerce,Woocommerce,在my child主题的functions.php中,我有如下自定义脚本: 添加操作(“woocommerce\u checkout\u process”、“my\u custom\u checkout\u field\u process1”); 函数my\u custom\u checkout\u field\u process1(){ //做点什么 } 为了做一些计算,我需要得到所选择的运输方式的成本。怎么做 我明白了 $cart = WC()->cart; $total = __(

在my child主题的functions.php中,我有如下自定义脚本:

添加操作(“woocommerce\u checkout\u process”、“my\u custom\u checkout\u field\u process1”); 函数my\u custom\u checkout\u field\u process1(){

//做点什么

}

为了做一些计算,我需要得到所选择的运输方式的成本。怎么做

我明白了

$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;
    }
}
$cart=WC()->cart;
$total=__;('Free!','woocommerce');
如果(0<$cart->获取装运总额()){
如果($cart->display\u prices\u include\u tax()){
$total=$cart->shipping\u total+$cart->shipping\u tax\u total;
}否则{
$total=$cart->shipping\u total;
}
}