jQuery(function($) { function APIloader() { if(!window.frontAPI) { setTimeout(APIloader,0); } else { var hotbasket_config = {"id":"283","0":"283","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"1","2":"1","border":"1","3":"1","border_thickness":"1","4":"1","border_color":"#6223d7","5":"#6223d7","font_color":"#242424","6":"#242424","font_size":"14","7":"14","custom_container":"","8":"","date_modified":"2022-02-08 10:35:58","9":"2022-02-08 10:35:58"}; var hotbasket_products = [{"id":"1366","0":"1366","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1509","3":"1509","shoper_product_name":"Boguchwa\u0142ki CHOCO \u2013 galaretki w czekoladzie","4":"Boguchwa\u0142ki CHOCO \u2013 galaretki w czekoladzie","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Boguchwa\u0142ki Choco","8":"Boguchwa\u0142ki Choco","hbprod_description":"Dodaj s\u0142odycze Boguchwa\u0142ki Choco - s\u0142odk\u0105 nowo\u015b\u0107 w \u015bwietnej cenie!","9":"Dodaj s\u0142odycze Boguchwa\u0142ki Choco - s\u0142odk\u0105 nowo\u015b\u0107 w \u015bwietnej cenie!","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2022-10-27 11:35:33","13":"2022-10-27 11:35:33"},{"id":"2112","0":"2112","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1663","3":"1663","shoper_product_name":"Opowiastki Bo\u017conarodzeniowe","4":"Opowiastki Bo\u017conarodzeniowe","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Opowiastki Bo\u017conarodzeniowe ","8":"Opowiastki Bo\u017conarodzeniowe ","hbprod_description":",,Wigilia\" + ,,Trzej kr\u00f3lowie\" - ksi\u0105\u017ceczki na d\u0142ugie, zimowe wieczory z dzie\u0107mi, teraz w zestawie!","9":",,Wigilia\" + ,,Trzej kr\u00f3lowie\" - ksi\u0105\u017ceczki na d\u0142ugie, zimowe wieczory z dzie\u0107mi, teraz w zestawie!","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2023-10-30 09:27:44","13":"2023-10-30 09:27:44"},{"id":"2115","0":"2115","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"1","2":"1","shoper_product_id":"1505","3":"1505","shoper_product_name":"Czekolada mleczna - prawdziwy \u015bw. Miko\u0142aj","4":"Czekolada mleczna - prawdziwy \u015bw. Miko\u0142aj","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Czekolada prawdziwego \u015bw. Miko\u0142aj","8":"Czekolada prawdziwego \u015bw. Miko\u0142aj","hbprod_description":"Dodaj mleczn\u0105 czekolad\u0119 prawdziwego \u015bw. Miko\u0142aja - s\u0142odki dodatek do prezentu!","9":"Dodaj mleczn\u0105 czekolad\u0119 prawdziwego \u015bw. Miko\u0142aja - s\u0142odki dodatek do prezentu!","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2023-11-09 13:35:48","13":"2023-11-09 13:35:48"},{"id":"2211","0":"2211","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1652","3":"1652","shoper_product_name":"Wigilia - Bo\u017conarodzeniowe opowiastki familijne","4":"Wigilia - Bo\u017conarodzeniowe opowiastki familijne","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Wigilia - opowiastki familijne","8":"Wigilia - opowiastki familijne","hbprod_description":"Dodaj ,,Wigili\u0119\" - ciep\u0142\u0105 opowie\u015b\u0107 o jednym z najpi\u0119kniejszych dni w ca\u0142ym roku!","9":"Dodaj ,,Wigili\u0119\" - ciep\u0142\u0105 opowie\u015b\u0107 o jednym z najpi\u0119kniejszych dni w ca\u0142ym roku!","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2023-12-07 14:30:19","13":"2023-12-07 14:30:19"},{"id":"2218","0":"2218","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1616","3":"1616","shoper_product_name":"HOLY GAME","4":"HOLY GAME","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Holy Game","8":"Holy Game","hbprod_description":"Dodaj \u015bwietn\u0105 ksi\u0105\u017ck\u0119 dla m\u0142odzie\u017cy ,,Holy Game\" - w rewelacyjnej cenie!","9":"Dodaj \u015bwietn\u0105 ksi\u0105\u017ck\u0119 dla m\u0142odzie\u017cy ,,Holy Game\" - w rewelacyjnej cenie!","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2023-12-11 07:08:48","13":"2023-12-11 07:08:48"},{"id":"2345","0":"2345","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1704","3":"1704","shoper_product_name":"Sound of Freedom. D\u017awi\u0119k wolno\u015bci","4":"Sound of Freedom. D\u017awi\u0119k wolno\u015bci","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Sound of Freedom. D\u017cwi\u0119k wolno\u015bci DVD","8":"Sound of Freedom. D\u017cwi\u0119k wolno\u015bci DVD","hbprod_description":"Jeden z najwi\u0119kszych filmowych fenomen\u00f3w wsp\u00f3\u0142czesnego kina ju\u017c na DVD! ","9":"Jeden z najwi\u0119kszych filmowych fenomen\u00f3w wsp\u00f3\u0142czesnego kina ju\u017c na DVD! ","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2024-01-08 14:43:16","13":"2024-01-08 14:43:16"},{"id":"2357","0":"2357","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1516","3":"1516","shoper_product_name":"Ksi\u0119ga B\u0142ogos\u0142awie\u0144stw (limitowana wersja z imienn\u0105 personalizacj\u0105- w\u0142asnor\u0119cznym podpisem Autora) i kosztami wysy\u0142ki","4":"Ksi\u0119ga B\u0142ogos\u0142awie\u0144stw (limitowana wersja z imienn\u0105 personalizacj\u0105- w\u0142asnor\u0119cznym podpisem Autora) i kosztami wysy\u0142ki","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Ksi\u0119ga B\u0142ogos\u0142awie\u0144stw - z dedykacj\u0105 autora","8":"Ksi\u0119ga B\u0142ogos\u0142awie\u0144stw - z dedykacj\u0105 autora","hbprod_description":"Dodaj Ksi\u0105\u017ck\u0119 Tygodnia z imienn\u0105 personalizacj\u0105 oraz w\u0142asnor\u0119cznym podpisem Autora w rewelacyjnej cenie!","9":"Dodaj Ksi\u0105\u017ck\u0119 Tygodnia z imienn\u0105 personalizacj\u0105 oraz w\u0142asnor\u0119cznym podpisem Autora w rewelacyjnej cenie!","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2024-01-15 07:19:40","13":"2024-01-15 07:19:40"},{"id":"2361","0":"2361","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1716","3":"1716","shoper_product_name":"The Chosen. Wezwani po imieniu - komiks sezon 1","4":"The Chosen. Wezwani po imieniu - komiks sezon 1","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"The Chosen. Wezwani po imieniu - komiks sezon 1","8":"The Chosen. Wezwani po imieniu - komiks sezon 1","hbprod_description":"Nowo\u015b\u0107! Komiks The Chosen. Wezwani po imieniu. ","9":"Nowo\u015b\u0107! Komiks The Chosen. Wezwani po imieniu. ","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2024-01-19 08:23:59","13":"2024-01-19 08:23:59"},{"id":"2456","0":"2456","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1739","3":"1739","shoper_product_name":"B\u0142ogos\u0142awiony J\u00f3zef Ulma. Opowie\u015b\u0107 pisana \u017cyciem","4":"B\u0142ogos\u0142awiony J\u00f3zef Ulma. Opowie\u015b\u0107 pisana \u017cyciem","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"B\u0142ogos\u0142awiony J\u00f3zef Ulma. Opowie\u015b\u0107 pisana \u017cyciem","8":"B\u0142ogos\u0142awiony J\u00f3zef Ulma. Opowie\u015b\u0107 pisana \u017cyciem","hbprod_description":"Dodaj ksi\u0105\u017ck\u0119 o B\u0142ogos\u0142awionym J\u00f3zefie Ulma w wyj\u0105tkowej cenie!","9":"Dodaj ksi\u0105\u017ck\u0119 o B\u0142ogos\u0142awionym J\u00f3zefie Ulma w wyj\u0105tkowej cenie!","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2024-03-25 11:46:44","13":"2024-03-25 11:46:44"},{"id":"2458","0":"2458","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1710","3":"1710","shoper_product_name":"Ulmowie. Rodzina pe\u0142na mi\u0142o\u015bci ","4":"Ulmowie. Rodzina pe\u0142na mi\u0142o\u015bci ","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Ulmowie. Rodzina pe\u0142na mi\u0142o\u015bci","8":"Ulmowie. Rodzina pe\u0142na mi\u0142o\u015bci","hbprod_description":"W ksi\u0105\u017cce zawarto wyj\u0105tkowy prezent! Specjalnie dla ma\u0142ych czytelnik\u00f3w do\u0142\u0105czono modlitw\u0119 do Anio\u0142a Str\u00f3\u017ca, kt\u00f3r\u0105 modli\u0142y si\u0119 b\u0142ogos\u0142awione dzieci Ulm\u00f3w.","9":"W ksi\u0105\u017cce zawarto wyj\u0105tkowy prezent! Specjalnie dla ma\u0142ych czytelnik\u00f3w do\u0142\u0105czono modlitw\u0119 do Anio\u0142a Str\u00f3\u017ca, kt\u00f3r\u0105 modli\u0142y si\u0119 b\u0142ogos\u0142awione dzieci Ulm\u00f3w.","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2024-03-25 11:51:16","13":"2024-03-25 11:51:16"},{"id":"2679","0":"2679","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"1","2":"1","shoper_product_id":"1808","3":"1808","shoper_product_name":"Nazajutrz w Markowej - \u017bycie po zbrodni na Rodzinie Ulm\u00f3w","4":"Nazajutrz w Markowej - \u017bycie po zbrodni na Rodzinie Ulm\u00f3w","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Nazajutrz w Markowej. \u017bycie po zbrodni na Rodzinie Ulm\u00f3w","8":"Nazajutrz w Markowej. \u017bycie po zbrodni na Rodzinie Ulm\u00f3w","hbprod_description":"Dodaj ksi\u0105\u017ck\u0119 \"Nazajutrz w Markowej\" - przepi\u0119kn\u0105 opowie\u015b\u0107 o tym, \u017ce \u201ekto ratuje jedno \u017cycie \u2013 ratuje ca\u0142y \u015bwiat\u201d.","9":"Dodaj ksi\u0105\u017ck\u0119 \"Nazajutrz w Markowej\" - przepi\u0119kn\u0105 opowie\u015b\u0107 o tym, \u017ce \u201ekto ratuje jedno \u017cycie \u2013 ratuje ca\u0142y \u015bwiat\u201d.","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2024-11-04 09:13:50","13":"2024-11-04 09:13:50"},{"id":"2680","0":"2680","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1457","3":"1457","shoper_product_name":"Boguchwa\u0142ki - galaretki w cukrze z sokiem malinowym (BCH002)","4":"Boguchwa\u0142ki - galaretki w cukrze z sokiem malinowym (BCH002)","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Boguchwa\u0142ki","8":"Boguchwa\u0142ki","hbprod_description":"Dodaj s\u0142odkie galaretki w cukrze z sokiem malinowym - s\u0142odko\u015b\u0107 w \u015bwietnej cenie.","9":"Dodaj s\u0142odkie galaretki w cukrze z sokiem malinowym - s\u0142odko\u015b\u0107 w \u015bwietnej cenie.","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2024-11-04 09:16:48","13":"2024-11-04 09:16:48"},{"id":"2681","0":"2681","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"0","2":"0","shoper_product_id":"1798","3":"1798","shoper_product_name":"Kalendarz Teoba\u0144kologii 2025","4":"Kalendarz Teoba\u0144kologii 2025","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Kalendarz Teoba\u0144kologii 2025","8":"Kalendarz Teoba\u0144kologii 2025","hbprod_description":"Dodaj nowy Kalendarz Teoba\u0144kologii na 2025 rok.","9":"Dodaj nowy Kalendarz Teoba\u0144kologii na 2025 rok.","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2024-11-04 11:15:00","13":"2024-11-04 11:15:00"},{"id":"2687","0":"2687","shop_id":"c99e43d07b5435222c8b1af12717e84e9f914e2e","1":"c99e43d07b5435222c8b1af12717e84e9f914e2e","active":"1","2":"1","shoper_product_id":"1799","3":"1799","shoper_product_name":"Kalendarz adwentowy","4":"Kalendarz adwentowy","shoper_category_id":"0","5":"0","shoper_category_name":"","6":"","limit_category":"0","7":"0","hbprod_title":"Kalendarz adwentowy","8":"Kalendarz adwentowy","hbprod_description":"Dodaj kalendarz adwentowy \"Boski adwent\" - drobny upominek, kt\u00f3ry os\u0142odzi czas oczekiwania na \u015awi\u0119ta!","9":"Dodaj kalendarz adwentowy \"Boski adwent\" - drobny upominek, kt\u00f3ry os\u0142odzi czas oczekiwania na \u015awi\u0119ta!","hbprod_tooltip":"","10":"","hbprod_icon":"<\/i>","11":"<\/i>","default_checked":"0","12":"0","date_modified":"2024-11-12 10:55:59","13":"2024-11-12 10:55:59"}]; //przygotowanie zmiennych konfiguracyjnych var active = null; var border = null; var border_thickness = null; var border_color = null; var font_color = null; var font_size = null; var custom_container = null; var default_checked = null; $.each(hotbasket_config, function(index, value){ //each po tablicy z konfiguracja if(index == 'active')active=value; if(index == 'border')border=value; if(index == 'border_thickness')border_thickness=value; if(index == 'border_color')border_color=value; if(index == 'font_color')font_color=value; if(index == 'font_size')font_size=value; if(index == 'custom_container')custom_container=value; }); if(active == 1 && $('body').hasClass('shop_basket')){ //jesli dodatek jest wlaczony oraz skrypt znajduje sie w koszyku //tworzenie elementów hotbasket i ustawienie podstawowej konfiguracji $.each(hotbasket_products, function(index, value){ //each po tablicy z produktami hotbasket var active_product = parseInt(value['active']); var product_id = parseInt(value['shoper_product_id']); var default_checked = parseInt(value['default_checked']); if(active_product){ //jesli produkt jest aktywny //pobieranie informacji o produkcie z API var product = frontAPI.getProduct({ id: product_id }); if(!product['name']){ console.log("Maxsote Hotbasket Error - Product not found, ERROR CODE: PID"+product_id); }else{ var product_price = product['price']['gross']['final']; var shoper_product_name = product['name']; //tworzenie elementu var hotbasket_element = $('
').attr( { 'data-name': "maxsote_hotbasket" }).css( { "width": "100%", "padding": "10px 0", "margin": "10px 0", "color": font_color, "font-size": font_size+"pt", "position" : "static", "box-sizing" : "initial", "display" : "flex", "align-items" : "center" } ); //czekanie na soobasket, jesli istnieje if(typeof GlobalSoolutionSoobasket != 'undefined'){ shoper.addEvent("soobasket:loaded", function(event, basket){ hotbasket_element.insertAfter(".el-table__body"); }); } //ustalenie pozycji hotbasket if(custom_container!=="" || custom_container!=false){ //jesli jest ustalony custom container hotbasket_element.appendTo(custom_container); }else{ hotbasket_element.insertAfter("table.productlist"); } //sprawdzenie czy jest limit do kategorii if(value['shoper_category_id']!=0){ hotbasket_element.attr('data-limit_category', value['shoper_category_id']); } //uzupelnianie hotbasket trescia if($.trim(value['hbprod_icon']) != ""){ $("
").html(value['hbprod_icon']).appendTo(hotbasket_element); } $("
").appendTo(hotbasket_element); var hotbasket_kaprow = hotbasket_element.find(".kap_row"); $("
").appendTo(hotbasket_kaprow); var hotbasket_kaprow_upper = hotbasket_kaprow.find(".kr_upper"); $("").appendTo(hotbasket_kaprow_upper); var hotbasket_kaprow_cwrap = hotbasket_kaprow_upper.find(".checkbox-wrap"); var additional_product_id = product_id; var checked = ""; var disabled = "" $(".productlist tbody tr").each(function(){ var basket_product_id = $(this).data("product-id"); if(parseInt(additional_product_id) == parseInt(basket_product_id)){ checked = "checked='checked'"; } if(default_checked==1){ checked = "checked='checked'"; disabled = "disabled"; } }); $("").appendTo(hotbasket_kaprow_cwrap); $("").appendTo(hotbasket_kaprow_cwrap); $("").appendTo(hotbasket_kaprow_upper); var hotbasket_kaprow_desc = hotbasket_kaprow_upper.find(".desc"); //sprawdzanie czy jest wpisana nazwa produktu if($.trim(value['hbprod_title'])!==""){ $("").html(value['hbprod_title']).appendTo(hotbasket_kaprow_desc); }else{ $("").html(shoper_product_name).appendTo(hotbasket_kaprow_desc); } $("").text(product_price).appendTo(hotbasket_kaprow_upper); if($.trim(value['hbprod_description'])!=""){ $("
").appendTo(hotbasket_kaprow); var hotbasket_kaprow_lower = hotbasket_kaprow.find(".kr_lower"); $("
").appendTo(hotbasket_kaprow_lower).text(value['hbprod_description']); } //dodanie elementu do html if(custom_container!=="" || custom_container!=false){ //jesli jest ustalony custom container hotbasket_element.appendTo(custom_container); }else{ hotbasket_element.insertAfter("table.productlist"); } } } // end if active product }); //sprawdzenie czy dodatek ma mieć obramowanie i inne cssy if(border==1){ $(".maxsote_hotbasket").css("border","1px solid "+border_color); if(border_thickness){ border_thickness = parseInt(border_thickness); $(".maxsote_hotbasket").css("border-width",border_thickness+"px"); } } $(".kap_icon").css({ "padding" : "10px 15px", "padding-right" : "0px", "display" : "inline-block", "float" : "left", "font-family": "fontAwesome", "font-size" : "25pt", "min-width" : "60px", "text-align" : "center", "vertical-align" : "middle" }); $(".kap_row").css({ "vertical-align":"middle", "padding": "10px 20px", "display": "inline-block", "vertical-align": "middle" }); $(".kap_icon i").css("font-style","normal").addClass("fa"); $(".kap_price").css({ "font-weight":"bold", "margin-left":"10px" }); $(".kap_description").css({ "margin": "10px 0px", "font-size": "10pt" }); $(".maxsote_hotbasket .desc").css({ "margin-left" : "5px" }); //obsluga zaznaczenia wybranej opcji i ukrycia w tabeli function check_hotbasket_products(){ //pobieram info o produktach w koszyku let basket_info = frontAPI.getBasketInfo({ lang: 'pl_PL', currency: 'PLN' }); let current_basket_prod_ids = []; let need_to_refresh = false; $.each(basket_info['products'],function(key, value) { console.log(value['product_id']); var product = frontAPI.getProduct({ id: value['product_id'] }); var stock_id = product.stockId; current_basket_prod_ids[value['product_id']] = stock_id; }); //sprawdzam wszystkie produkty hotbasket $(".k_additional_product").each(function(){ let additional_product_id = $(this).data('product_id'); var checked = $(this).is(":checked"); if(checked == true){ if (!(additional_product_id in current_basket_prod_ids)) { var product = frontAPI.getProduct({ id: additional_product_id }); var stock_id = product.stockId; var addInfo = frontAPI.addToBasket({ lang: 'pl_PL', // optional currency: 'PLN', // optional data: { stock_id: stock_id, quantity: 1 } }); if (typeof addInfo === 'undefined') { console.log("nieprawidlowy produkt hotbasket"); } need_to_refresh = true; } }else{ if (additional_product_id in current_basket_prod_ids) { var current_product_id = $(this).data("product_id"); //id produktu (dodatek) var basket = frontAPI.getBasketInfo({ }); var basket_products = basket['products']; var basket_product_id = null; $.each(basket_products,function(key, value) { product_id = value['product_id']; if(product_id == current_product_id){ //znalazlem ten produkt dodatkowy w koszyku basket_product_id = value['id']; } }); if(basket_product_id){ var removeInfo = frontAPI.removeFromBasket({ id: basket_product_id }); need_to_refresh= true; } } } }); if(need_to_refresh){ location.reload(); } } check_hotbasket_products(); //obsluga zmiany $(document).ready(function() { $(".k_additional_product").change(function() { check_hotbasket_products(); }); }); } //end if enabled } } APIloader(); });