-1

I'm writing a if statement in which a button needs to show if the cart is empty. For this button I need to get the form key of the product for the data-url So something like this:

<a href="#" data-url="checkout/cart/add/product/59/form_key/<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>/" class="btn btn-success">Order</a>

As mentioned above I need to wrap this button in an if statement, so something like this:

 <?php
    $_helper = Mage::helper('checkout/cart');
    if (1 > $_helper->getItemsCount()) {
    echo '<a href="#" data-url="checkout/cart/add/product/59/form_key/<?php echo Mage::getSingleton(\'core/session\')->getFormKey(); ?>/" class="btn btn-success">Order</a>';
    }
    else {
        '<p>hello</p>';
    }
    ?>

But obviously I can't have php echo within echo. Can anybody point me in the right direction of how to do this?

0

You can use a dot/period to connect the pieces of your string, like this:

echo '<a href="#" data-url="checkout/cart/add/product/59/form_key/' . Mage::getSingleton('core/session')->getFormKey() . '" class="btn btn-success">Order</a>';
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.