6

I need to check the validity of a coupon code on the checkout/cart page with server-side code.

Magento already ships with a similar check in place. However, I need to add one to see if a user is connected or not: what would be the best way to extend/override that action in Magento?

I know I can copy the controller PHP file to the /app/code/local/ folder tree, but I'm wondering whether there's a better way to do it.

Brighid McDonnell
  • 4,293
  • 4
  • 36
  • 61
JohnT
  • 967
  • 2
  • 16
  • 30

1 Answers1

11

Anything besides modifying the core is good in my opinion. With that said create a simple module with a controllers directory and etc with config.xml:

<config>
    <frontend>
        <routers>
            <checkout>
                <args>
                    <modules>
                         <My_Module before="Mage_Checkout">My_Module_Checkout</My_Module>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
</config>

See here for more details on how to extend the frontend controller: http://prattski.com/2010/06/24/magento-overriding-core-files-blocks-models-resources-controllers/

B00MER
  • 5,471
  • 1
  • 24
  • 41
  • 2
    Thnak you, in fact I did that, but I need to explicitly add a require on the require_once("Mage/Checkout/controllers/CartController.php"); – JohnT Jun 16 '11 at 16:24
  • 2
    Can you update your post with the full config.xml and controller code? – B00MER Jun 16 '11 at 16:25