【问题标题】:Woocommerce Cart Coupon Value Placeholder ChangeWoocommerce 购物车优惠券价值占位符更改
【发布时间】:2018-07-03 09:33:21
【问题描述】:

所以,我想我可以通过尝试应用来改变这一点

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

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

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

我根本不习惯php环境,所以浏览了30分钟后看到%$符号就头晕了。

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

谢谢

【问题讨论】:

  • 发布的anwser对您有帮助吗? hust 查找 .php 页面,其中 input 具有 id = coupon_code

标签: php css wordpress woocommerce placeholder


【解决方案1】:

让我们在 coupon.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="&lt;?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?&gt;"

<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>

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

【讨论】:

  • 如果 WooCommerce 更新,请避免更改模板并使用 gettext 过滤器来证明您的更改。
  • @AndrewSchultz 同意
【解决方案2】:

在 WooCommerce 或任何插件中更改文本的首选方法是使用 gettext 过滤器。最好使用过滤器而不是编辑模板,因为模板可以在 WooCommerce 更新时更改。将以下代码放在您的 functions.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 );

【讨论】:

    猜你喜欢
    • 2017-09-15
    • 1970-01-01
    • 2019-04-19
    • 2020-11-15
    • 2020-11-04
    • 2021-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多