Question

We've used the AttributeIcons extension to convert our configurable product options from drop downs to radio buttons and we now wish to implement a quantity field against each option (as can be set with grouped product types).

The extension includes it's own configurable.js override and the template override for inserting the radio buttons is:-

this.radioTemplate = new Template('<div><input type="radio" name="#{name}" onclick="$(\'#{element}\').setValue(#{value});" id="#{id}" value="#{value}">#{label}</input></div>');

I'd like to modify this to include the quantity inputs (using the grouped type template as a guide). I have this so far...

this.radioTemplate = new Template('<div><input type="radio" name="#{name}" onclick="$(\'#{element}\').setValue(#{value});" id="#{id}" value="#{value}">#{label}</input><!-- Start of QTY inputs --><input type="text" name="super_group_#{name}" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /></input></div>');

I'm struggling to convert the value and the title to something that will work in this file however. The $_item variable is not declared in the configurable type template whereas it is in the grouped, specifically:-

<?php foreach ($_associatedProducts as $_item): ?>

How can I get the default quantity and display the quantity input against each product option within the configurable template? I've tried loading associated products in the configurable type template from the below but it didn't like that...

<?php $_associatedProducts = $this->getAssociatedProducts(); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>

Can I use something else other than $_item to get the quantity of each product option (associated product) or do I have to find a way of loading these into the configurable type template?

Was it helpful?

Solution

So if I understand correctly you want a quantity box for each option. That sounds more like a grouped product.

quantities per option

This way the user can add a quantity per product option and add them to the cart all at once. You can read more on grouped products on this Magento knowledge base page.

As an added bonus for Grouped products, the HTML output is easier to modify allowing you to, for example, show the picture of the simple product per item

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top