0

I have a website, sell a products with and without installation service. I want two add to cart buttons, one with and one without installation on a product page. The price for installation is variable for each product.

How can I create a extra add to cart button for this products? Thanks

Dhiren Vasoya
9,70914 gold badges37 silver badges61 bronze badges
asked Feb 13, 2017 at 10:14
1
  • 1
    You can do this using adding custom option to product. No requirement to add this extra button. Commented Feb 13, 2017 at 10:28

1 Answer 1

0

write below code in {theme}/template/catalog/product/view/addtocart.phtml near Add to Cart button.

<?php 
 if($_product->getSampleProductId()): 
 $_price = Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getSampleProductId(), 'price', Mage::app()->getStore()); 
 $_formattedPrice = Mage::helper('core')->currency($_price, true, false);
 $_buttonTitle = "Order Sample @".$_formattedPrice;
?>
 <button type="button" title="<?php echo $_buttonTitle ?>" class="button btn-cart" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add/product/'.$_product->getSampleProductId()) ?>')"><span><span><?php echo $_buttonTitle ?></span></span></button>
<?php endif; ?>
answered Feb 13, 2017 at 10:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.