Use PHP code in Menu Admin Section

Allan, thanks for clarifying the question. You can’t add PHP in the wp-admin menu manager. Instead, here is a way to keep the menu dynamic and managed in wp-admin, while still allowing you to add your PHP at the end:

<?php $args = array(
    'menu' => 'your-menu-name',
    'container' => '',
    'items_wrap' => '%3$s'
); ?>
<ul class="my-custom-menu">
<?php wp_nav_menu($args); ?>
<li><?php // add your badge code here ?></li>
</ul>

What this does: outputs a menu named your-menu-name (replace this with whatever you’re calling the menu, looks like it may be cart). Leaving container empty means it removes the <div> that normally wraps around the menu. You want to remove that because if you don’t, you’ll have a <div> around the menu but not your badge. Setting items_wrap to just %3$s strips off the <ul> that normally wraps around the menu – you’re removing it for the same reason you’re removing the <div>. Finally, you wrap both the menu and your custom code within your own <ul> – you can change my-custom-menu to whatever CSS class you like, add an ID, etc. – and by putting your badge code inside an <li> it will then get the same CSS styles such as float that your other menu items are getting.