0

I have a magento site and I am selling cloth materials. There I created a group product for selling products with different sizes. I need to sell the product as whole group, not as individual product. So I disabled the input value.

Now I need to disable the add to cart button in single product page, not in grouped project.

Which means I need to sell the whole group together not single-single products. What should I do?

Hope you can help me. Thank you.

hakkim
  • 666
  • 15
  • 36

2 Answers2

4

For e.g to disable the add to cart button in product detail page you can add below code.

Go to app\design\frontend\\\template\catalog\product\view\addtocart.phtml Add below code after getProduct();?>

<?php if($_product->getTypeId() != 'simple'): ?>
<?php endif; ?>

so your file look like below.

<?php $_product = $this->getProduct();?>
<?php if($_product->getTypeId() != 'simple'): ?>
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php if($_product->isSaleable()): ?>
    <div class="add-to-cart">
        <?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" />
        <?php endif; ?>
        <button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
        <?php echo $this->getChildHtml('', true, true) ?>
    </div>
<?php endif; ?>
<?php endif; ?>

And you are done!

2

In Magento 2 in Vendor/Module/view/frontend/layout/catalog_product_view.xml add this line

<referenceBlock name="product.info.addtocart" remove="true" />