How to add a dynamic cart link to the user menu? Commerce already defines two menu items in the Navigation menu:


Shopping cart - 'cart' - enabled by default, static
Shopping cart - 'cart/my' - disabled by default, dynamic


'cart/my' uses a custom title callback, 'commerce_cart_menu_item_title' that builds a dynamic menu link in the form: Shopping cart (2 items)

If I want to add a new menu item for the shopping cart to the User Menu, what's the proper way to do this? Do I first need to duplicate a menu item, then override the duplicate?

Ideally, I would be able to set my own title callback so that I can optionally build a dynamic menu in any format I choose.
You can create a new menu programatically through menu hooks, and a great source for sample code and explanation is the menu_example portion of the Examples Module.

For example

function mymodule_menu() {
     $items['cart/new_menu_item'] = array(
    'title' =&gt; 'Shopping cart (# items)',
    'title callback' =&gt; 'mymodule_new_menu_item_title',
    'title arguments' =&gt; array(TRUE),
    'page callback' =&gt; 'mymodule_new_menu_item_redirect',
    'access arguments' =&gt; array('access content'),
    'type' =&gt; MENU_SUGGESTED_ITEM, 
  );
  return $items;
}