如何解决显示文本而不是费用的金额值?可能吗?
即使我是一个完全的新手,我也能够为我的购物车和结帐页面执行此操作。但在订单确认页面和电子邮件中,相关费用仍以货币价格金额显示。
我不想明确说明费用是“免费”的,而不仅仅是 0.00 欧元。
// Add a conditional fee
add_action( 'woocommerce_cart_calculate_fees','flat_rate_based_fee',20,1 );
function flat_rate_based_fee( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
$product_ids = array (10133,9992);
foreach( WC()->cart->get_cart() as $cart_item ) {
$product_id = $cart_item['product_id'];
if( in_array( 'flexible_shipping_5_1',$chosen_shipping_methods ) && in_array( $product_id,$product_ids) ) {
$fee = array( 'text' => __( "Name","woocommerce" ),'amount' => 0.00 );
} elseif ( in_array( 'flexible_shipping_7_4',$product_ids) ) {
$fee = array( 'text' => __( "Name ",'amount' => 0.00 );
}
if( isset($fee) ) {
$cart->add_fee( $fee['text'],$fee['amount'],false );
}
}
}
add_filter('woocommerce_cart_totals_fee_html','show_positive_fee_value',10,2 );
function show_positive_fee_value($cart_totals_fee_html,$fee ) {
if ($fee->name === 'Name' ) {
$cart_totals_fee_html ='Post Europe (Free)';
}
return $cart_totals_fee_html;
}
add_filter('woocommerce_cart_totals_fee_html','show_positive_fee_valuk',2 );
function show_positive_fee_valuk($cart_totals_fee_html,$fee) {
if($fee->name === 'Name ') {
$cart_totals_fee_html ='Post America (Free)';
}
return $cart_totals_fee_html;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。