I replaced the table view with a drop down view. Now, the file "template/catalog/product/view/type/grouped.phtml" looks like this:
..
<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" class="add-to-cart" id="product_addtocart_form_<?php echo $_product->getId()?>"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
<div style="float:right;border:1px solid;padding:5px; width: 100%;">
<?php if($_product->isGrouped()): ?>
<?php $_subAssociatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product); ?>
<?php if(count($_subAssociatedProducts)){?>
<!--<div class="groupedTitle">Dimensiune / Grosime</div>-->
<select id="grouped_products" name="grouped_products" onchange="addSuperQty('<?php echo $_product->getId()?>',this.value);">
<?php foreach ($_subAssociatedProducts as $_item) {?>
<option value="<?php echo $_item->getId()?>" id="<?php echo number_format($_item->getFinalPrice(),2); ?>"><?php echo $this->htmlEscape($_item->getName())?></option>
<?php } ?>
</select>
<?php }?>
<span id="span_<?php echo $this->getId()?>"></span>
<input type="button" value="-" id="minus1" class="minus" />
<input type="text" size="3" name="qty" onchange="changeQty(this.value,'<?php echo $_product->getId()?>');" id="<?php echo $_product->getId()?>_qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
<input type="button" value="+" id="add1" class="plus" />
<?php else:?>
<input type="button" value="-" id="minus1" class="minus" />
<input type="text" size="3" name="qty" id="qty" maxlength="12" value="<?php echo $_product->getProductDefaultQty() * 1 ?>" class="input-text qty" />
<input type="button" value="+" id="add1" class="plus" />
<?php endif; ?>
<button type="button" class="button btn-cart" onclick="this.form.submit()"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
</div>
</form>
..
<script type="text/javascript">
function addSuperQty(spanId,itemId)
{
var qty = document.getElementById(spanId+'_qty').value;
var ID = 'span_'+spanId;
document.getElementById(ID).innerHTML = '<input type="hidden" value="'+qty+'" id="super_group_'+spanId+'" name="super_group['+itemId+']" />';
}
function changeQty(val,itemId)
{
document.getElementById('super_group_'+itemId).value = val;
}
</script>
For all my grouped products, the default value is 0. So this:
<?php echo $_product->getProductDefaultQty() * 1 ?>
Displays 0 for the quantity each time. What is wrong? On older Magento versions it worked.
When I set a bigger product quantity and try to add the product (sub product) into my account, I receive this error: Please specify the quantity of product(s).
Please help me to fix the problem. Thanks!