cancel
Showing results for 
Search instead for 
Did you mean: 

Change Grouped products View from Table to Drop Down

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

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

Change Grouped products View from Table to Drop Down

Hello Guys Please I need someone to review my script and let me know what might be wrong with it.

 

What I'm trying to accomplish is to display my Grouped products in a drop down way not the default table view.

 

This is what I have so far

 

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * Grouped product data template
 *
 * @see Mage_Catalog_Block_Product_View_Media
 * @see Mage_Catalog_Block_Product_View_Type_Grouped
 */
?>
<?php $this->setPreconfiguredValue(); ?>
<?php $_product = $this->getProduct(); ?>
<?php $_associatedProducts = $this->getAssociatedProducts(); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
<?php if ($this->displayProductStockStatus()): ?>
    <?php if ($_product->isAvailable() && $_hasAssociatedProducts): ?>
        <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
    <?php else: ?>
        <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
    <?php endif; ?>
<?php endif; ?>
<?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="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() * 0 ?>" 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>

 

 

Problem is that when implementing this script I get an error from Magento which is the following.

 

a:5:{i:0;s:42:"Please specify the quantity of product(s).";i:1;s:1309:"#0 /home5/wholesj8/public_html/NEWCP2016/app/code/core/Mage/Checkout/Model/Cart.php(284): Mage::throwException('Please specify ...')
#1 /home5/wholesj8/public_html/NEWCP2016/app/code/local/Cmsmart/AjaxCart/controllers/IndexController.php(154): Mage_Checkout_Model_Cart->addProduct('49', Array)
#2 /home5/wholesj8/public_html/NEWCP2016/app/code/local/Cmsmart/AjaxCart/controllers/IndexController.php(67): Cmsmart_AjaxCart_IndexController->tryaddAction(Object(Mage_Catalog_Model_Product), Array)
#3 /home5/wholesj8/public_html/NEWCP2016/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Cmsmart_AjaxCart_IndexController->indexAction()
#4 /home5/wholesj8/public_html/NEWCP2016/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#5 /home5/wholesj8/public_html/NEWCP2016/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#6 /home5/wholesj8/public_html/NEWCP2016/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#7 /home5/wholesj8/public_html/NEWCP2016/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#8 /home5/wholesj8/public_html/NEWCP2016/index.php(83): Mage::run('', 'store')
#9 {main}";s:3:"url";s:345:"/NEWCP2016/index.php/ajaxcart/index/index/uenc/aHR0cDovL2NyeXN0YWxwbGFjZS5jb20vTkVXQ1AyMDE2L2luZGV4LnBocC9jcnlzdGFscy1mcm9tLXN3YXJvdnNraS1nYWxsZXJ5L3N3YXJvdnNraS1jcnlzdGFsLXByaXNtcy9zd2Fyb3Zza2ktY2xlYXItZmFjZXRlZC1iYWxsLWNyeXN0YWwtcHJpc20tYnktY3J5c3RhbHMtZnJvbS1zd2Fyb3Zza2ktY2hvb3NlLWZyb203LXNpemVzLmh0bWw,/product/49/form_key/jfH5ZB5saW5HMqYe/";s:11:"script_name";s:20:"/NEWCP2016/index.php";s:4:"skin";s:7:"english";}

 

 

Any and every idea will be greatly appreciated !

 

2 REPLIES 2

Re: Change Grouped products View from Table to Drop Down

Forgot to include I'm dealing with the file

 

grouped.phtml   

 

Location:

 

/app/design/frontend/base/default/template/catalog/product/view/type

 

 

Re: Change Grouped products View from Table to Drop Down

SO Any ideas? what might be wrong on my script?