Делаю калькулятор из опций. Опции выводятся в виде изображений, но бяка в том, что при выборе опции, меняется главное фото товара. Как убрать вывод фото опций на главное фото при выборе? Или как сделать, чтоб изображения выбранной опции выводилось в отдельном модуле? Посоветуйте модуль для создания связанных опций.
/* configurable settings */ // IF YOU WANT SWATCH IMAGES, USE THE OPENCART BUILT-IN SWATCH OPTION BY SETTING YOUR OPTION TYPE IN OPENCART TO "IMAGE". // THEN ASSIGN THE SAME IMAGE USED FOR SWATCH TO THE OPTIONS BOOST IMAGE IN THE PRODUCT EDIT AREA. // THAT WILL MAKE IT SWAP THE MAIN IMAGE WHEN CLICKED.
/* Theme Settings */ var img = '#main-image'; // The main image id
var origSrc = ''; var origTitle = ''; var origAlt = ''; var origPopup = '';
if (!window.console) {var console = {};} if (!console.log) {console.log = function() {};}
// Force a change on load to support mods like default product options and any "onload" adjustments jQuery('select[name^="option"] :selected').change(); jQuery('input[name^="option"][type=radio]:checked').change(); jQuery('input[name^="option"][type=checkbox]:checked').change(); });
function getCookie(name) { name += '='; var parts = document.cookie.split(/;\s*/); for (var i = 0; i < parts.length; i++) { var part = parts[i]; if (part.indexOf(name) == 0) return part.substring(name.length) } return null; }
function obUpdate($this) { console.log('Options Boost: obUpdate Called by '+jQuery($this).attr('name'));
// Get Type for determining checked/unchecked for checkbox $checked = true; if ($this.is('input:checkbox') && !$this.is(':checked')) { $checked = false; }
// Set variables... var option_id = $this.attr('id'); var option_name = $this.attr('name'); var option_val = $this.val();
// Remove existing option info jQuery('#option_info').remove(); jQuery('.ob_ajax_error').remove();
//if (jQuery(option).val()) { if (option_val && $checked) {
if (getCookie('isAceshop') == '1') { var ajaxurl = 'index.php?option=com_aceshop&format=raw&tmpl=component&route=produc t/product/updateImage'; } else { var ajaxurl = 'index.php?route=product/product/updateImage'; }
// Update the main image with the new image. var swatch = data.ob_swatch; var thumb = data.ob_thumb; var popup = data.ob_popup; var info = data.ob_info; var stock = data.quantity; var name = data.name;
// Swap Image if exists... if (thumb) { jQuery(img).attr('src', thumb); jQuery(img).attr('title', name); jQuery(img).attr('alt', name); jQuery(img).parent().attr('href', popup); } else { //revert back to main if image not exists jQuery(img).attr('src', origSrc); jQuery(img).attr('title', origTitle); jQuery(img).attr('title', origAlt); jQuery(img).parent().attr('href', origPopup); }
// Add under main image or popup if (info) { xinfo = info.replace("~~", ""); if (info.indexOf("~~") != -1) { alert(xinfo); } jQuery(img).parent().after('<p id="option_info">'+xinfo+'</p>');