Question

I am writing a Magento Extension that is trying to hide the Discount Code section on the checkout cart page. I wrote the following code to replace the current cart.phtml with my custom template.

<layout version="0.1.0">    
    <checkout_cart_index>
        <reference name="checkout.cart">
           <action method="setTemplate">
                <template>company/module/cart.phtml</template>
            </action>
        </reference> 
    </checkout_cart_index>
</layout>

Everything looked good until I realized it even overwrote the template the cart page uses for an empty cart. I have tried many combinations for switch the "checkout_cart_index" name to the reference name but I cannot get it to just replace that template. I further investigated and found in the default layout it sets the cart values here:

 <reference name="content">
            <block type="checkout/cart" name="checkout.cart">
                <action method="setCartTemplate"><value>checkout/cart.phtml</value></action>
                <action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>

I tried again using "SetCartTemplate" but I cannot get it to display yet alone behave as I am intending. Any ideas?

Was it helpful?

Solution

In your layout update

<checkout_cart_index>
    <reference name="checkout.cart">
        <action method="setCartTemplate"><value>path/to/your/cart.phtml</value></action>
        <action method="setEmptyTemplate"><value>path/to/your/noItems.phtml</value></action>
        <action method="chooseTemplate"/>
    </reference> 
</checkout_cart_index>

chooseTemplate will choose the right template

OTHER TIPS

Try to Rewrite this core class to hide the discount code section in your cart page

Mage_Sales_Model_Quote_Address_Total_Discount
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top