3

At the controller checkout_cart_index with the reference content, I want to replace this:

<block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>

With this:

<block type="multicoupon/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>

What happens is instead of replacing the block, it adds a new one. I've spent hours looking into this to no avail. Is there a way to do this with my own module using just the layout or will I have to write the change to a different file?

1 Answer 1

2

Because unsetChild isn't working in this case, I suggest the nuclear option:

<checkout_cart_index>
    <remove name="checkout.cart.coupon"></remove>
</checkout_cart_index>

This will remove the block entirely. Not such a big deal because you'll immediately re-create it:

<checkout_cart_index>
    <remove name="checkout.cart.coupon"></remove>
    <reference name="checkout.cart">
        <block type="multicoupon/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
    </reference>
</checkout_cart_index>
3
  • Doesn't work. Also tried using the value from the original block's as attribute as the value for the name parameter for unsetChild (as per this example: stackoverflow.com/questions/12422641/…. Commented Feb 24, 2014 at 18:09
  • @DissidentRage see update. Tested as working in 1.8. Commented Feb 24, 2014 at 18:50
  • I seem to have left out a vital piece of information: I didn't notice before that checkout.cart.coupon happened to be a child of the block checkout.cart. After using <action method="unsetChild"><name>checkout.cart.coupon</name></action> again inside <block name="checkout.cart"/> it worked flawlessly. Thank you! Commented Feb 24, 2014 at 18:58

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.