1

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 1.9.2.4

Please suggest how to add both functionalities without extension.

2

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; ?>
        </div>
        <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) ?>
</div>

and must be added this script for Buy Now button :

<script type="text/javascript">
function setcheckoutLocation(location)
{
    showLoadingAnimation();
    jQuery.ajax({
        type:"GET",
        url:location,
        success:function(data){
            window.location.href = "<?php echo Mage::helper('checkout/url')->getCheckoutUrl(); ?>";
        }
    });
}
</script>
  • thanks for response, but it didn't work, still its redirect me to checkout/cart. :( – Mace Long Apr 19 '16 at 12:36
  • please tell me what happen with this code:? – Ajay Patel Apr 20 '16 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 Apr 20 '16 at 4:18
  • can you send me your url link? – Ajay Patel Apr 20 '16 at 4:21
  • so, basically its not working with configurable products. fine with simple one. – Mace Long Apr 20 '16 at 5:05

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.