Magento 1.7 – Add to Cart Button Next to Each Grouped Item

cartcart-rulecheckoutgrouped-productsmagento-1.7

I have a grouped product with a large amount of simple products. I want the quantity of the simple product to default to the maximum stock available.

Issue with this that the current "Add To Cart" button adds all the simple products to the cart.

I'd like to add a button next to each simple item that will only add that item to the cart, is that possible?

Best Answer

You can edit this template from your theme catalog/product/view/type/grouped.phtml and replace the sectnion that lists all the simple products:

     <?php if ($_product->isSaleable()): ?>
        <td class="a-center">
        <?php if ($_item->isSaleable()) : ?>
            <input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
        <?php else: ?>
            <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
        <?php endif; ?>
        </td>
     <?php endif; ?>

with this:

   <?php if ($_product->isSaleable()): ?>
        <td class="a-center">
        <?php if ($_item->isSaleable()) : ?>
            <input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /> 
             <!-- [+]  add this-->
            <button type="button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>' + 'qty/' + $(this).previous().value)">Add to cart</button>
             <!-- [-]  add this-->
        <?php else: ?>
            <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
        <?php endif; ?>
        </td>
     <?php endif; ?>

I didn't test the code so there might be some errors bu this sounds like the way to go. You can work on the button styling and translating the add to cart text.