Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IF current url equals Onepage Checkout hide element 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...

like image 323
user1704524 Avatar asked Dec 26 '22 04:12

user1704524


1 Answers

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()) ?>
like image 192
Andrew Avatar answered Apr 26 '23 22:04

Andrew