Let's suppose I want to add a custom link to my product in M1, is there a way to do that? These products would be linked to an external site. I have two buttons on my website - Buy Now And Add to Cart. Buy now redirects customers directly to the checkout page.

I want this feature to function something like this:

If there is no custom URL entered in the backend, Magento should create product URL as it usually does and both buy now & add to cart button should appear.

If there is a custom product URL entered, Magento should use that link. ONLY 'buy now' button should appear in that case, and if customers click on buy now button, it should redirect them to the external website.

Here's the code in addtocart.phtml

<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php $buyNowTitle = $this->__('Buy Now'); ?>
<?php if($_product->isSaleable()): ?>
    <div class="add-to-cart  actions-wrapper">
        <?php if(!$_product->isGrouped()): ?>
        <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
        <?php endif; ?>
        <div style="display:inline-block;margin-top: 5px;">
        <a  title="<?php echo $buyNowTitle ?>" id="product-buynow-button" class="button btn-cart product-add-btn" onclick="productBuyNowForm.submit(this)"><span><span><?php echo $buyNowTitle ?></span></span></a> 
        <button type="button" title="<?php echo $buttonTitle ?>" id="product-addtocart-button" class="button btn-cart product-add-btn" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
  • 1
    could you share how you added Buy Now button and in which phtml ?
    – Pawan
    Commented Apr 7, 2019 at 14:42
  • @Pawan I have added the code in question. Commented Apr 13, 2019 at 11:09

1 Answer 1


Workaround : you can have product's attribute for storing custom buying url and check if it exist for the product you can remove the link in phtml file.

You need to set Manage Stock false for those type of product.

And also you can prevent these type of product to be added in cart by following refrences

Preventing a product from being added to cart in magento

How to exclude products being added to cart based on products attributes?

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.