5

The store I am working on handles wholesale orders only and the only functionality I want in the customer account order history area is for the customer to view their orders/status's and delivery, but not the invoice (which is part of a completely different system). On the Order info/history page after an order has been completed and shipped, there are three links on the top of the page for "order information", "invoices" and "deliveries" by default. I want to remove the "invoices" link. I've found where this is coming from (sales.xml located in app/design/frontend/base/default/layout/) on the following line:

<action method="addLink" translate="label" module="sales"><name>invoice</name><path>*/*/invoice</path><label>Invoices</label></action>

There are 6 occurrences of the above line (for different views such as order detail, shipments, credit memo, invoice etc...) so by commenting them all out it works:

<!--<action method="addLink" translate="label" module="sales"><name>invoice</name><path>*/*/invoice</path><label>Invoices</label></action>-->

But I don't really like editing the base files. I tried moving "sales.xml" to my theme folder but then found that my custom order e-mails were missing the footer, having found they also rely on sales.xml and template files it refers to in the base template folder so I'd rather not go there.

Can this over-ridden using the local xml? Or is there a better method?

1 Answer 1

6

Yes you can but you will need a small module to override the sales/order_info block.

Here is how your module config.xml should look like:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Company_Module>
            <version>0.0.1</version>
        </Company_Module>
    </modules>
    <global>
        <blocks>
            <sales>
                <rewrite>
                    <order_info>Company_Module_Block_Sales_Order_Info</order_info>
                </rewrite>
            </sales>
        </blocks>
    </global>
</config>

Here is your Block/Sales/Order/Info.php

<?php
class Company_Module_Block_Sales_Order_Info extends Mage_Sales_Block_Order_Info {

    public function removeLinkByName($name) {
        unset($this->_links[$name]);
    }

}

Your app/etc/modules/Company_Module.xml file:

<?xml version="1.0"?>
<config>
    <modules>
        <Company_Module>
            <active>true</active>
            <codePool>local</codePool>
            <depends><Mage_Sales/></depends>
        </Company_Module>
    </modules>
</config> 

Finally in your local.xml you can do the following:

<reference name="sales.order.info">
    <action method="removeLinkByName">
        <name>invoice</name>
    </action>
</reference>
4
  • local.xml snippet needs: <sales_order_view> </sales_order_view> around it in order to work... Commented Apr 8, 2016 at 17:56
  • in fact I think you would also need to make a duplicate entry in local.xml for <sales_order_shipment> view as well to completely get rid Commented Apr 8, 2016 at 18:00
  • @mike-source yes that's why I didn't specify the handle as I assumed the OP would use the module wherever he wanted ;) Commented Apr 8, 2016 at 18:04
  • 1
    My bad, I think those are the only two places it comes up to do what OP wants, sometimes when I'm in copy paste mode, I don't even check, did take me a few minutes to spot what was missing ;) Commented Apr 8, 2016 at 18:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.