如何在购物车页面“WooCommerce"中显示运输等级的零费率值 [英] How to show zero rate value of shipping class in cart page "WooCommerce"

查看:21
本文介绍了如何在购物车页面“WooCommerce"中显示运输等级的零费率值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关 WooCommerce 运输方法的帮助.如何在购物车页面上显示运输等级的价值.让我解释一下我的问题.

我添加了统一费率来收取某些产品的运费,即 7 欧元的椅子,效果很好,并在购物车页面上显示为 => 运费:统一费率:7 欧元,但我有一些椅子可以免费运送给我的客户.我添加了像免费送货"这样的新类,并在结账时将值设置为 0.00 欧元,它不收取任何费用,这很好,但是当客户查看购物车和运输时,它只显示运输方式的名称,如统一费率而没有任何费用,因为那设置为 0.00 这不能说服客户,他认为我们隐藏了成本.

有没有办法显示运输类别的零值,或者是否可以显示类别名称而不是运输方式的标题?

解决方案

您可以添加一个过滤器,检查您的运输方式的成本是否为零(WooCommerce 目前在其功能中除了打印统一费率"之外什么都不做; 标签,如果成本不高于零)并将您的标签更改为您喜欢的任何内容:

add_filter( 'woocommerce_cart_shipping_method_full_label', 'add_free_shipping_label', 10, 2 );函数 add_free_shipping_label( $label, $method ) {if ( $method->cost == 0 ) {$label = '免运费';//不太优雅的硬编码字符串}返回 $label;}

基于https://stackoverflow.com/a/23581656/8264519,效果非常好.

感谢@DhirenPatel 提出问题.以下附加代码适用于感谢页面和电子邮件:

add_filter( 'woocommerce_order_shipping_to_display', 'add_free_shipping_label_email', 10, 2 );函数 add_free_shipping_label_email( $label, $method ) {if ( $method->cost == 0 ) {$label = '免运费';//不太优雅的硬编码字符串}返回 $label;}

I need some help in WooCommerce Shipping method. How can I show the value of shipping class on the cart page. Let me explain little bit my problem.

I added a flat rate to charge shipping for some products i.e. chairs €7 which is working perfect and show on cart page as => Shipping: Flat rate: €7 but I've some chairs to ship free to my customers. I added new class like "Free Shipping" and set the value to 0.00 EUR on checkout it's no charging any cost which fine, but when client view cart and in shipping it only show the name of shipping method like Flat Rate without any cost because that was set to 0.00 which doesn't convince the customer and he think we've hidden cost.

Is there any way to show the zero value of shipping class or is this possible to show the class name rather than shipping method's title?

解决方案

You can add a filter, checking if the cost of your shipping method is zero (WooCommerce currently is doing nothing else in their function than printing the "flat rate" label, if the cost isn't above zero) and changing your label to whatever you'd like:

add_filter( 'woocommerce_cart_shipping_method_full_label', 'add_free_shipping_label', 10, 2 );
function add_free_shipping_label( $label, $method ) {
    if ( $method->cost == 0 ) {
        $label = 'Free shipping'; //not quite elegant hard coded string
    }
    return $label;
}

Based on https://stackoverflow.com/a/23581656/8264519 and works like a charm.

Thank you @DhirenPatel for your question. The following additional code works for the thank you page and email:

add_filter( 'woocommerce_order_shipping_to_display', 'add_free_shipping_label_email', 10, 2 );
function add_free_shipping_label_email( $label, $method ) {
    if ( $method->cost == 0 ) {
        $label = 'Free shipping'; //not quite elegant hard coded string
    }
    return $label;
}

这篇关于如何在购物车页面“WooCommerce"中显示运输等级的零费率值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆