主要使用两种过滤器:
1) 过滤器woocommerce_order_shipping_to_display
位于get_shipping_to_display()
方法,由使用get_order_item_totals()
显示发货订单总行的方法:
add_filter( \'woocommerce_order_shipping_to_display\', \'customize_order_shipping_to_display\', 10, 3 );
function customize_order_shipping_to_display( $shipping, $order, $tax_display ){
// Your code to filter displayed shipping
return $shipping;
}
2)或过滤器
woocommerce_get_order_item_totals
位于
get_order_item_totals()
用于显示订单总行数的方法:
add_filter( \'woocommerce_get_order_item_totals\', \'customize_order_item_totals\', 10, 3 );
function customize_order_item_totals( $total_rows, $order, $tax_display ){
// You can make changes below
$total_rows[\'shipping\'][\'label\'] = __( \'Shipping:\', \'woocommerce\' ); // The row shipping label
$total_rows[\'shipping\'][\'value\'] = $order->get_shipping_to_display( $tax_display ); // The row shipping value
return $total_rows;
}
代码进入函数。活动子主题(或活动主题)的php文件。