重命名“有促销代码?”在 Woocommerce

问题描述

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

解决方法

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

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>