I want to add both buttons "Buy Now" as well as "Add to Cart", If the user clicks on Buy-now it will redirect to the "onestepcheckout" page directly (Magento extension), for Add to Cart need default functionality. I'm using Magento

Please suggest how to add both functionalities without extension.


1 Answer 1


Please add this in your phtml file where you want to add :

<div class="add-to-cart">
        <div class="qty-view">
        <?php if(!$_product->isGrouped()): ?>
        <label for="qty"><?php echo $this->__('Qty:') ?></label>
        <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty validate-greater-than-zero-qty validate-digits" />
        <?php endif; ?>
        <button type="button" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
        <button type="button" title="Buy Now" class="button btn-cart" onclick="setcheckoutLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span>Buy Now</span></span></button>
        <?php echo $this->getChildHtml('', true, true) ?>

and must be added this script for Buy Now button :

<script type="text/javascript">
function setcheckoutLocation(location)
            window.location.href = "<?php echo Mage::helper('checkout/url')->getCheckoutUrl(); ?>";
  • thanks for response, but it didn't work, still its redirect me to checkout/cart. :(
    – Mace Long
    Commented Apr 19, 2016 at 12:36
  • please tell me what happen with this code:?
    – Ajay Patel
    Commented Apr 20, 2016 at 3:21
  • it didn't redirect me to onestepcheckout page. It works as default after click on buy now, it takes to checkout/cart page.
    – Mace Long
    Commented Apr 20, 2016 at 4:18
  • can you send me your url link?
    – Ajay Patel
    Commented Apr 20, 2016 at 4:21
  • so, basically its not working with configurable products. fine with simple one.
    – Mace Long
    Commented Apr 20, 2016 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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