2

I needed to edit the "invalid promo code" error as it is a valid code, it's just they need to be logged in to use it. Since our login (within the cart) is designed on the next page, it really wasn't working out wording wise.

I edited:

$this->__('Coupon code "%s" is not valid.', Mage::helper('core')->escapeHtml($couponCode))

to this....

$this->__('This coupon code "%s" can not be applied now or it may require you to <b>login or register an account</b> to use it.', Mage::helper('core')->escapeHtml($couponCode))

However: is that safe for future upgrades? And how do I make "login" and "register" links? After I added the html the page went white so I had to just bold those words for now.

  • Where did you edit this line? In what file? – 7ochem Mar 2 '15 at 20:03
0

If you have edited this line in a file that was in app/code/core/ of in app/design/frontend/base/default or app/design/frontend/default/default, then you can be almost sure that it is not upgrade safe. You should do this by overriding in a proper way. I cannot give any hints to how to do this because your question does not state what file you have edited.

About the links for "login" and "register", you can do that in the same way the coupon code is being inserted into the text:

$this->__(
    'This coupon code "%s" can not be applied now or it may require you to <b><a href="%s">login</a> or <a href="%s">register</a> an account</b> to use it.',
    Mage::helper('core')->escapeHtml($couponCode),
    Mage::helper('customer')->getLoginUrl(),
    Mage::helper('customer')->getRegisterUrl()
)
| improve this answer | |
  • This worked perfectly for now. – Daniel Mar 2 '15 at 21:11
1

The most upgradeable way for messages is to use the locale of your theme. If it allows, you can always use inline translations as well.

app/design/frontend/YOUR_PACKAGE/YOUR_THEME/locale/translate.csv

You can also override a controller and edit the message if you'd like.

<!--app/code/local/namespace/module/etc/config.xml-->
<config>
    <frontend>
        <routers>
            <checkout>
                <args>
                    <modules>
                        <mymodule_checkout before="Mage_Checkout">Namespace_Package_Checkout</interactone_customoptions>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
</config>

Here is your controller file:

<?php
// app/code/local/namespace/module/controllers/Checkout/CartController.php

require_once Mage::getModuleDir('controllers', 'Mage_Checkout') . DS . 'CartController.php';

class Namespace_Module_Checkout_CartController extends Mage_Checkout_CartController {

    public function couponPostAction() {
        // ...snip
        if ($codeLength) {
            if ($isCodeLengthValid && $couponCode == $this->_getQuote()->getCouponCode()) {
                $this->_getSession()->addSuccess(
                    $this->__('Coupon code "%s" was applied.', Mage::helper('core')->escapeHtml($couponCode))
                );
            } else {
                $this->_getSession()->addError(
                    $this->__(
                        'This coupon code "%s" can not be applied now or it may require you to <b><a href="%s">login</a> or <a href="%s">register</a> an account</b> to use it.',
                        Mage::helper('core')->escapeHtml($couponCode),
                        Mage::helper('customer')->getLoginUrl(),
                        Mage::helper('customer')->getRegisterUrl()
                    )
                );
            }
        } else {
            $this->_getSession()->addSuccess($this->__('Coupon code was canceled.'));
        }
        // ...snip
    }
}
| improve this answer | |
  • When I opened that CSV file it didn't seem like there was any code? It was just a bunch of double sentences. How does that work? Nothing looked like it would do anything so I didn't update it. I still want to be safe about upgrades in the future so I'm curious. – Daniel Mar 6 '15 at 15:41
  • Translation as they call it in Magento is just string replacement. The left column is the "default" item for translation. The right column is what you want to display. – Ryan Street Mar 6 '15 at 22:01
1

Edit the core files update is poor way to do coding in magento.If you upgrade the magento in future ,your core file edited will be lost.So from my point of view you override the cartController in coustom module.

Step1:brymayor.com/magento/magento-module-creator/ create module & use below names. Namespace:sourav modulename:jain

Step2:In config file

<!--app/code/local/namespace/module/etc/config.xml-->
<config>
    <frontend>
        <routers>
            <checkout>
                <args>
                    <modules>
                        <sourav_jain before="Mage_Checkout">Sourav_Jain</sourav_jain>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
</config>

Step3:override controller

require_once(Mage::getModuleDir('controllers','Mage_Checkout').DS.'CartController.php'); Include the base cart controller in coustom controller file

In this file only we put the function that we need edited example: public function couponPostAction(){

/add on this code with default code/

$this->__(
    'This coupon code "%s" can not be applied now or it may require you to <b><a href="%s">login</a> or <a href="%s">register</a> an account</b> to use it.',
    Mage::helper('core')->escapeHtml($couponCode),
    Mage::helper('customer')->getLoginUrl(),
    Mage::helper('customer')->getRegisterUrl()
)

}

| improve this answer | |
  • join me at skype:kinex.sourav – Sourav Mar 15 '15 at 14:34

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.