<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><script>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>{"id":170,"date":"2024-04-17T09:38:24","date_gmt":"2024-04-17T09:38:24","guid":{"rendered":"https:\/\/wp.tergusek.eu\/?page_id=170"},"modified":"2024-04-24T13:33:46","modified_gmt":"2024-04-24T13:33:46","slug":"trgovina","status":"publish","type":"page","link":"https:\/\/wp.tergusek.eu\/","title":{"rendered":"Trgovina"},"content":{"rendered":"<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-products\"><div class=\"rpobtsp-web-category-picker\"><div onclick=\"handleCategoryPick('all')\" class=\"rpobtsp-web-category-button rpobtsp-web-pointer rpobtsp-web-animation3\">Prikaz vseh izdelkov<div class=\"rpobtsp-web-image rpobtsp-web-animation3\"><img decoding=\"async\" width=\"50%\" src=\"https:\/\/wp.tergusek.eu\/racuni\/img\/all\"><\/div><\/div><div onclick=\"handleCategoryPick('0a05ecb07ede4414a93eed08e38fd2bf')\" class=\"rpobtsp-web-category-button rpobtsp-web-pointer rpobtsp-web-animation3\">Kategorija I<div class=\"rpobtsp-web-image rpobtsp-web-animation3\"><img decoding=\"async\" width=\"50%\" src=\"https:\/\/wp.tergusek.eu\/racuni\/img\/0a05ecb07ede4414a93eed08e38fd2bf\"><\/div><\/div><div onclick=\"handleCategoryPick('14e673195da54f8c9d3d68f68d2867a0')\" class=\"rpobtsp-web-category-button rpobtsp-web-pointer rpobtsp-web-animation3\">Kategorija II<div class=\"rpobtsp-web-image rpobtsp-web-animation3\"><img decoding=\"async\" width=\"50%\" src=\"https:\/\/wp.tergusek.eu\/racuni\/img\/14e673195da54f8c9d3d68f68d2867a0\"><\/div><\/div><\/div><p><\/p><div class=\"rpobtsp-web-category-element\"><label class=\"rpobtsp-web-cart-label\">Izdelki v ko\u0161arici:<\/label><input onclick=\"window.location.replace('https:\/\/wp.tergusek.eu\/index.php\/zakljucek-nakupa\/')\" readonly class=\"rpobtsp-web-cart-items\" id=\"cartItems\" \/><\/div><div class=\"rpobtsp-web-category-element\"><svg onclick=\"handleCategoryPick()\" class=\"rpobtsp-web-cart-items\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"16.197\" height=\"16.546\" viewBox=\"0 0 16.197 16.546\" aria-label=\"Search Icon\">\r\n                <path id=\"icons8-search\" d=\"M9.939,3a5.939,5.939,0,1,0,3.472,10.754l4.6,4.585.983-.983L14.448,12.8A5.939,5.939,0,0,0,9.939,3Zm0,.7A5.24,5.24,0,1,1,4.7,8.939,5.235,5.235,0,0,1,9.939,3.7Z\" transform=\"translate(-3.5 -2.5) \" stroke-width=\"2\"><\/path>\r\n            <\/svg><input class=\"rpobtsp-web-category\" id=\"product-search\" type=\"text\"\/><\/div><\/div><div class=\"rpobtsp-web-product cat_0a05ecb07ede4414a93eed08e38fd2bf rpobtsp-web-animation2\" id=\"4a02b2dfb1484121a005ccbaa0123358\"><div class=\"rpobtsp-web-category\">Kategorija I<\/div><h3 class=\"rpobtsp-web-title\">Artikel 1<\/h3><p class=\"rpobtsp-web-description\">Tukaj bom vpisal dalj\u0161i opis, kjer lahko opi\u0161e\u0161 posebnosti, lastnosti, ...<\/p><h4 class=\"rpobtsp-web-price\">100.00\u20ac \/ m<\/h4><div class=\"rpobtsp-web-image rpobtsp-web-animation3\"><img decoding=\"async\" width=\"100%\" src=\"https:\/\/wp.tergusek.eu\/racuni\/img\/4a02b2dfb1484121a005ccbaa0123358\"><\/div><div class=\"rpobtsp-web-cart\"><input type=\"button\" class=\"rpobtsp-web-button\" onclick=\"addToCart('4a02b2dfb1484121a005ccbaa0123358');\" value=\"Dodaj izdelek v ko\u0161arico\"\/><\/div><div class=\"rpobtsp-web-finish\"><input type=\"button\" class=\"rpobtsp-web-button\" onclick=\"window.location.replace('https:\/\/wp.tergusek.eu\/index.php\/zakljucek-nakupa\/');\" value=\"Zaklju\u010di nakup\"\/><\/div><\/div><div class=\"rpobtsp-web-product cat_0a05ecb07ede4414a93eed08e38fd2bf rpobtsp-web-animation2\" id=\"7a2f915b73c343eba781050433bf35f9\"><div class=\"rpobtsp-web-category\">Kategorija I<\/div><h3 class=\"rpobtsp-web-title\">Artikel 3<\/h3><p class=\"rpobtsp-web-description\">Pri enem artiklu sem nala\u0161\u010d pustil brez opisa, da se vidi, kako izgleda ...<\/p><h4 class=\"rpobtsp-web-price\">1100.00\u20ac \/ kos<\/h4><div class=\"rpobtsp-web-image rpobtsp-web-animation3\"><img decoding=\"async\" width=\"100%\" src=\"https:\/\/wp.tergusek.eu\/racuni\/img\/7a2f915b73c343eba781050433bf35f9\"><\/div><div class=\"rpobtsp-web-cart\"><input type=\"button\" class=\"rpobtsp-web-button\" onclick=\"addToCart('7a2f915b73c343eba781050433bf35f9');\" value=\"Dodaj izdelek v ko\u0161arico\"\/><\/div><div class=\"rpobtsp-web-finish\"><input type=\"button\" class=\"rpobtsp-web-button\" onclick=\"window.location.replace('https:\/\/wp.tergusek.eu\/index.php\/zakljucek-nakupa\/');\" value=\"Zaklju\u010di nakup\"\/><\/div><\/div><div class=\"rpobtsp-web-product cat_14e673195da54f8c9d3d68f68d2867a0 rpobtsp-web-animation2\" id=\"3667890948b84b49a38873c2626b9215\"><div class=\"rpobtsp-web-category\">Kategorija II<\/div><h3 class=\"rpobtsp-web-title\">Artikel 2<\/h3><p class=\"rpobtsp-web-description\"><\/p><h4 class=\"rpobtsp-web-price\">48.00\u20ac \/ m2<\/h4><div class=\"rpobtsp-web-image rpobtsp-web-animation3\"><img decoding=\"async\" width=\"100%\" src=\"https:\/\/wp.tergusek.eu\/racuni\/img\/3667890948b84b49a38873c2626b9215\"><\/div><div class=\"rpobtsp-web-cart\"><input type=\"button\" class=\"rpobtsp-web-button\" onclick=\"addToCart('3667890948b84b49a38873c2626b9215');\" value=\"Dodaj izdelek v ko\u0161arico\"\/><\/div><div class=\"rpobtsp-web-finish\"><input type=\"button\" class=\"rpobtsp-web-button\" onclick=\"window.location.replace('https:\/\/wp.tergusek.eu\/index.php\/zakljucek-nakupa\/');\" value=\"Zaklju\u010di nakup\"\/><\/div><\/div><\/div><script>jQuery(function($) {$(document).ready( function () {handleCategoryPick();countItems();})});<\/script>\n","protected":false},"excerpt":{"rendered":"","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\/170"}],"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=170"}],"version-history":[{"count":6,"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/pages\/170\/revisions"}],"predecessor-version":[{"id":187,"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/pages\/170\/revisions\/187"}],"wp:attachment":[{"href":"https:\/\/wp.tergusek.eu\/index.php\/wp-json\/wp\/v2\/media?parent=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}