In Magento 1.7.0.2 I have a custom URL and path for admin.
The custom path it was set up in local.xml
<admin> <routers> <adminhtml> <args> <frontName>
And the custom URL on admin System > Config > Advanced > Admin > Admin Base URL
After that, the following lines are inserted in DB:
'1236','default','0','admin/url/custom','http://admin.mydomain.com/'
'1239','default','0','admin/url/use_custom_path','0'
'1240','stores','0','web/secure/base_url','https://admin.mydomain.com/'
'1241','stores','0','web/unsecure/base_url','http://admin.mydomain.com/'
When I use <?php echo Mage::getBaseUrl(); ?> is returning base URL for links of custom admin (http://admin.mydomain.com/index.php/)
Because of this behavior, it puts URL admin in the cart and checkout.