如何在WooCommerce结账页面更改送货方式的文本?

huangapple go评论78阅读模式
英文:

How do I change the text of the delivery method in the WooCommerce checkout?

问题

我要移除结帐中的送货方式文本以仅保留送货方式的价格。通过WooCommerce设置,我未能将送货方式保留为空白。

英文:

How do I change the text of the delivery method in the checkout? I want to remove the text of the delivery method completely so that only the prices for the delivery methods remain. Through the WooCommerce settings, I failed to leave the delivery methods without a name.

如何在WooCommerce结账页面更改送货方式的文本?

答案1

得分: 1

要修改WooCommerce购物车中运输方式的标签,您可以使用woocommerce_cart_shipping_method_full_label过滤器钩子。该钩子允许您根据特定条件自定义标签。例如,您可以检查运输价格是否大于零,然后删除原始标签并用运输价格替换它。要实现这一点,您需要将提供的代码片段添加到您当前WordPress主题的functions.php文件中。

add_filter( 'woocommerce_cart_shipping_method_full_label', 'remove_delivery_method_label', 10, 2 );
function remove_delivery_method_label( $label, $method ) {
    if ( $method->cost > 0 ) {
        $label = '';
        $label .= wc_price( $method->cost );
    }
    return $label;
}

如何在WooCommerce结账页面更改送货方式的文本?

如何在WooCommerce结账页面更改送货方式的文本?

英文:

To modify the label for shipping methods in the WooCommerce cart, you can utilize the woocommerce_cart_shipping_method_full_label filter hook. This hook allows you to customize the label based on certain conditions. For example, you can check if the shipping price is greater than zero and then remove the original label and replace it with the shipping price. To implement this, you need to add the provided code snippet to the functions.php file of your active WordPress theme.

add_filter( 'woocommerce_cart_shipping_method_full_label', 'remove_delivery_method_label', 10, 2 );
function remove_delivery_method_label( $label, $method ) {
    if ( $method->cost > 0 ) {
    	$label = '';
        $label .= wc_price( $method->cost );
    }
    return $label;
}

如何在WooCommerce结账页面更改送货方式的文本?

如何在WooCommerce结账页面更改送货方式的文本?

huangapple
  • 本文由 发表于 2023年7月6日 15:53:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76626647.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定