douduidui1046 2017-09-27 07:42
浏览 54
已采纳

如何在Woocommerce中本地化自定义费用标签?

I need to do some job in Wordpress. I managed to add fee to checkout

$woocommerce->cart->add_fee( 'thebestcompany_service', $fee, true, 'standard' );

That's great. I managed to create a plugin. That's great. I managed to translate my plugin with Loco translate. That's great.

But I do not now where to translate the fee thebestcompany_service.

There is no such string in the plugin translation, in theme translation or woocommerce plugin translation. Please help.

  • 写回答

1条回答 默认 最新

  • dongquanlin1885 2017-09-27 10:27
    关注

    To make The string translatable in your function, you need to use a translatable function this way:

    $fee_label = __( 'The best company service', 'domain_name' );
    // Or (without domain name):
    // $fee_label = __( 'The best company service' );
    
    $woocommerce->cart->add_fee( $fee_label, $fee, true, 'standard' );
    

    Where 'domain_name' has to be replaced by your active theme domain slug or plugin domain slug, that Loco translate is going to use.

    This should work now

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 怎么实现数组的循环累加,simulink
  • ¥15 51单片机最小开发板系统,想让寻迹小车在全检测到黑线(寻迹模块代码在第一块板子上)时蜂鸣器响(在第二块板子上)
  • ¥15 pbootcms多选调用成列表
  • ¥15 51单片机oled显示时钟
  • ¥15 小规模TSP问题的动态规划求解
  • ¥25 kubelet.service: Failed with result 'exit-code'.
  • ¥15 bitvise黑框内一键部署v2ray提示账户没有root怎么解决
  • ¥15 车型识别以及相似度匹配中细节特征提取以及图像模糊问题
  • ¥15 怎么用鸿蒙的ArkTs写出来啊
  • ¥30 websocket服务端多线程通信
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部