douduidui1046 2017-09-27 15: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 18: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

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

报告相同问题?