在我的子主题的functions.php中,我具有如下自定义脚本:
add_action('woocommerce_checkout_process','my_custom_checkout_field_process1'); 函数my_custom_checkout_field_process1(){
//做点事情
}
要进行一些计算,我需要获得选择的运输方式的成本。该怎么做?
答案 0 :(得分:0)
我明白了!
$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;
}
}