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.

I write the code below in {theme}/template/ajaxcart/catalog/product/view/addtocart.phtml near Add to Cart button. The price that is displayed add the button is € 0,00 it should be € 350,00 and when you use this button the totaal page refresh.

<?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; ?>

How can I make this extra add to cart button to work? Thanks

7
  • have you created new attribute to store installation price? Feb 14, 2017 at 9:18
  • I don't use a atrribute for the price now Feb 15, 2017 at 10:22
  • then how will you get the installation price for particular product ? Feb 15, 2017 at 14:35
  • That's one problem I don't know. Can you tell me how? Feb 15, 2017 at 15:27
  • if you dont want to do it via custom option then you can create new attribute called installation_price to store installation price Feb 15, 2017 at 15:49

1 Answer 1

0

You don't have to make extra cart button for this. Just use default custom option simple product for installation service.

  1. You have to create a simple product with regular price.

  2. Add custom option in that product for Installation service and put extra price of installation only.

It will give you extra check-box of installation service and its price in that product. When user selects that check-box then price will update automatically.

2
  • I want a extra add to cart button for this option. At the production site this is in use now. But we want a extra add to cart button for the installation service. Do you know how to do this? Feb 15, 2017 at 10:20
  • A custom option with its own add to cart button is also a good start Feb 15, 2017 at 17:34

Your Answer

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

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