Notice : Undefined index: url_params in /homepages/40/d707000689/htdocs/iadiy_online/catalog/controller/extension/module/options_combinations.php on line 33 /**/
function DefaultCombinationEngine(){
CombinationEngine.call(this);
}
DefaultCombinationEngine.prototype = Object.create(CombinationEngine.prototype);
DefaultCombinationEngine.prototype.reset_combined_option_images = function () {
var additional = initial_additional_slides.length ? initial_additional_slides : initial_additional_popup_images;
this.include_to_gallery(initial_main_slides, additional, initial_gallery_images);
};
DefaultCombinationEngine.prototype.include_to_gallery = function (main_slides, additional_slides, gallery_images) {
/* include to main */
var main_slider = $($('.swiper.main-image')).data('swiper');
if (main_slider) {
main_slider.removeAllSlides();
main_slides.forEach(function (slide) {
main_slider.appendSlide(slide);
});
main_slider.update();
}
/* include to additional */
if( $('.swiper.additional-images').length == 0 && j3_config.carousel ) {
var _style = j3_config.direction == 'vertical' ? `style="width: ${j3_config.imageDimensionsAdditional.width}px;"` : '';
var _rtl = j3_config.isRTL ? 'dir="rtl"' : '';
var additional_images_template = `
`;
$('.swiper.main-image').after(additional_images_template);
this.init_swiper_gallery('.swiper.additional-images');
}
var additional_slider = $($('.swiper.additional-images')).data('swiper');
if( additional_slider ) {
additional_slider.removeAllSlides();
if( additional_slides.length > 0 ) {
additional_slides.forEach(function(slide, index) {
additional_slider.appendSlide(slide);
});
additional_slider.update();
} else {
$('.swiper.additional-images').remove();
}
}
/* include to additional popup images */
var additional_popup_images_container = $('.product-image > div.additional-images:not(.swiper)');
if( additional_popup_images_container.length == 0 && additional_slides.length > 0 && !j3_config.carousel ) {
$('.swiper.main-image').after('
');
additional_popup_images_container = $('.product-image > div.additional-images:not(.swiper)');
}
if (additional_popup_images_container.length > 0){
additional_popup_images_container.empty();
additional_slides.forEach(function (slide, index) {
additional_popup_images_container.append(slide);
});
}
if (gallery_images) {
if ($('div.lightgallery.lightgallery-product-images').length) {
var image_for_gallery = [];
gallery_images.forEach(function (image, index) {
image_for_gallery.push({
'src': image.image_popup,
'thumb': image.image_thumb,
'subHtml': ''
});
});
var original = $('div.lightgallery.lightgallery-product-images');
var options = original.attr('data-options');
original.after('
');
original.remove();
$('div.temp_copy_lightgallery-product-images').attr('class', 'lightgallery lightgallery-product-images').attr('data-options',options);
}
}
var gallery = $($('[data-gallery]').data('gallery'));
if (gallery_images){
gallery.data('images', gallery_images);
gallery.data('index', gallery_images.length);
}
/* Product Page */
if ($('html').hasClass('route-product-product')) {
/* sync image carousels */
$(document).delegate('.additional-image', 'click', function () {
$('.additional-image').removeClass('swiper-slide-active');
$(this).addClass('swiper-slide-active');
var $s = $('.main-image').data('swiper');
if ($s.params.loop) {
$s.slideToLoop($(this).data('index'), 0);
} else {
$s.slideTo($(this).data('index'), 0);
}
});
/* image zoom */
if (!('ontouchstart' in document)) {
if (Journal['isPopup'] ? Journal['quickviewPageStyleCloudZoomStatus'] : Journal['productPageStyleCloudZoomStatus']) {
$('.main-image img').each(function () {
var $this = $(this);
$this.ImageZoom({
type: Journal['isPopup'] ? Journal['quickviewPageStyleCloudZoomPosition'] : Journal['productPageStyleCloudZoomPosition'],
showDescription: false,
offset: [0, 0],
zoomSize: [$this.width(), $this.height()],
bigImageSrc: $this.data('largeimg')
});
});
/* delay mouseover */
$('.product-image').mouseover(function () {
$('.zm-viewer').delay(200).queue(function (next) {
$(this).css('opacity', '1');
next();
});
}).mouseleave(function () {
$('.zm-viewer').css('opacity', '0');
});
}
}
}
};
DefaultCombinationEngine.prototype.add_combined_option_images = function (images) {
if (images.length){
$('div.zm-handler, div.zm-viewer').remove();
var main_slides = [];
images.forEach(function (image, index) {
main_slides.push(``);
});
var additional_slides = [];
images.forEach(function (image, index) {
additional_slides.push(``);
});
var gallery_images = [];
images.forEach(function (image) {
gallery_images.push({
src: image.image_popup,
subHtml: '',
thumb: image.image_additional,
});
});
this.include_to_gallery(main_slides, additional_slides, gallery_images);
} else {
this.reset_combined_option_images();
}
};
DefaultCombinationEngine.prototype.remove_combined_option_images = function () {
$(images_selector).html('');
};
DefaultCombinationEngine.prototype.init_swiper_gallery = function(selector) {
if(is_quick_view)
return false;
var $this = $(selector);
var itemsPerRow = { 0: {items: 1, spacing: 0} };
var breakpoints = {};
$.each(itemsPerRow, function (v, k) {
breakpoints[v] = {
slidesPerView: parseInt(k.items, 10),
slidesPerGroup: parseInt(k.items, 10),
spaceBetween: parseInt(k.spacing, 10)
}
});
var options = $.extend({
init: false,
slidesPerView: parseInt(itemsPerRow[0].items, 10),
slidesPerGroup: parseInt(itemsPerRow[0].items, 10),
spaceBetween: parseInt(itemsPerRow[0].spacing, 10),
breakpoints: breakpoints,
observer: true,
observeParents: true,
paginationClickable: true,
preventClicks: false,
preventClicksPropagation: false,
simulateTouch: true,
watchSlidesProgress: true,
watchSlidesVisibility: true,
navigation: {
nextEl: $this.find('.swiper-button-next'),
prevEl: $this.find('.swiper-button-prev')
},
pagination: {
el: $this.find('.swiper-pagination'),
type: 'bullets',
clickable: true
},
scrollbar: $this.find('.swiper-scrollbar'),
scrollbarHide: false,
scrollbarDraggable: true
}, $this.data('options'));
if( options.loop && ($(selector).find('.swiper-slide').length < 2) ) {
options.loop = false;
}
if( !Journal.isDesktop ) {
options.a11y = false;
}
var swiper = new Swiper($('.swiper-container', selector), options);
function checkPages() {
if( $('.product-image').hasClass('direction-vertical') && $this.hasClass('additional-images') ) {
var height = Journal['isPopup'] ? Journal['quickviewPageStyleAdditionalImagesHeightAdjustment'] : Journal['productPageStyleAdditionalImagesHeightAdjustment'];
var interval = setInterval(function() {
var imageHeight = $('.main-image .swiper-slide-visible img').outerHeight();
if( imageHeight ) {
$this.css('height', imageHeight + (parseInt(height, 10) || 0));
swiper.update();
clearInterval(interval);
$('.product-image').addClass('additional-images-loaded');
}
}, 1000);
}
if( swiper.isBeginning && swiper.isEnd ) {
$this.removeClass('swiper-has-pages');
} else {
$this.addClass('swiper-has-pages');
}
}
swiper.on('init', checkPages);
swiper.on('resize', checkPages);
swiper.init();
if( options.autoplay ) {
// pause on hover
if( options.pauseOnHover ) {
$('.swiper-container', this).hover(function() {
swiper.autoplay.stop();
}, function() {
swiper.autoplay.start();
});
}
// stop autoplay for elements not in viewport
swiper.on('observerUpdate', function() {
var visible = $(swiper.$el).is(':visible');
var running = swiper.autoplay.running;
if( visible && !running ) {
swiper.autoplay.start();
}
if( !visible && running ) {
swiper.autoplay.stop();
}
});
}
swiper.on('observerUpdate', function() {
Journal.lazyLoadInstance && Journal.lazyLoadInstance.update();
});
$this.data('swiper', swiper);
};
DefaultCombinationEngine.prototype.reset_data = function (reset_image=true) {
$(prices_group_selector).html(initial_product_price);
$(product_data_group_selector).html(initial_product_data);
/* add_to_cart_button.attr("disabled", true); */
/* var current_elements = $('div.col-sm-4 > ul.list-unstyled'); */
/* current_elements.remove(); */
$(elements_placeholder_selector).after(orig_elements);
if (reset_image){
this.reset_combined_option_images();
}
};
DefaultCombinationEngine.prototype.use_variant_data = function (selected_options) {
/* $(button_cart_selector).removeAttr("disabled"); */
var variant = this.get_combination_by_options(selected_options);
if (variant){
/* var current_elements = $(orig_elements_selector); */
/* current_elements.remove(); */
var data_element = $('');
var exists_manufacturer = $('div.product-stats').find('.product-manufacturer').length;
var exists_weight = $('div.product-stats').find('.product-weight').length;
data_element.append(`Deliver Time: ${this.get_stock(variant)} `);
if (product.manufacturer && !manufacturer_data_as_image.length && exists_manufacturer){
data_element.append('Brand: '+product.manufacturer+' ');
}
if (this.get_reward_points(variant)){
data_element.append('Reward Points: ' + this.get_reward_points(variant) + ' ');
}
if (this.get_model(variant)) {
data_element.append('Product ID: ' + this.get_model(variant) + ' ');
}
if (this.get_weight(variant) && exists_weight) {
data_element.append('Weight: ' + this.get_weight(variant) + ' ');
}
if (this.get_dimensions(variant)){
data_element.append(''+this.get_dimensions(variant)+' ');
}
if (this.get_sku(variant)){
data_element.append('SKU: ' + this.get_sku(variant) + ' ');
}
if (this.get_upc(variant)){
data_element.append('UPC: ' + this.get_upc(variant) + ' ');
}
if (this.get_extra_text(variant)){
data_element.append(''+this.get_extra_text(variant)+' ');
}
var product_stats_element = $('.product-stats');
product_stats_element.empty();
product_stats_element.append(data_element);
if (product.manufacturer && manufacturer_data_as_image.length && exists_manufacturer){
product_stats_element.append(manufacturer_data_as_image);
}
if (initial_custom_stats){
product_stats_element.append(initial_custom_stats);
}
var price_wrapper = $('.price-wrapper');
price_wrapper.empty();
var price_group = $('
');
price_group.append(`${this.get_price(variant)}
`);
if (this.get_old_price(variant)) {
price_group.append(''+this.get_old_price(variant)+'
');
}
price_wrapper.append(price_group);
if (this.get_tax(variant)){
price_wrapper.append('Ex Tax: '+this.get_tax(variant)+'
');
}
if( this.get_points(variant) && this.get_points(variant) != "0") {
price_wrapper.append('Price in reward points: '+this.get_points(variant)+'
');
}
if(variant.option_discount.length){
var discounts_wrapper = $('
');
variant.option_discount.forEach(function (discount) {
discounts_wrapper.append(''+discount.quantity+' or more '+discount.price_formatted+'
');
});
price_wrapper.append(discounts_wrapper);
}
} else {
this.reset_data(reset_image=false);
}
};
DefaultCombinationEngine.prototype.get_dimensions = function (variant) {
var dimensions_length = parseFloat(variant.length);
var dimensions_width = parseFloat(variant.width);
var dimensions_height = parseFloat(variant.height);
var dimensions_text_arr = [];
if (dimensions_length){
dimensions_text_arr.push(`${dimensions_length.toFixed(2)}${text_dimensions_length_default}`);
}
if (dimensions_width){
dimensions_text_arr.push(`${dimensions_width.toFixed(2)}${text_dimensions_width_default}`);
}
if (dimensions_height){
dimensions_text_arr.push(`${dimensions_height.toFixed(2)}${text_dimensions_height_default}`);
}
var dimensions_text = dimensions_text_arr.join(' x ');
if (dimensions_text.length){
dimensions_text = `${text_dimensions_default} ${dimensions_text} `;
}
return dimensions_text;
};
function getOptionHtml(option) {
var html_option = '';
if (options_like_images && options_like_images_option_fields.includes(option.option_id)){
html_option = `
${option.name}
${ text_select }
`;
$.each(option.product_option_value, function(key, option_value) {
var image_src = '';
if (options_like_images_image == 0){
if (option_value.image){
image_src = option_value.image;
}
} else if (option_value.opt_image){
image_src = option_value.opt_image;
}
html_option += `
${ option_value.name }
`;
});
html_option += `
`;
} else if (options_like_list && options_like_list_option_fields.includes(option.option_id)) {
html_option = `
${option.name}
${ text_select }
`;
$.each(option.product_option_value, function(key, option_value) {
html_option += `
${ option_value.name }
`;
});
html_option += `
`;
} else {
if (option.type == 'select'){
html_option = `
${option.name}
${ text_select }
`;
$.each(option.product_option_value, function(key, option_value) {
html_option += `
${ option_value.name }
`;
});
html_option += `
`;
}
if (option.type == 'radio' || option.type == 'checkbox'){
html_option = `
`;
}
}
return html_option;
}
/* function getOptions(){
var options = '';
product_options.forEach(function (option) {
options += getOptionHtml(option);
});
options += '
';
return options;
}
$('div.product-options').append(getOptions()); */
var default_combination_engine = new DefaultCombinationEngine();
default_combination_engine.include_styles();
default_combination_engine.include_error_wrapper();
default_combination_engine.include_imagepicker();
default_combination_engine.register_on_input_change();
default_combination_engine.register_reset_options();
/*default_combination_engine.check_only_one_combination();*/
default_combination_engine.register_add_cart_call(
null,
function (event, xhr, settings, json, call_url) {
var scroll = function () {
$([document.documentElement, document.body]).animate({
scrollTop: $(".options-combinations-error").offset().top - 85
}, 500);
};
if(call_url && call_url.includes(settings.url) && json && json.error){
if(json.error.quantity){
scroll();
} else if (json.error.require_combination){
scroll();
} else if (json.error.invalid_combination) {
scroll();
}
}
}
);
$(document).off('change', '.product-options input[type="radio"], .product-options input[type="checkbox"], .product-options select, #product-quantity');
$(document).on('change', '.product-options input[type="radio"], .product-options input[type="checkbox"], .product-options select, #product-quantity', function (e) {
e.stopImmediatePropagation();
});
/* add quantity from url parameter */
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
var product_quantity = getUrlParameter('product_quantity');
if ($.isNumeric(product_quantity)){
$('#product-quantity').val(product_quantity);
}
default_combination_engine.start();
});
/**/