Notice : Undefined index: url_params in /home/ne3dlthred/needlethread.gr/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 */
var additional_slider = $($('.swiper.additional-images')).data('swiper');
if (additional_slider) {
additional_slider.removeAllSlides();
additional_slides.forEach(function (slide, index) {
additional_slider.appendSlide(slide);
});
additional_slider.update();
}
/* 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_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_thumb,
});
});
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.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(`Stock: ${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('Model: ' + 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 (product.points && product.points != "0"){
price_wrapper.append('Price in reward points: '+product.points+'
');
}
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();
});
/**/