php 如何获取 magento 商店的默认结帐网址?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11485361/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I get the default checkout url for a magento store?
提问by smokingoyster
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?
我正在尝试在 Magento 中以编程方式发送用户结帐。我可以将它们发送到,$this->_redirect('checkout/onepage');但如果他们有某种第三方结帐扩展程序,我将不会使用正确的扩展程序。有没有办法获取网站的默认结帐网址并重定向到那里?
采纳答案by user487772
By default checkout link is returned by getCheckoutUrl()function of Mage_Checkout_Block_Onepage_Linkclass. If is quite simple:
默认情况下,结帐链接由类的getCheckoutUrl()函数返回Mage_Checkout_Block_Onepage_Link。如果很简单:
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).
第 3 方扩展很可能会覆盖这个类(我检查了 OneStepCheckout 1.4,它的工作原理是这样的)。
回答by MirzaShakir
you can try with
你可以试试
$checkout_link = Mage::helper('checkout/url')->getCheckoutUrl();
this return checkout link in all conditions
在所有条件下此退货结帐链接
- while using any extensions such as OnePagecheckout or OneStepcheckout
- if on extension were used it simply returns the basic checkout url
- 使用任何扩展程序时,例如 OnePagecheckout 或 OneStepcheckout
- 如果使用了扩展,它只会返回基本的结帐网址

