Jump to content

Loading Attributes using Jquery


khalilrumi

Recommended Posts

Allright, the thing is that, with products like tables, chair and other decoration items, customers can select different colors before they buy. The first option is that i would have to create configurable options for each product and load them when the template loads. It can make loading slow.

 

Few options can be shown and then users can select other options if they like. thanks

Resolved, i was using the following code,

 

<?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 name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>

 

 

Now i will fetch these options from spConfig.config.attributes, i will use following code:

 

<script type="text/javascript">

var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
for(var i=spConfig.settings.length-1;i>=0;i--) {
spConfig.settings[i].selectedIndex = 1;
}
spConfig.reloadPrice();
</script>

 

 

Thanks,

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.