2017-03-15 57 views
-1

如何更改woocommerce優惠券中的「有促銷代碼?」標籤?如何更改「有促銷代碼?」

我試過包括一些我在互聯網上找到的php代碼,但它沒有工作。

請幫助我;我也改變了「有一個促銷代碼?」到「請在下面輸入您的會員代碼來申請折扣」在form-coupon.php文件中。

代碼如下:

if (! defined('ABSPATH')) { 
    exit; // Exit if accessed directly 
} 

if (! wc_coupons_enabled()) { 
    return; 
} 

if (empty(WC()->cart->applied_coupons)) { 
    $info_message = apply_filters('woocommerce_checkout_coupon_message', __('Please enter your membership code in the coupon to apply discount', 'woocommerce') . ' <a href="#" class="showcoupon">' . __('Please enter your membership code below to apply discount', 'woocommerce') . '</a>'); 
    wc_print_notice($info_message, 'notice'); 
} 
?> 

<form class="checkout_coupon" method="post" style="display:none"> 

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

    <p class="form-row form-row-last"> 
     <input type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e('Apply code', 'woocommerce'); ?>" /> 
    </p> 

    <div class="clear"></div> 
</form> 

`

感謝

+1

你試過什麼代碼? – helgatheviking

+2

請更新您的問題與您使用的代碼不工作......謝謝 – LoicTheAztec

回答

0

看看this article,並按照指示。或者只是將以下代碼粘貼到主題功能文件中:

function woocommerce_rename_coupon_field_on_cart($translated_text, $text, $text_domain) { 
    // bail if not modifying frontend woocommerce text 
    if (is_admin() || 'woocommerce' !== $text_domain) { 
     return $translated_text; 
    } 
    if ('Apply Coupon' === $text) { 
     $translated_text = 'Put your text here'; 
    } 
    return $translated_text; 
} 
add_filter('gettext', 'woocommerce_rename_coupon_field_on_cart', 10, 3); 

然後更改'將您的文本放在這裏'。

+0

嗨,感謝您的回覆,但上面的代碼沒有工作。我從上面提到的鏈接中獲得了我的代碼。 – Kumar

+0

在我的購物車頁面中,我啓用了我的優惠券選項,優惠券正常工作,但我實際上想要更改標有「有促銷代碼」的優惠券的標籤。到「輸入您的會員代碼」 – Kumar

+0

如果您的網站正在運行並向上發送鏈接。此外,你可能會使用CSS技巧來隱藏它。 –