');	} if (add_to_cart && allow_add_to_cart) { $('#button-cart').attr('allow_add_to_cart','allow_add_to_cart'); $('#button-cart').click(); } }, error: function(error) { console.log(error); } }); } else { // if there's no selected related options combination - use standard algorithm if (add_to_cart) { $('#button-cart').attr('allow_add_to_cart','allow_add_to_cart'); $('#button-cart').click(); } } }, updateModel : function(){ // ro_set_model var options_values = ro_instance.getOptionValues([]); var ro_ids = ro_instance.getCurrentROIds(options_values); var product_model = "4182"; var model = ""; if (ro_ids.length) { ro_instance.each(ro_instance.ro_data, function(ro_dt){ //for (var i in ro_instance.ro_data) { //	var ro_dt = ro_instance.ro_data[i]; ro_instance.each(ro_ids, function(ro_id){ //for (var j in ro_ids) { //	var ro_id = ro_ids[j]; if (ro_dt['ro'][ro_id] && ro_dt['ro'][ro_id]['model']) { if (ro_instance.ro_settings['spec_model'] == 1) { model = ro_dt['ro'][ro_id]['model']; } else if (ro_instance.ro_settings['spec_model'] == 2 || ro_instance.ro_settings['spec_model'] == 3) { if ( ro_instance.ro_settings['spec_model_delimiter_ro'] && model ) { model+= ro_instance.ro_settings['spec_model_delimiter_ro']; } model+= ro_dt['ro'][ro_id]['model']; } } }); }); } if (model) { if (ro_instance.ro_settings['spec_model'] == 3) { if ( ro_instance.ro_settings['spec_model_delimiter_product'] ) { model = product_model + ro_instance.ro_settings['spec_model_delimiter_product'] + model; } else { model = product_model + model; } } } else { model = product_model; } $('#product_model').html(model); }, updateStockInfo : function() { // ro_set_stock var stock_text = "Availability:"; var stock = "In Stock"; var journal2_stock_status = ''; if ( ro_instance.ro_theme_name == 'revolution' ) { if ( !stock && $('input.product_max').length ) { // quickorder stock = ""; } } else if (ro_instance.ro_theme_name == 'journal2') { journal2_stock_status = ""; } var options_values = ro_instance.getOptionValues([]); var ro_ids = ro_instance.getCurrentROIds(options_values); if (ro_ids.length) { ro_instance.each(ro_instance.ro_data, function(ro_dt){ //for (var i in ro_instance.ro_data) { //	var ro_dt = ro_instance.ro_data[i]; ro_instance.each(ro_ids, function(ro_id){ if (ro_dt['ro'][ro_id] && ro_dt['ro'][ro_id]['stock']) { stock = ro_dt['ro'][ro_id]['stock']; if (ro_instance.ro_theme_name == 'journal2') { journal2_stock_status = ro_dt['ro'][ro_id]['in_stock'] ? 'instock' : 'outofstock'; } return false; } }); }); } if (ro_instance.ro_theme_name == 'journal2') { //journal2 uses specific price and stock update, but it's slow and doesn't swith block class (style) $('#product .p-stock .journal-stock').removeClass('instock, outofstock').addClass(journal2_stock_status); $('#product .p-stock .journal-stock').html(stock); } else if ( ro_instance.ro_theme_name == 'revolution' && $('input.product_max').length ) { // quickorder $('input.product_max').val(stock);	} else if ( ro_instance.ro_theme_name == 'revolution' && $('#product_stock').find('.pr_quantity').length && stock.indexOf('pr_quantity') == -1 ) { $('#product_stock').find('.pr_quantity').html(stock); } else { $('#product_stock').html(stock); } }, // Block Option & journal2 compatibility // show/hide enable/disable options block updateAvailabilityOfBlockAndJournalPushButtons : function() { // ro_check_visibility_of_block_options if (ro_instance.use_block_options || ro_instance.ro_theme_name == 'journal2') { var available_values = []; // block options use SELECTs for select & radio ro_instance.getOptionElement('select[name^="'+ro_instance.option_prefix+'["]').find('option').each( function () { if ($(this).val()) { if (ro_instance.hide_inaccessible) { available_values.push( $(this).val() ); } else { if (! $(this).attr('disabled')) { available_values.push( $(this).val() ); } } } }); // block options use RADIOs for images ro_instance.getOptionElement('input[type=radio][name^="'+ro_instance.option_prefix+'["]').each( function () { if (ro_instance.hide_inaccessible) { if ($(this)[0].style.display != 'none') { available_values.push( $(this).val() ); } } else { if (!$(this).attr('disabled')) { available_values.push( $(this).val() ); } } }); // Product Block Option Module if ( ro_instance.use_block_options) { ro_instance.getOptionElement('a[id^=block-option],a[id^=block-image-option]').each( function () { if ($.inArray($(this).attr('option-value'), available_values) == -1) { $(this).removeClass('block-active'); if (ro_instance.hide_inaccessible) { $(this).hide(); } else { if (!$(this).attr('disabled')) { $(this).attr('disabled', true); $(this).fadeTo("fast", 0.2); } } } else { if (ro_instance.hide_inaccessible) { $(this).show(); } else { if ($(this).attr('disabled')) { $(this).attr('disabled', false); $(this).fadeTo("fast", 1); } } } } ); ro_instance.getOptionElement('a[id^=color-option]').each( function () { if ($.inArray($(this).attr('optval'), available_values) == -1) { $(this).removeClass('color-active'); if (ro_instance.hide_inaccessible) { $(this).hide(); } else { if (!$(this).attr('disabled')) { $(this).attr('disabled', true); $(this).fadeTo("fast", 0.2); } } } else { if (ro_instance.hide_inaccessible) { $(this).show(); } else { if ($(this).attr('disabled')) { $(this).attr('disabled', false); $(this).fadeTo("fast", 1); } } } } ); } // Journal2 if ( ro_instance.ro_theme_name == 'journal2' ) { $('#product').find('li[data-value]').each(function() { if ($.inArray($(this).attr('data-value'), available_values) == -1) { $(this).removeClass('selected'); if (ro_instance.hide_inaccessible) { $(this).hide(); } else { if (!$(this).attr('disabled')) { $(this).attr('disabled', true); $(this).fadeTo("fast", 0.2); } } } else { if (ro_instance.hide_inaccessible) { $(this).show(); } else { if ($(this).attr('disabled')) { $(this).attr('disabled', false); $(this).fadeTo("fast", 1); } } } // change standart Journal2 function $(this).unbind('click'); $(this).click(function () { if ($(this).attr('disabled')) { return; } var product_option_value_id = $(this).attr('data-value'); $(this).siblings().removeClass('selected'); $(this).addClass('selected'); $(this).parent().siblings('select').find('option[value="' + product_option_value_id + '"]').attr('selected', 'selected'); $(this).parent().siblings('select').trigger('change'); $(this).parent().parent().find('.radio input[type=radio][name^="'+ro_instance.option_prefix+'"]').attr('checked', false); $(this).parent().parent().find('.radio input[type=radio][name^="'+ro_instance.option_prefix+'"][value="'+product_option_value_id+'"]').attr('checked', true).trigger('change'); if (Journal.updatePrice) { Journal.updateProductPrice(); } // compatibility with Product Option Image extension (by another developer) if ( typeof(selectvalue) == 'function' ) { selectvalue(product_option_value_id); } }); }); } } }, // << EVENT/TRIGGER FUNCTIONS event_setOptionValue_after : function(event, product_option_id, product_option_value_id, $touched_elems) { // ro_event_setOptionValue_after if ( $touched_elems && $touched_elems.length && $touched_elems.is(':radio') ) { } ro_instance.common_fn.piodd_setValue(product_option_id, product_option_value_id); ro_instance.common_fn.journal2_makeOptionValueSelected(product_option_value_id); }, event_init_after : function(event) { // ro_event_init_after ro_instance.getOptionElement('[name^="quantity_per_option["]').change(function(){ ro_functions.stockControl(0); }); $("input[type=text][name=quantity], input[type=number][name=quantity]").change(function(){ ro_functions.stockControl(0); }); if (ro_instance.ro_theme_name == 'journal') { // compatibility for live price update with specials in related options var div_prod_opt = $('div.product-options'); if (div_prod_opt.length == 1) { if ( div_prod_opt.find('div.price').find('span.product-price').length ) { div_prod_opt.find('div.price').find('span.product-price').after(''); } else if ($('div.price').find('span.price-old').length) { div_prod_opt.find('div.price').find('span.price-old').before(''); } setInterval( function() { if ( div_prod_opt.find('div.price').find('span.product-price').html() && div_prod_opt.find('div.price').find('span.price-old').html() && div_prod_opt.find('div.price').find('span.price-new').html() ) { if ( div_prod_opt.find('div.price').find('span.price-old').html() == div_prod_opt.find('div.price').find('span.price-new').html() || Number($('div.product-options').find('div.price').find('span.price-new').html().replace(/\D/g, '')) == 0 ) { div_prod_opt.find('div.price').find('span.price-old').hide(); div_prod_opt.find('div.price').find('span.price-new').hide(); div_prod_opt.find('div.price').find('span.product-price').show(); } else { div_prod_opt.find('div.price').find('span.price-old').show(); div_prod_opt.find('div.price').find('span.price-new').show(); div_prod_opt.find('div.price').find('span.product-price').hide(); } } }, 200 ); } } if (ro_instance.ro_theme_name == 'journal3') { $().ready(function(){ setTimeout(function(){ if ( ro_instance.hasSelectedOptions() ) { ro_instance.controlAccessToValuesOfAllOptions(); } }, 1); }); } }, event_setAccessibleOptionValues_select_after : function (event, product_option_id) { var $select_element = ro_instance.getOptionElement('select[name="'+ro_instance.option_prefix+'['+product_option_id+']"]'); if ( $select_element.data('_styler') ) { $select_element.trigger('refresh'); } // nice-select if ( $select_element.next().is('.nice-select') && typeof($.fn.niceSelect) == 'function' ) { $select_element.niceSelect('update'); } // fancy-select if ( $select_element.parent().is('.fancy-select') ) { $select_element.trigger('disable'); $select_element.parent().find('ul.options').html(''); $select_element.trigger('enable'); } if ( $.fn.customSelect ) { $select_element.trigger('render'); $select_element.trigger('update'); // older customSelect version } }, event_setAccessibleOptionValues_radioUncheck_after : function(event, elem_to_uncheck) { if ( elem_to_uncheck.length ) { if ( ro_instance.ro_theme_name == 'fastor' && elem_to_uncheck.siblings('span').length && ( !elem_to_uncheck.is(':visible') || elem_to_uncheck.css('visibility') == 'hidden' ) ) { // specific selectors - button-style elem_to_uncheck.siblings('span').removeClass('active'); } if ( elem_to_uncheck.data('iCheck') ) { // radio and checkboxes nicer elem_to_uncheck.iCheck(); } } // << Product Image Option DropDown compatibility var option_id = ro_instance.getProductOptionIdFromName( elem_to_uncheck.attr('name') ); ro_instance.common_fn.piodd_setValue(option_id, ''); // >> Product Image Option DropDown compatibility }, event_setAccessibleOptionValues_radioToggle_after : function(event, option_id, $radio) { // << Product Image Option DropDown compatibility var piodd_option_div = $('#image-option-'+option_id); var piodd_value = piodd_option_div.find('ul.dd-options input.dd-option-value[value='+$radio.val()+']'); if (piodd_value.length) { piodd_value.parent().toggle(!option_value_disabled); } // >> Product Image Option DropDown compatibility }, event_setAccessibleOptionValues_radioEnableDisable_after : function(event, option_id, $radio) { if ( ro_instance.ro_theme_name == 'theme628' ) { // additionally, always opacity = 1 $radio.siblings('label').fadeTo("fast", 1); } var option_id = ro_instance.getProductOptionIdFromName($radio.attr('name')); // << Product Image Option DropDown compatibility // make copies of unavailable elements, originals hide in hidden div, when element became available again - place it back var piodd_option_div = $('#image-option-'+option_id); if ( piodd_option_div.find('ul.dd-options').length ) { var ro_hidden_div_id = piodd_option_div.attr('id')+'-ro-hidden'; if ( !$('#'+ro_hidden_div_id).length ) { piodd_option_div.after('