Magento : Change options of configurable product to radio button
Replace the configurable.phtml code with below code:
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select style="display:none;" name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
</script>
<?php endif;?>
<div id="r"></div>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#attribute<?php echo $_attribute->getAttributeId() ?> option").each(function(i, e) {
if(jQuery(this).val() == '')
{}
else
{
jQuery("<input type='radio' name='r' />")
.attr("value", jQuery(this).val())
.attr("checked", i == 0)
.click(function () {
jQuery("#attribute<?php echo $_attribute->getAttributeId() ?>").val(jQuery(this).val());
})
.appendTo("#r");
jQuery("<span > "+jQuery(this).html()+" </span>")
.appendTo("#r");
}
});
});
</script>
Replace the configurable.phtml code with below code:
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select style="display:none;" name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
</script>
<?php endif;?>
<div id="r"></div>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#attribute<?php echo $_attribute->getAttributeId() ?> option").each(function(i, e) {
if(jQuery(this).val() == '')
{}
else
{
jQuery("<input type='radio' name='r' />")
.attr("value", jQuery(this).val())
.attr("checked", i == 0)
.click(function () {
jQuery("#attribute<?php echo $_attribute->getAttributeId() ?>").val(jQuery(this).val());
})
.appendTo("#r");
jQuery("<span > "+jQuery(this).html()+" </span>")
.appendTo("#r");
}
});
});
</script>
Hi Afroz ,
ReplyDeleteNice post ,Thanks for sharing ,looking forward for more posts .
Magento Developers
Hey thanks for sharing this. I tried this but I had some issues while implementing this. Anyways finally it was resolved.
ReplyDeleteHi,
ReplyDeleteI am a Magento developer and I am struggling to resolve a particular bug for my client.
when the product is out of stock, is there a way to clear all customers shopping cart of this product, instead of disabling the product?
My product is Magento out of stock
Can you please explain how?
You can do this making a module or cron job.
DeleteGet all the shopping cart items from quote object.
Check if out of stock, remove them from quote object.
Thanks
Thanks Afroz..
DeleteI've cleared the bug. Got an idea when I got in "quote object:
Thanks a lot
Hi,
ReplyDeleteSorry my question is not related to this. I have been trying to write a custom api in magento just to display hello world and i have been having resource path not callable and I try to debug but the same result.
Can you pls help post a tutorial on creating magento custom api. Just to display a simple string will be ok.
Thanks.
you are god! thanks a lot
ReplyDeleteHi Andrej, Please don't compare anyone with God. There is none other than God. God is one and only one.
DeleteWorked like a charm. Thank you.
ReplyDeleteThanks for your valuable comments Shreyas.
DeleteHi ...
ReplyDeleteI used your code ..Iam new in magento let me know hw I view the code in hellowires theme...
Need to edit view.phtml?
I got it... But Price doesn't change when i select option
DeleteThis code works in magento 1.8? i find several configurable.phtml files, can you tell me where is located?
ReplyDeletethanks
This is Great Code.. working Good Thank you. for sharing.
ReplyDeletehow to get id of selected custom radio button in magento
ReplyDeleteand how to keep radio button checked by default on a specific radio button
plz help me.....
how to get id of selected custom radio button in magento
ReplyDeleteand how to keep radio button checked by default on a specific radio button
plz help me.....
Extremely rattling Article. The substance stream and elegance of forming is astounding. i buy the focal purposes and smart conditions of Magento in a very purpose by point path during this article among others I browse a comparative subject.
ReplyDeleteOutsource ecommerce website development services
Affordable ecommerce development services
Nice post ,Thanks for sharing ,looking forward for more posts .
ReplyDeletegreat
ReplyDelete