Remove the coupon field from the cart

The solution of this is at the end

I monitor "magento" on twitter. Sometimes I read the tweets. A few minutes ago I found a tweet to a blog article which describes how to remove the coupon field from the cart.

It starts with:

There is no button in the backend to deactivate the coupon field in magento. Because of this you have to change the source code.

Then there is a description how to change app/code/core/Mage/Checkout/Block/Cart/Coupon.php

NO! NEVER touch files in app/code/core! NEVER! NEVER! NEVER!

IF you need to change them - and there are ALWAYS ways around this, copy them to app/code/local/Mage and change them there.

There are a lot of reasons why this is a really bad idea. The first one is, if you change it this way you have a lot of trouble while updating OR all your changes are lost, because you overwrite them all.

Copies in app/code/local/Mage

If you copy the files to app/code/local/Mage the changes are not lost, but you have a lot of trouble too, because the files after an update in app/code/core/ are not used.

Core hacks

The question "Why core hacks in magento are a really bad idea?" can answer google for me.

How to change the layout

If you want changes in the layout, there are two main ways to achieve this:

  1. have your own theme
  2. or change the layout.xml (it is described in the german article at the webguys too)

Removing the coupon box from the cart

	<remove name="" />

Update: Vinai Kopp just mailed me, that <remove /> doesn't use the parent block context, so you should use it directly in the handle.

Markdown doesn't support strike through, so to compare, the old code:

Update: Alternative with unsetChild

As far as I know <remove> is the lastto be called. For this reason, it is not possible to have a block with the same name at another location. So you can use unsetChild instead (which works in the parent block context! ;-)). But be careful with the handles, because in <default> the coupon-block doesn't exist yet.

    <reference name="checkout.cart">
        <action method="unsetChild"><name>coupon</name></action>