How can I change text in checkout page in Magento 2? I already googled but most suggested to change a translation file (.csv) - This is not a ideal solution I think.

Especially, I want to change a text 'Apply Discount Code'.

When I search the text in all file, I found a file is using the text. (File path: \vendor\magento\module-checkout\view\frontend\templates\cart\coupon.phtml)

<div class="fieldset coupon<?= strlen($block->getCouponCode()) ? ' applied' : '' ?>">
    <input type="hidden" name="remove" id="remove-coupon" value="0" />
    <div class="field">
        <label for="coupon_code" class="label"><span><?= /* @escapeNotVerified */ __('Enter discount code') ?></span></label>
        <div class="control">
            <input type="text" class="input-text" id="coupon_code" name="coupon_code" value="<?= $block->escapeHtml($block->getCouponCode()) ?>" placeholder="<?= $block->escapeHtml(__('Enter discount code')) ?>" />
    <div class="actions-toolbar">
        <?php if (!strlen($block->getCouponCode())): ?>
        <div class="primary">
            <button class="action apply primary" type="button" value="<?= /* @escapeNotVerified */ __('Apply Discount') ?>">
                <span><?= /* @escapeNotVerified */ __('Apply Discount') ?></span>
        <?php else: ?>
            <div class="primary">
                <button  type="button" class="action cancel primary" value="<?= /* @escapeNotVerified */ __('Cancel Coupon') ?>"><span><?= /* @escapeNotVerified */ __('Cancel Coupon') ?></span></button>
        <?php endif; ?>

enter image description here

Help! Thank you in advance...

  • You aren't want override core html ? – Evgeniy Kapelko Jun 20 '18 at 18:16
  • No but I used purchased theme. – Yun Jun 20 '18 at 20:08

1) The easiest way is that we translate this text on our custom module or theme:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.