• Resolved Warren

    (@rabbitwordpress)


    Hi there,

    To change the Add a coupon text to Gift Card / Coupon Number in the new blocks page layout on the basket and checkout pages for WooCommerce 9+ I had to manually edit the plugin :

    woocommerce > assets > client > blocks > checkout.js (line 13)
    woocommerce > assets > client > blocks > wc-cart-checkout-base-frontend.js (line 25)

    Obviously not ideal as this will be overwritten when the plugin is next updated.

    My question is how can I create a permanent override in my theme to do this? The same way php template files can be overrode.

    • This topic was modified 3 months, 2 weeks ago by Warren.
Viewing 3 replies - 1 through 3 (of 3 total)
  • @rabbitwordpress Try this:

    function change_add_coupon_text( $translated_text, $text, $domain ) {
    // Target only WooCommerce text domain
    if ( 'woocommerce' === $domain ) {
    // Change "Add a coupon" on Cart and Checkout
    if ( 'Add a coupon' === $text ) {
    $translated_text = 'Apply Discount Code'; // Replace with your custom text
    }
    }
    return $translated_text;
    }
    add_filter( 'gettext', 'change_add_coupon_text', 10, 3 );
    Thread Starter Warren

    (@rabbitwordpress)

    Thanks @julianosb but sadly that didn’t work

    Plugin Support Jonayed (woo-hc)

    (@jonayedhosen)

    Hi @rabbitwordpress ,

    I understand you’re looking to customize the “Add a coupon” text in WooCommerce. With the new Cart and Checkout blocks, this requires a different approach compared to modifying traditional shortcode-based templates.

    Since the new blocks are built with React, their text strings are managed differently. To achieve a permanent override without editing plugin files directly, you can use a translation plugin like Say What? or Loco Translate.

    For more details about how translations work, you can check this guide: WooCommerce Translations.

    I hope this helps! Let us know if you have any further questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.