0

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>
    </div>
    <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>
            </button>
        </div>
        <?php else: ?>
            <div class="primary">
                <button  type="button" class="action cancel primary" value="<?= /* @escapeNotVerified */ __('Cancel Coupon') ?>"><span><?= /* @escapeNotVerified */ __('Cancel Coupon') ?></span></button>
            </div>
        <?php endif; ?>
    </div>
</div>

enter image description here

Help! Thank you in advance...

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

2 Answers 2

0

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

0

Copy this file to your theme folder (app/design/frontend/Vendor/TemplateName/Magento_Checkout/templates/cart/coupon.phtml), then edit it as you like.

Rebuild the project bin/magento set:up && bin/magento s:d:c && bin/magento s:s:d -f && bin/magento c:f

If you need to change only the text, then I do not recommend this method. It is better to use the manuals from the previous answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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