How do I get the default checkout url for a magento store?

magento, php

Solution

By default checkout link is returned by `getCheckoutUrl()` function of `Mage_Checkout_Block_Onepage_Link` class. If is quite simple:

public function getCheckoutUrl()
{
    return $this->getUrl('checkout/onepage', array('_secure'=>true));
}

3rd party extensions will most likely override this class (i checked OneStepCheckout 1.4 and it works like this).

Problem

I'm trying to send a user to checkout programmatically in Magento. I can send them to `$this->_redirect('checkout/onepage');` but if they have some sort of third party checkout extension I won't be using the proper one. Is there a way to get the default checkout url for the site and redirect there?

Original source