dongyuqi3808
dongyuqi3808
2013-05-02 13:38

IF当前url等于Onepage Checkout隐藏元素ELSE show element - Magento

已采纳

I am trying to write a simple script to hide the "checkout" button located on the sidebar mini cart in Magento if on the checkout page. For obvious reasons I don't think the checkout button should still be visible if the customer is already on the checkout page...

Here is what I have done but Its not working and I am not sure how far off I am.

   <?php if(Mage::getURL('checkout/onepage') == Mage::helper('core/url')->getCurrentUrl()): ?>
        <?php echo $this->__('Checking out...') ?>
            <?php else: ?>
                <button type="button" title="<?php echo $this->__('Checkout') ?>" class="btn btn-mini btn-success" onclick="setLocation('<?php echo $this->getCheckoutUrl() ?>')"><span><span><?php echo $this->__('Checkout') ?></span></span></button>
  <?php endif ?>

If someone could be kind enough to give me a shift in the right direction I'd be grateful OR even let me know of a better method...

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • doulouli8686 doulouli8686 8年前

    try this:

    Mage::getURL('checkout/onepage') // or $this->getUrl('checkout/onepage')
    

    This will get the url for the checkout/onepage route

    Mage::helper('core/url')->getCurrentUrl()
    

    this will get you the current url

    Now compare them:

    <?php if(Mage::getURL('checkout/onepage') == Mage::helper('core/url')->getCurrentUrl()) ?>
    
    点赞 评论 复制链接分享