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
 
 - 
 1You can do this using adding custom option to product. No requirement to add this extra button.Dhiren Vasoya– Dhiren Vasoya2017年02月13日 10:28:48 +00:00Commented Feb 13, 2017 at 10:28
 
1 Answer 1
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
 
 
 
 Khushbu_sipl 
 
 1,08810 silver badges18 bronze badges
 
 default