Question

I want to remove a sidebar element for ALL checkout pages. So inside my local.xml I've got something like:

<checkout_default>
    <remove name="left.cart"/>
</checkout_default>

but nothing happened... I've tried checkout, checkout_default, checkout_default_default... no bunga.

checkout_cart_index worked but only for the.. cart index page. I tried checkout_cart_default to see if that'd make it work for all cart pages but then it stopped working entirely.

What handle can I use to select ALL checkout pages?

Was it helpful?

Solution

No such handle exists/that's not how handles work.

Layout handles are sort of like events — only they apply strictly the the layout system. Every time you load a URL in the system, certain layout handles are generated. For example, using the online Commerce Bug demo on the cart index page

enter image description here

We can see the five handles generated are

default
STORE_default
THEME_frontend_default_commercebugdemo
checkout_cart_index
customer_logged_out

The checkout_cart_index handle is specific to that page (called the full action name handle), the others fire on all pages. There's no named layout handle that fires for all cart pages.

There are some tools to help you with code reuse. First, you'll need to identify the pages you want to target. Let's say that's checkout_cart_index and checkout_onepage_index.

Then, in you layout update XML file, do something like this

<layouts>
    <checkout_cart_index>
        <update handle="namespace_packagename_my_custom_handle_name"
    </checkout_cart_index>
    <checkout_onepage_index>
        <update handle="namespace_packagename_my_custom_handle_name"/>
    </checkout_onepage_index>

    <namespace_packagename_my_custom_handle_name>
        <remove name="left.cart"/>
        <!-- other updates -->
    </namespace_packagename_my_custom_handle_name>
</layouts>

What we've done here is create a custom handle named namespace_packagename_my_custom_handle_name. Then, in each full action name handle, we've told Magento to import the layout rules in our custom handle.

Sometimes Magento itself will do this. For example, Magento uses the customer_account handle to share information between different pages in the customer account section

<sales_order_history translate="label">
    <label>Customer My Account Order History</label>
    <update handle="customer_account"/>
    <!-- ... -->
</sales_order_history>
<!-- ... -->
<sales_order_view translate="label">
    <label>Customer My Account Order View</label>
    <update handle="customer_account"/>
    <!-- ... -->
</sales_order_view translate="label">

However, in the case of the cart pages, there is no such handle.

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