<script>var totalAmount=0;var allItemsForCheckout=[{"appkey":"dd18169416dd48ca873b282c239ba120","id":"4a02b2dfb1484121a005ccbaa0123358","ident":"00001","name":"Artikel 1","price":"100.00","taxrate":null,"unit":"m","idcategory":"0a05ecb07ede4414a93eed08e38fd2bf","description":"Tukaj bom vpisal dalj\u0161i opis, kjer lahko opi\u0161e\u0161 posebnosti, lastnosti, ...","categoryname":"Kategorija I"},{"appkey":"dd18169416dd48ca873b282c239ba120","id":"7a2f915b73c343eba781050433bf35f9","ident":"00003","name":"Artikel 3","price":"1100.00","taxrate":null,"unit":"kos","idcategory":"0a05ecb07ede4414a93eed08e38fd2bf","description":"Pri enem artiklu sem nala\u0161\u010d pustil brez opisa, da se vidi, kako izgleda ...","categoryname":"Kategorija I"},{"appkey":"dd18169416dd48ca873b282c239ba120","id":"3667890948b84b49a38873c2626b9215","ident":"00002","name":"Artikel 2","price":"48.00","taxrate":null,"unit":"m2","idcategory":"14e673195da54f8c9d3d68f68d2867a0","description":null,"categoryname":"Kategorija II"}];</script><script>function apiCall(url, payload, callBack)
					{
						var http = new XMLHttpRequest();
						http.open("POST", url);
						http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
						http.send(JSON.stringify(payload));
						http.onload = function() {
							if (window[callBack])
								window[callBack](JSON.parse(http.responseText));
						}
					};function countItems(){
			var cart = localStorage.getItem('cart');
			if (!cart)
				cart = '';
			var itemCount = cart.split('#').length-1;
			document.getElementById('cartItems').value = itemCount;
		};function addToCart(id){
			var cart = localStorage.getItem('cart');
			if (!cart)
				cart = '';
			if (cart.indexOf(id)<0)
			{
				cart = cart + '#' + id;
				document.getElementById(id).style.display='none';
				alert('Izdelek je dodan v košarico!');
			}
			else
			{
				alert('Izdelek je že v košarici!');
			}
			localStorage.setItem('cart', cart);
			countItems();
		};function handleCategoryPick(currentValue){
			var cart = localStorage.getItem('cart');
			if (!cart)
				cart = '';
			if (!currentValue)
				var currentValue = 'all';
			var searchText = document.getElementById('product-search').value;
			var allItems = document.getElementsByClassName('rpobtsp-web-product');
			for (var i=0;i<allItems.length;i++)
			{
				if (currentValue==='all')
				{
					allItems[i].style.display=null;
				}
				else
				{
					if (allItems[i].classList.contains('cat_' + currentValue))
						allItems[i].style.display=null;
					else
						allItems[i].style.display='none';
				}
				if (cart.indexOf(allItems[i].id)>-1)
				{
					allItems[i].style.display='none';
				}
				if (searchText && !allItems[i].style.display)
				{
					for (var j=0;j<allItemsForCheckout.length;j++)
					{
						if (allItemsForCheckout[j].id==allItems[i].id)
						{
							var doHide = true;
							if (allItemsForCheckout[j].name && allItemsForCheckout[j].name.indexOf(searchText)>-1)
								doHide = false;
							if (allItemsForCheckout[j].description && allItemsForCheckout[j].description.indexOf(searchText)>-1)
								doHide = false;
							if (doHide)
								allItems[i].style.display='none';
						}
					}

				}
			}
		};function removeItem(id){
			var cart = localStorage.getItem('cart');
			if (!cart)
				cart = '';
			cart = cart.replace('#'+id,'');
			localStorage.setItem('cart', cart);
			handleCheckOut();
		}function setQuantity(id, value){
			for (var i=0;i<allItemsForCheckout.length;i++)
			{
				if (allItemsForCheckout[i].id==id)
				{
					allItemsForCheckout[i].quantity = Number(value);
				}
			}
			handleCheckOut();
		}function htmlForProduct(id){
			var html = '';
			html += '<div class=\'rpobtsp-web-cart-item\'>';
			html += '<div class=\'gg-remove\' onclick=\'removeItem("' + id + '")\'></div>';
			for (var i=0;i<allItemsForCheckout.length;i++)
			{
				if (allItemsForCheckout[i].id==id)
				{
					if (!allItemsForCheckout[i].quantity)
						allItemsForCheckout[i].quantity = 1;
					html += '<div class=\'rpobtsp-web-cart-item-title\'>';
					html += allItemsForCheckout[i].name;
					html += '</div>';
					html += '<div class=\'rpobtsp-web-cart-item-price\'>';
					html += allItemsForCheckout[i].price + '€ / ' + allItemsForCheckout[i].unit;
					html += '</div>';
					html += '<input onchange=\'setQuantity("' + id + '", this.value)\' class=\'rpobtsp-web-cart-item-quantity\' type=\'number\' value=\'' + allItemsForCheckout[i].quantity + '\' />';
					html += '<div class=\'rpobtsp-web-cart-item-total\'>';
					html += Number(Number(allItemsForCheckout[i].price)*Number(allItemsForCheckout[i].quantity)).toFixed(2);
					totalAmount = totalAmount + Number(allItemsForCheckout[i].price)*Number(allItemsForCheckout[i].quantity);
					html += '</div>';
				}
			}
			html += '</div>';
			return html;
		}function handleCheckOut(){
			var cart = localStorage.getItem('cart');
			if (!cart)
				cart = '';
			totalAmount = 0;
			var cartItems = cart.split('#');
			if (cartItems.length<2)
			{
				document.getElementById('rpobtsp-web-checkout-items').innerHTML = '<h4>Trenutno ni izdelkov v košarici!</h4>';
				return;
			}
			var html = '';
			for (var i=0;i<cartItems.length;i++)
			{
				if (cartItems[i])
					html += htmlForProduct(cartItems[i]);
			}
			html += '<div class=\'rpobtsp-web-cart-item-total-total\'>Skupna vrednost naročila: ';
			html += Number(totalAmount).toFixed(2);
			html += '</div>';
			document.getElementById('rpobtsp-web-checkout-items').innerHTML = html;
		}function orderCreated(){
			localStorage.removeItem('cart');
			window.location.replace('https://wp.tergusek.eu/index.php/hvala-za-oddano-narocilo/');
		}function finishOrder(){
			var cart = localStorage.getItem('cart');
			if (!cart)
				cart = '';
			var cartItems = cart.split('#');
			if (cartItems.length<2)
			{
				alert('V košarici nimate izbranih artiklov!');
				return;
			}
			var itemsForOrder = [];
			for (var i=0;i<cartItems.length;i++)
			{
				if (cartItems[i])
				{
					for (var j=0;j<allItemsForCheckout.length;j++)
					{
						if (allItemsForCheckout[j].id==cartItems[i])
						{
							itemsForOrder.push(allItemsForCheckout[j]);
						}
					}
				}
			}
			var customer_data = {};
			var customerInputs = document.getElementsByClassName('rpobtsp-web-customer-input');
			for (var i=0;i<customerInputs.length;i++)
			{
				customer_data[customerInputs[i].id] = customerInputs[i].value;
				if (!customerInputs[i].value)
				{
					alert('Prosimo, da izpolnite podatke o naročniku!');
					return;
				}
			}
			customer_data['customer_notes'] = document.getElementById('customer-notes').value;
			customer_data['isDelivery'] = document.getElementById('isDelivery').checked;
			customer_data['isAssembly'] = document.getElementById('isAssembly').checked;
			apiCall('https://wp.tergusek.eu/racuni/api.php',{'appId':'dd18169416dd48ca873b282c239ba120','action':'createOrderFromWeb','customer_data':customer_data,'itemsForOrder':itemsForOrder,'numLen':5},'orderCreated');
		}</script>{"id":183,"date":"2024-04-17T10:38:11","date_gmt":"2024-04-17T10:38:11","guid":{"rendered":"https:\/\/wp.tergusek.eu\/?page_id=183"},"modified":"2024-04-19T12:02:42","modified_gmt":"2024-04-19T12:02:42","slug":"zakljucek-nakupa","status":"publish","type":"page","link":"https:\/\/wp.tergusek.eu\/index.php\/zakljucek-nakupa\/","title":{"rendered":"Zaklju\u010dek nakupa"},"content":{"rendered":"<p>Cene so informativne in veljajo za osebni prevzem na sede\u017eu podjetja.<br \/>\nPo oddaji va\u0161ega naro\u010dila boste v najkraj\u0161em mo\u017enem \u010dasu prejeli nezavezujo\u010do ponudbo za nakup \u017eelenih izdelkov.<br \/>\nV kolikor \u017eelite dostavo in\/ali monta\u017eo naro\u010denih izdelkov, prosimo, da to ozna\u010dite pri oddaji naro\u010dila.<br \/>\n<link href=\"https:\/\/wp.tergusek.eu\/wp-content\/plugins\/rpobtsp-webshop-wp-plugin\/base.css?v=0.4.1\" rel=\"stylesheet\"><div class\"rpobtsp-web-checkout\"><div id=\"rpobtsp-web-checkout-items\" class=\"rpobtsp-web-checkout-items\"><\/div><div class=\"rpobtsp-web-checkout-items\"><input class=\"rpobtsp-web-checkbox\" id=\"isDelivery\" type=\"checkbox\" \/>&nbsp;<label for=\"isDelivery\">\u017delim ponudbo za dostavo izdelkov na vpisan naslov<\/label><\/div><div class=\"rpobtsp-web-checkout-items\"><input class=\"rpobtsp-web-checkbox\" id=\"isAssembly\" type=\"checkbox\" \/>&nbsp;<label for=\"isAssembly\">\u017delim ponudbo za monta\u017eo izdelkov<\/label><\/div><div class=\"rpobtsp-web-checkout-customer-data\"><div class=\"rpobtsp-web-customer-label\">Ime in priimek ali naziv:<\/div><input required class=\"rpobtsp-web-customer-input\" id=\"customer-name\" type=\"text\"\/><\/div><div class=\"rpobtsp-web-checkout-customer-data\"><div class=\"rpobtsp-web-customer-label\">Ulica in hi\u0161na \u0161tevilka:<\/div><input required class=\"rpobtsp-web-customer-input\" id=\"customer-address\" type=\"text\"\/><\/div><div class=\"rpobtsp-web-checkout-customer-data\"><div class=\"rpobtsp-web-customer-label\">Po\u0161tna \u0161tevilka in kraj:<\/div><input required class=\"rpobtsp-web-customer-input\" id=\"customer-post\" type=\"text\"\/><\/div><div class=\"rpobtsp-web-checkout-customer-data\"><div class=\"rpobtsp-web-customer-label\">Email naslov:<\/div><input required class=\"rpobtsp-web-customer-input\" id=\"customer-email\" type=\"text\"\/><\/div><div class=\"rpobtsp-web-checkout-customer-data\"><div class=\"rpobtsp-web-customer-label\">Opombe:<\/div><textarea class=\"rpobtsp-web-customer-input-notes\" id=\"customer-notes\" rows=\"5\"><\/textarea><\/div><div class=\"rpobtsp-web-finish\"><input type=\"button\" class=\"rpobtsp-web-button\" onclick=\"finishOrder();\" value=\"Oddaj naro\u010dilo\"\/><\/div><script>jQuery(function($) {$(document).ready( function () {handleCheckOut();})});<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cene so informativne in veljajo za osebni prevzem na sede\u017eu podjetja. Po oddaji va\u0161ega naro\u010dila boste v najkraj\u0161em mo\u017enem \u010dasu prejeli nezavezujo\u010do ponudbo za nakup \u017eelenih izdelkov. V kolikor \u017eelite dostavo in\/ali monta\u017eo naro\u010denih izdelkov, prosimo, da to ozna\u010dite pri oddaji naro\u010dila.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/pages\/183"}],"collection":[{"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":3,"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/pages\/183\/revisions"}],"predecessor-version":[{"id":190,"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/pages\/183\/revisions\/190"}],"wp:attachment":[{"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/media?parent=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}