Magento – Change position of Cart Link in Top Links

layoutmagento-1toplinks

I want to put the Cart link at the end of the top links – ideally using my local.xml file.

Most top links are added like this:

<reference name="top.links">
      <action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action>
</reference>

where I can obviously change the position.

But the cart links seem to be added like this:

<block type="checkout/links" name="checkout_cart_link">
       <action method="addCartLink"></action>
       <action method="addCheckoutLink"></action>
</block>

How do I change the position of a link that doesn't use the addLink method?

Best Answer

The position is hardcoded in /app/code/core/Mage/Checkout/Block/Links.php:

$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart"');

The cart is pos 50 and the checkout link is pos 60. So maybe the easiest way is to position all top.links below 50. But to place just the cart link at the end you would have to rewrite the addCartLink() method.