Woocommerce更改默认订单[方法-价格]运送到购物车
wc-cart-functions.phpWoocommerce更改默认订单[方法-价格]运送到购物车,woocommerce,shipping,Woocommerce,Shipping,wc-cart-functions.php function wc_cart_totals_shipping_method_label( $method ) { $label = $method->label; if ( $method->cost > 0 ) { if ( WC()->cart->tax_display_cart == 'excl' ) { $label .= ': ' . wc_price
function wc_cart_totals_shipping_method_label( $method ) {
$label = $method->label;
if ( $method->cost > 0 ) {
if ( WC()->cart->tax_display_cart == 'excl' ) {
$label .= ': ' . wc_price( $method->cost );
if ( $method->get_shipping_tax() > 0 && WC()->cart->prices_include_tax ) {
$label .= ' <small>' . WC()->countries->ex_tax_or_vat() . '</small>';
}
} else {
$label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() );
if ( $method->get_shipping_tax() > 0 && ! WC()->cart->prices_include_tax ) {
$label .= ' <small>' . WC()->countries->inc_tax_or_vat() . '</small>';
}
}
} elseif ( $method->id !== 'free_shipping' ) {
$label .= ' (' . __( 'Free', 'woocommerce' ) . ')';
}
return apply_filters( 'woocommerce_cart_shipping_method_full_label', $label, $method );
}
因为我可以把结账页面改成这样
Cart Subtotal $300.00
Shipping and Handling **$35.00 Ship To An International Destination** *CHANGE*
Order Total $335.00
在
cart-shipping.php
我刚刚找到了解决方案,返回这个函数,wp\u kses\u post wc\u cart\u totals\u shipping\u method\u label$method;我只是使用了一个带有拆分功能的分隔符来更改外观顺序
<?php if ( 1 === count( $available_methods ) ) : $method = current( $available_methods ); $Leyenda=wp_kses_post( wc_cart_totals_shipping_method_label( $method ) ); $palabras=split(":","$Leyenda"); echo "$palabras[1] $palabras[0]"; ?>
谢谢您只需更改:
$label .= ': ' . wc_price( $method->cost );
到
也改变了:
$label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() );
到
希望将来能帮助有同样问题的人:cart-shipping.php我刚刚找到了解决方案,返回此函数,wp\u kses\u post wc\u cart\u totals\u shipping\u method\u label$method;我只是使用了一个带有拆分功能的分隔符来更改外观顺序。非常感谢。
$label = wc_price( $method->cost ) . ': ' . $label ;
$label .= ': ' . wc_price( $method->cost + $method->get_shipping_tax() );
$label = wc_price( $method->cost + $method->get_shipping_tax() ) . ' : ' .$label;