1.app/design/frontend/smartwave/porto/template/apparel/apparel.phtml

<?php
    $_helper  = $this->helper('catalog/output');
    $helper_richsnippets = $this->helper('porto/richsnippets');
    $store = Mage::app()->getStore();
    $code  = $store->getCode();
    $useragent = $_SERVER['HTTP_USER_AGENT'];
    $apparelCatId = Mage::helper('ejuice')->getApparelCategoryId();
    $apparelCategory = Mage::getModel('catalog/category')->load($apparelCatId);
    $apparelCatProductCount = $apparelCategory->getProductCount();
    $apparelProductCollection = Mage::getResourceModel('catalog/product_collection')
							->addCategoryFilter($apparelCategory)
							->addAttributeToSelect('*')
							->addAttributeToFilter('status', 1) // enabled
							->addAttributeToSort('position') // short products
							->addAttributeToFilter('type_id','configurable')
							->addAttributeToFilter('visibility', 4);
?>
<?php if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50&#91;1-6&#93;i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez(&#91;4-7&#93;0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-&#91;a-w&#93;)|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10&#91;0-2&#93;|n20&#91;2-3&#93;|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-(&#91;1-8&#93;|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-&#91;2-7&#93;|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5&#91;0-3&#93;|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) : ?>
    <?php if(Mage::getModel('cms/block')->load('apparel_listing_page_mobile')->getIsActive()) :
            echo Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('apparel_listing_page_mobile')->toHtml();
    endif;?>
<?php else: ?>
    <?php if(Mage::getModel('cms/block')->load('apparel_listing_page_desktop')->getIsActive()) :
            echo Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('apparel_listing_page_desktop')->toHtml();
    endif;?>
<?php endif; ?>
<?php if($apparelCatProductCount >=1): ?>
    <div class="category-products">
        <div class="row">
            <?php foreach($apparelProductCollection as $_product): ?>
                <div class="col-lg-6 col-sm-6 col-xs-12">
                    <div class="apparel-item-col-left">
                        <div class="loader-container" id="loader_container_<?php echo $_product->getId() ?>" style="display: none;">
                            <div class="loader">
                                <i class="ajax-loader medium animate-spin"></i>
                            </div>
                        </div>
                    
                        <div class="apparel-product-image">
                            <?php if($_product->getImage()!= 'no_selection'): ?>
                                <?php $image_src = $this->helper('catalog/image')->init($_product, 'image'); ?>
                                <div class="image-apparel"><a href="<?php echo $_product->getProductUrl(); ?>"><img id="image_main_<?php echo $_product->getId() ?>" src="<?php echo $image_src; ?>" alt="<?php echo $_product->getName(); ?>"></a></div>
                            <?php else: ?>
                                <h3><?php echo $_product->getName(); ?></h3>
                            <?php endif; ?>
                        </div>
                        <div class="apparel-option">
                            <div class="apparel-product-name">
                                <h3><?php echo $_product->getName() ?></h3>
                            </div>
                            <div class="actions">
                                <?php if($_product->isSaleable()): ?>
                                    <?php $rate = Mage::getModel('rewardpoints/rate')->getRate(Magestore_RewardPoints_Model_Rate::MONEY_TO_POINT); ?>
                                    <form data-money="<?php echo $rate->getMoney(); ?>" data-points="<?php echo $rate->getPoints(); ?>" id="addtocart_form_<?php echo $_product->getId(); ?>" action="<?php echo $this->helper('checkout/cart')->getAddUrl($_product) ?>" method="post">
                                        <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
                                        <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
                                        <?php Mage::unregister('product') ?>
                                        <?php Mage::register('product', $_product); ?>
                                        <?php if ( $_product->getTypeId() == 'configurable'): ?>
                                            <?php echo $this->getLayout()->createBlock('catalog/product_view_type_configurable', '', array('template'=> 'catalog/product/view/type/configurable_category_apparel.phtml'))->toHtml(); ?>
                                        <?php endif; ?>
                                        <div class="qty-n-price">
                                            <div class="qty-field">
                                                <div class="qty-holder">
                                                    <input type="text" name="qty" id="qty_<?php echo $_product->getId(); ?>" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
                                                    <div class="qty-changer new-style-plus-minus">
                                                        <a href="javascript:void(0)" class="qty_inc"><i class="fa fa-plus"></i></a>
                                                        <a href="javascript:void(0)" class="qty_dec"><i class="fa fa-minus"></i></a>
                                                    </div>
                                                </div>
                                            </div>
                                            <?php
                                            $productBlock = $this->getLayout()->createBlock('catalog/product_price');
                                            if(Mage::getStoreConfig("porto_settings/category/product_price", $code)):?>
                                                <?php echo $productBlock->getPriceHtml($_product, true) ?>
                                            <?php endif; ?>
                                            <div class="btns-group">
                                                <button type="button" title="Add to Cart" class="button btn-cart" id="button" onclick="productAddToCartForm_<?php echo $_product->getId()?>.submit(this);"><span>Add to Cart</span></button>
                                            </div>
                                        </div>
                                        <?php echo $this->getLayout()->createBlock('rewardpoints/product_view_earning', '', array('template'=> 'rewardpoints/product/view/earning.phtml'))->toHtml(); ?>
                                    </form>
                                    <?php if(Mage::getStoreConfig('ajaxcart/addtocart/enableproduct')): ?>
                                        <script type="text/javascript">
                                            //<!&#91;CDATA&#91;
                                            var productAddToCartForm_<?php echo $_product->getId()?> = new VarienForm('addtocart_form_<?php echo $_product->getId(); ?>');
                                            productAddToCartForm_<?php echo $_product->getId()?>.submit = function(button, url) {
                                                if (this.validator.validate()) {
                                                    var form = this.form;
                                                    var oldUrl = form.action;
                                                    if (url) {
                                                        form.action = url;
                                                    }
                                                    var e = null;
                                                    if (!url) {
                                                        url = jQuery('#addtocart_form_<?php echo $_product->getId(); ?>').attr('action');
                                                    }
                                                    if(url.indexOf("wishlist/index/cart") != -1){
                                                        url = url.replace("wishlist/index/cart","ajaxcart/index/add"); // New Code
                                                    }
                                                    else {
                                                        url = url.replace("checkout/cart","ajaxcart/index"); // New Code
                                                    }
                                                    url = url.replace("http://", "//");
                                                    url = url.replace("https://", "//");
                                                    var data = jQuery('#addtocart_form_<?php echo $_product->getId(); ?>').serialize();
                                                    data += '&isAjax=1';
                                                    var is_quickview = false;
                                                    if(jQuery("body").hasClass("quickview-index-view")){
                                                        is_quickview = true;
                                                    }
                                                    if(is_quickview)
                                                        window.parent.jQuery("#loading-mask").show();
                                                    else
                                                        jQuery('#loading-mask').show();
                                                        try {
                                                            jQuery.ajax({
                                                                url : url,
                                                                dataType : 'json',
                                                                type : 'post',
                                                                data : data,
                                                                success : function(data) {
                                                                    if(is_quickview)
                                                                        window.parent.jQuery('#loading-mask').hide();
                                                                    else
                                                                        jQuery('#loading-mask').hide();
                                                                    if(data.status == 'ERROR'){
                                                                        if(is_quickview)
                                                                            window.parent.alert(data.message.replace("<br/>",""));
                                                                        else
                                                                            alert(data.message.replace("<br/>",""));
                                                                    }
                                                                    else{
                                                                        if(is_quickview){
                                                                            if(window.parent.jQuery('.header-container .mini-cart')){
                                                                                window.parent.jQuery('.header-container .mini-cart').replaceWith(data.toplink);
                                                                            }
                                                                            if(window.parent.jQuery('.fixed-header .mini-cart')){
                                                                                window.parent.jQuery('.fixed-header .mini-cart').replaceWith(data.toplink);
                                                                            }
                                                                            if(window.parent.jQuery('.sticky-header .mini-cart')){
                                                                                window.parent.jQuery('.sticky-header .mini-cart').replaceWith(data.toplink);
                                                                            }
                                                                            if(window.parent.jQuery('.col-right .block.block-cart')){
                                                                                window.parent.jQuery('.col-right .block.block-cart').replaceWith(data.cart_sidebar);
                                                                            }
                                                                            window.parent.jQuery('#after-loading-success-message #success-message-container .msg-box').html(data.message);
                                                                            <?php $autoclose = Mage::getStoreConfig('ajaxcart/addtocart/autoclose', $code); ?>
                                                                            ajaxcart_sec = <?php echo ($autoclose && is_numeric($autoclose))?$autoclose:5; ?>;
                                                                            timer_sec = ajaxcart_sec;
                                                                            window.parent.jQuery('#after-loading-success-message').fadeIn(200);
                                                                            ajaxcart_timer = setInterval(function(){
                                                                                timer_sec --;
                                                                                window.parent.jQuery('#after-loading-success-message .timer').html(timer_sec);
                                                                            },1000);
                                                                            setTimeout(function(){
                                                                                window.parent.jQuery('#after-loading-success-message').fadeOut(200);
                                                                                clearTimeout(ajaxcart_timer);
                                                                                setTimeout(function(){
                                                                                    window.parent.jQuery('#after-loading-success-message .timer').html(ajaxcart_sec);
                                                                                }, 1000);
                                                                            },ajaxcart_sec*1000);
                                                                        }
                                                                        else {
                                                                            if(jQuery('.header-container .mini-cart')){
                                                                                jQuery('.header-container .mini-cart').replaceWith(data.toplink);
                                                                            }
                                                                            if(jQuery('.fixed-header .mini-cart')){
                                                                                jQuery('.fixed-header .mini-cart').replaceWith(data.toplink);
                                                                            }
                                                                            if(jQuery('.sticky-header .mini-cart')){
                                                                                jQuery('.sticky-header .mini-cart').replaceWith(data.toplink);
                                                                            }
                                                                            if(jQuery('.col-right .block.block-cart')){
                                                                                jQuery('.col-right .block.block-cart').replaceWith(data.cart_sidebar);
                                                                            }
                                                                            jQuery('#after-loading-success-message #success-message-container .msg-box').html(data.message);
                                                                            <?php $autoclose = Mage::getStoreConfig('ajaxcart/addtocart/autoclose', $code);?>
                                                                            ajaxcart_sec = <?php echo ($autoclose && is_numeric($autoclose))?$autoclose:5; ?>;
                                                                            timer_sec = ajaxcart_sec;
                                                                            jQuery('#after-loading-success-message').fadeIn(200);
                                                                            ajaxcart_timer = setInterval(function(){
                                                                                timer_sec --;
                                                                                jQuery('#after-loading-success-message .timer').html(timer_sec);
                                                                            },1000);
                                                                            setTimeout(function(){
                                                                                jQuery('#after-loading-success-message').fadeOut(200);
                                                                                clearTimeout(ajaxcart_timer);
                                                                                setTimeout(function(){
                                                                                    jQuery('#after-loading-success-message .timer').html(ajaxcart_sec);
                                                                                }, 1000);
                                                                            },ajaxcart_sec*1000);
                                                                        }
                                                                    }
                                                                }
                                                            });
                                                        }
                                                        catch (e) {
                                                        }                
                                                        this.form.action = oldUrl;
                                                        if (e) {
                                                            throw e;
                                                        }
                                                }
                                                else {
                                                    if(jQuery('#product-options-wrapper'))
                                                    jQuery('#product-options-wrapper').scrollToMe();
                                                }
                                            }.bind(productAddToCartForm_<?php echo $_product->getId()?>);
                                            //&#93;&#93;>
                                        </script>
                                    <?php else : ?>
                                        <script type="text/javascript">
                                            //<!&#91;CDATA&#91;
                                            var productAddToCartForm_<?php echo $_product->getId()?> = new VarienForm('addtocart_form_<?php echo $_product->getId(); ?>');
                                            productAddToCartForm_<?php echo $_product->getId()?>.submit = function(button, url) {
                                                if (this.validator.validate()) {
                                                    var form = this.form;
                                                    var oldUrl = form.action;
                                                    if (url) {
                                                       form.action = url;
                                                    }
                                                    var e = null;
                                                    try {
                                                        this.form.submit();
                                                    }
                                                    catch (e) {
                                                    }
                                                    this.form.action = oldUrl;
                                                    if (e) {
                                                        throw e;
                                                    }
                                                    if (button && button != 'undefined') {
                                                        button.disabled = true;
                                                    }
                                                }
                                                else {
                                                    if(jQuery('#product-options-wrapper'))
                                                    jQuery('#product-options-wrapper').scrollToMe();
                                                }
                                            }.bind(productAddToCartForm_<?php echo $_product->getId()?>);
                                            //&#93;&#93;>
                                        </script>
                                    <?php endif; ?>
                                <?php else : ?>
                                    <h1>Out Of Stock</h1>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                    <div class="apparel-item-col-right">
                        <div class="apparel-product-gallery">
                            <ul>
                            <?php $product = Mage::getModel('catalog/product')->load($_product->getId());
                            $count = 0;
                            foreach ($product->getMediaGalleryImages() as $image) : ?>
                                <?php $count++; ?>
                                <li class="<?php echo $count==1 ? "active" : "" ?>" data-id="<?php echo $product->getId(); ?>" data-src="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail', $image->getFile()); ?>"><img src="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail', $image->getFile())->resize(75,90); ?>"/></li>
                            <?php endforeach; ?>
                            </ul>
                        </div>
                    </div>
                </div>
            <?php endforeach; ?>
        </div>
    </div>
<?php else: ?>
    <div class="category-products">
        <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
    </div>
<?php endif; ?>
<script type="text/javascript">
    $j(document).ready(function(){
        $j('.apparel-product-gallery li').click(function(){
            $data = $j(this).data();
            var loader = "loader_container_"+$data.id;
            var image = "image_main_"+$data.id;
            //alert(loader);
            //alert(image);
            $j('#'+loader).show();
            $j('#'+image).attr('src', $data.src);
            $j('#'+loader).hide();
            $j(this).siblings().removeClass('active');
            $j(this).addClass('active');
            
        });
        
        var price = 0;
        $j('.new-option-for-apparel select').change(function(){
            
            var $this = $j(this);
            var productId = $this.closest('form').find('input[name="product"]').attr('value');
            var $data = $this.data();
            var $attributeId = $data.attributeid;
            var $selectedOptions = $this.val();            
            var jsonConvertedData = window['priceConfig_'+productId];
            var attributes = jsonConvertedData.attributes;
            var basePrice = parseFloat(jsonConvertedData.basePrice);
            var oldProductPrice = parseFloat(jsonConvertedData.oldPrice);
            if($data.index==1){
                price = 0;
            }
            if(price==0){
                price = basePrice;
            }
            var optionPrice = 0;
            $j.each(attributes, function( index, value ){
              
                 if(index == $attributeId){
                    var options = value.options;
                    $j.each(options, function( indx, val ){
                       if(val.id == $selectedOptions){
                          price = parseFloat(price)+parseFloat(val.price);
                          optionPrice = parseFloat(val.price);
                       }
                    });
                 }
            });
            
            var finalPrice = parseFloat(price);
            var oldPrice = oldProductPrice+optionPrice;
            var priceTemplate = new Template(jsonConvertedData.template);
            var formatedFinalPrice = priceTemplate.evaluate({price:finalPrice.toFixed(2)});
            var formatedOldPrice = priceTemplate.evaluate({price:oldPrice.toFixed(2)});
            if(parseFloat(jsonConvertedData.oldPrice)>basePrice){
                $this.closest('form').find('.qty-n-price .old-price .price').html(formatedOldPrice);
                $this.closest('form').find('.qty-n-price .special-price .price').html(formatedFinalPrice);
            }else{
                $this.closest('form').find('.qty-n-price .regular-price .price').html(formatedFinalPrice);
            }
            var $formData = $this.closest('form').data();
            var $points = calculatePoints($formData.money,$formData.points,finalPrice);
            $this.closest('form').find('.rewardpoints-product-view-earning').html('<?php echo Mage::helper('rewardpoints/point')->getImageHtml(true) ?>'+' You will earn '+$points+' VGOD Points for purchasing this product');
        });
    });
    
    function calculatePoints(money,points,price){
        console.log(money);
        var totalPoints = (parseFloat(points)/parseFloat(money))*price;
        return parseInt(totalPoints);
    }
</script>

2. /var/www/html/vgod/app/design/frontend/smartwave/porto/template/catalog/product/view/type/configurable_category_apparel.phtml

<?php
$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
  
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
    <?php $i = 0; ?>
    <?php foreach($_attributes as $_attribute): ?>
    <div class="new-option-for-apparel">
        <dt><label><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
        <dd<?php if ($_attribute->decoratedIsLast){?><?php }?>>
            <?php $i++; ?>
            <div>
            <select data-index="<?php echo $i; ?>" data-attributeid="<?php echo $_attribute->getAttributeId() ?>" name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select_<?php echo $_product->getId()?>">
            <option><?php echo $this->__('Choose an Option...') ?></option>
            </select>
            </div>
        </dd>
    </div>
    <?php endforeach; ?>
</dl>
  
<script type="text/javascript">
    var spConfig_<?php echo $_product->getId()?> = new Inchoo_Product.Config(<?php echo $this->getJsonConfig() ?>);
    var priceConfig_<?php echo $_product->getId()?> = <?php echo $this->getJsonConfig() ?>;
</script>
<?php endif;?>

3. vgod/js/configurable_list.js

if(typeof Inchoo_Product ==’undefined’) {
var Inchoo_Product = {};
}

/**************************** CONFIGURABLE PRODUCT **************************/
Inchoo_Product.Config = Class.create();
Inchoo_Product.Config.prototype = {
initialize: function(config){
this.config = config;
this.taxConfig = this.config.taxConfig;
var settingsClassToSelect = ‘.super-attribute-select_’+this.config.productId;
this.settings = $$(settingsClassToSelect);
this.state = new Hash();
this.priceTemplate = new Template(this.config.template);
this.prices = config.prices;

this.settings.each(function(element){
Event.observe(element, ‘change’, this.configure.bind(this))
}.bind(this));

// fill state
this.settings.each(function(element){
var attributeId = element.id.replace(/[a-z]*/, ”);
attributeId = attributeId.replace(/_.*/, ”);
if(attributeId && this.config.attributes[attributeId]) {
element.config = this.config.attributes[attributeId];
element.attributeId = attributeId;
this.state[attributeId] = false;
}
}.bind(this))

// Init settings dropdown
var childSettings = [];
for(var i=this.settings.length-1;i>=0;i–){
var prevSetting = this.settings[i-1] ? this.settings[i-1] : false;
var nextSetting = this.settings[i+1] ? this.settings[i+1] : false;
if(i==0){
this.fillSelect(this.settings[i])
}
else {
this.settings[i].disabled=true;
}
$(this.settings[i]).childSettings = childSettings.clone();
$(this.settings[i]).prevSetting = prevSetting;
$(this.settings[i]).nextSetting = nextSetting;
childSettings.push(this.settings[i]);
}

// Set default values – from config and overwrite them by url values
if (config.defaultValues) {
this.values = config.defaultValues;
}

var separatorIndex = window.location.href.indexOf(‘#’);
if (separatorIndex != -1) {
var paramsStr = window.location.href.substr(separatorIndex+1);
var urlValues = paramsStr.toQueryParams();
if (!this.values) {
this.values = {};
}
for (var i in urlValues) {
this.values[i] = urlValues[i];
}
}

this.configureForValues();
document.observe(“dom:loaded”, this.configureForValues.bind(this));
},

configureForValues: function () {
if (this.values) {
this.settings.each(function(element){
var attributeId = element.attributeId;
element.value = (typeof(this.values[attributeId]) == ‘undefined’)? ” : this.values[attributeId];
this.configureElement(element);
}.bind(this));
}
},

configure: function(event){
var element = Event.element(event);
this.configureElement(element);
},

configureElement : function(element) {
this.reloadOptionLabels(element);
if(element.value){
this.state[element.config.id] = element.value;
if(element.nextSetting){
element.nextSetting.disabled = false;
this.fillSelect(element.nextSetting);
this.resetChildren(element.nextSetting);
}
}
else {
this.resetChildren(element);
}
//this.reloadPrice();
// Calculator.updatePrice();
},

reloadOptionLabels: function(element){
var selectedPrice;
if(element.options[element.selectedIndex].config){
selectedPrice = parseFloat(element.options[element.selectedIndex].config.price)
}
else{
selectedPrice = 0;
}
for(var i=0;i-1){
allowedProducts.push(options[i].products[j]);
}
}
} else {
allowedProducts = options[i].products.clone();
}

if(allowedProducts.size()>0){
options[i].allowedProducts = allowedProducts;
element.options[index] = new Option(this.getOptionLabel(options[i], options[i].price), options[i].id);
element.options[index].config = options[i];
index++;
}
}
}
},

getOptionLabel: function(option, price){
var price = parseFloat(price);
if (this.taxConfig.includeTax) {
var tax = price / (100 + this.taxConfig.defaultTax) * this.taxConfig.defaultTax;
var excl = price – tax;
var incl = excl*(1+(this.taxConfig.currentTax/100));
} else {
var tax = price * (this.taxConfig.currentTax / 100);
var excl = price;
var incl = excl + tax;
}

if (this.taxConfig.showIncludeTax || this.taxConfig.showBothPrices) {
price = incl;
} else {
price = excl;
}

var str = option.label;
if(price){
if (this.taxConfig.showBothPrices) {
str+= ‘ ‘ + this.formatPrice(excl, true) + ‘ (‘ + this.formatPrice(price, true) + ‘ ‘ + this.taxConfig.inclTaxTitle + ‘)’;
} else {
str+= ‘ ‘ + this.formatPrice(price, true);
}
}
return str;
},

formatPrice: function(price, showSign){
var str = ”;
price = parseFloat(price);
if(showSign){
if(price<0){ str+= '-'; price = -price; } else{ str+= '+'; } } var roundedPrice = (Math.round(price*100)/100).toString(); if (this.prices && this.prices[roundedPrice]) { str+= this.prices[roundedPrice]; } else { str+= this.priceTemplate.evaluate({price:price.toFixed(2)}); } return str; }, clearSelect: function(element){ for(var i=element.options.length-1;i>=0;i–){
element.remove(i);
}
},

getAttributeOptions: function(attributeId){
if(this.config.attributes[attributeId]){
return this.config.attributes[attributeId].options;
}
},

reloadPrice: function(){
var price = 0;
var oldPrice = 0;
for(var i=this.settings.length-1;i>=0;i–){
var selected = this.settings[i].options[this.settings[i].selectedIndex];
if(selected.config){
price += parseFloat(selected.config.price);
oldPrice += parseFloat(selected.config.oldPrice);
}
}

optionsPrice.changePrice(‘config’, {‘price’: price, ‘oldPrice’: oldPrice});
optionsPrice.reload();

return price;

if($(‘product-price-‘+this.config.productId)){
$(‘product-price-‘+this.config.productId).innerHTML = price;
}
this.reloadOldPrice();
},

reloadOldPrice: function(){
if ($(‘old-price-‘+this.config.productId)) {

var price = parseFloat(this.config.oldPrice);
for(var i=this.settings.length-1;i>=0;i–){
var selected = this.settings[i].options[this.settings[i].selectedIndex];
if(selected.config){
price+= parseFloat(selected.config.price);
}
}
if (price < 0) price = 0; price = this.formatPrice(price); if($('old-price-'+this.config.productId)){ $('old-price-'+this.config.productId).innerHTML = price; } } } } [/code]

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *