cancel
Showing results for 
Search instead for 
Did you mean: 

Grouped product with dropdown menu

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Grouped product with dropdown menu

Hello,

 

I found browsing the net a piece of code to allow groupable products instead of the table that showed by default to select quantities, have a dropdown menu to select an associate product.
I have in a grouped product, two associates, one simple and one virtual, if I choose the simple product via dropdown menu it goes fine, but if I choose the virtual one I get an error that tells me to indicate the quantity of the product.
It already states 1 in quantity, anyone could help me to fix the code?

 

Thanks a lot

 

The file path is: app/design/frontend/rwd/default/template/catalog/product/view/type/grouped.phtml

 

?>
<?php $this->setPreconfiguredValue(); ?>
<?php $_product = $this->getProduct(); ?>
<?php $_associatedProducts = $this->getAssociatedProducts(); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
<?php echo $this->getChildHtml('product_type_data_extra') ?>
<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 $_product->getId()?>"></span>
        <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 $_item->getQty() * 1 ?>" class="input-text qty" />
    <?php else:?>
        <input type="text" size="3" name="qty" id="qty" maxlength="12" value="<?php echo $_item->getQty() * 1 ?>" class="input-text qty" />
    <?php endif; ?>

</div>
</form>
<script type="text/javascript">decorateTable('super-product-table')</script>