【问题标题】:Rename "Have A Promotional Code?" in Woocommerce重命名“有促销代码?”在 WooCommerce 中
【发布时间】:2021-07-28 07:04:58
【问题描述】:

请检查:http://www.baroniarialb.cat/finalitza-la-compra/ 我安装了 AVADA 和 Woocommerce 主题,但我需要更改“有促销代码?”我找不到正确的代码来做到这一点。 我已经尝试过不同的方式出现在互联网上,但从 funtions.php 没有成功。 你能指导我吗?

【问题讨论】:

    标签: php wordpress woocommerce coupon


    【解决方案1】:

    试试这个代码。我已经从我身边测试过,它工作正常

    function woocommerce_rename_coupon_field_on_cart( $translated_text, $text, $text_domain ) {
        
        if ( is_admin() || 'woocommerce' !== $text_domain ) {
            return $translated_text;
        }
        if ( 'Apply Coupon' === $text ) {
            $translated_text = 'Put your text here'; //Here add your text which you want to replace
        }
        return $translated_text;
    }
    add_filter( 'changetext', 'woocommerce_rename_coupon_field_on_cart', 10, 3 );
    

    您也可以通过 jQuery 进行更改。在footer.php文件中添加脚本

    <script>
    jQuery("h2.promo-code-heading").text("Hello world!");
    </script>
    

    【讨论】:

    • 谢谢,但不适合我...这是我的 funtions.php
    • 我已经用 jquery 更新了我的 ans 所以请检查@nibfreelancer
    • 不,如果我输入 jQuery 代码,我会在网络上收到错误消息。我做错了吗?
    • 我已经更新了我的答案,请检查它在您的网站上是否正常检查此屏幕截图:prntscr.com/1hghugt
    • 感谢我的朋友,但是当复制并粘贴此代码时,我的站点损坏了:prnt.sc/1hhast4
    【解决方案2】:

    对于插件上的字符串翻译,我们使用 locotranslate 插件,简单、快速并且可以将翻译后的文件用于更多的 wordpress 实例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-15
      • 1970-01-01
      • 2017-07-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多