伍商务购物车优惠券价值占位符更改



所以,我想我可以通过尝试应用来改变它

input#coupon_code.input-value::placeholder {
content: 'Enter Code here'; }

这是CSS,它不起作用,所以我开始在php上找到它的位置

我设置了一个wordpress,所以我继续cart.phpcoupon.php

我根本不习惯 php 环境,所以在浏览所有内容 30 分钟后查看 % $ 符号后我感到头晕目眩。

我目前只是想找到如何更改此占位符文本,但无法这样做。

谢谢

在WooCommerce或任何插件中更改文本的首选方法是使用gettext过滤器。 最好使用过滤器而不是编辑模板,因为模板可以在更新WooCommerce时更改。 将以下代码放在函数.php文件中,以获得更面向未来的解决方案。

function my_text_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Coupon code' :
            $translated_text = __( 'My New Coupon Code Text', 'woocommerce' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );

假设在优惠券中.php你有以下内容:

 <p class="form-row form-row-first">
    <input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" id="coupon_code" value="" />
 </p>

更改placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>"

<p class="form-row form-row-first">
    <input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( 'your placeholder text here', 'woocommerce' ); ?>" id="coupon_code" value="" />
</p>

在此处看到占位符文本的位置,这就是您更改它的地方。

最新更新