问题描述
我的页面上有多种送货选项,当客户购买商品超过 2500 捷克克朗时,我想在这些选项旁边贴上“免费”标签。
我正在使用 Set all shipping methods costs to zero based on cart items subtotal in WooCommerce 答案代码,它使运输方式免费,但它没有在它们旁边贴上标签,实际上是“免费”。
我想将我的文字放在运输方式旁边 - 例如。 “联邦快递(免费)”。
我尝试实现此代码:
$rates[$rate_key]->label = __("Here your text","woocommerce");
谢谢
解决方法
不要使用=
,而是使用.=
(连接赋值运算符)
所以只需更换
$rates[$rate_key]->label = __("Here your text","woocommerce");
与
$rates[$rate_key]->label .= __( 'Here your text','woocommerce' );