Support

Home Forums Community Forum How to change "Enter Voucher code:" label text?

How to change "Enter Voucher code:" label text?

Posted: December 17, 2014 at 3:13 pm


modular

December 17, 2014 at 3:13 pm

How can I change “Enter Voucher code:” label text on the registration form?
I tried to change this part of the code by going to shopping_cart.php (although it says: inactive) because this is the only place where I found “Enter voucher code” label, but unfortunately it didn’t work.
……………………………………………………………………

<div id=”event_espresso_coupon_wrapper” class=”clearfix event-data-display” >
<label class=”coupon-code” for=”event_espresso_groupon_code”><?php _e( ‘Enter Voucher code’, ‘event_espresso’ ); ?></label>
<input type=”text”
name=”event_espresso_groupon_code”
id =”event_espresso_groupon_code”
value=”<?php echo isset( $_SESSION[‘espresso_session’][‘groupon_code’] ) ? $_SESSION[‘espresso_session’][‘groupon_code’] : ”; ?>”
onkeydown=”if(event.keyCode==13) {document.getElementById(‘event_espresso_refresh_total’).focus(); return false;}”
/>
</div>
…………………………………………………………………..

Thanks


Lorenzo Orlando Caum

  • Support Staff

January 5, 2015 at 1:30 pm

Hi, that can be changed by using a gettext filter:

https://eventespresso.com/wiki/how-to-change-wording-with-poedit/#custom-function

This example is ready to go and can be added to your child theme’s functions.php file or a site specific plugin:

function ee_replace_voucher_code_messaging( $translated, $original, $domain ) {
 
    // This is an array of original strings
    // and what they should be replaced with
    $strings = array(
        'Enter Voucher code' => 'Replace this phrase',
        // Add some more strings here
    );
 
    // See if the current string is in the $strings array
    // If so, replace its translation
    if ( isset( $strings[$original] ) ) {
        // This accomplishes the same thing as __()
        // but without running it through the filter again
        $translations = get_translations_for_domain( $domain );
        $translated = $translations->translate( $strings[$original] );
    }
 
    return $translated;
}
 
add_filter( 'gettext', 'ee_replace_voucher_code_messaging', 10, 3 );


Lorenzo

The support post ‘How to change "Enter Voucher code:" label text?’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso