Pallets Plásticos

pallets plásticos peru
Loading…
Todas
Todas
Loading…
function getCategories(){ let $categories = jQuery(‘#categories’); $categories.find(‘option:gt(0)’).remove(); jQuery.ajax({ type: “GET”, beforeSend: function (xhr) { xhr.setRequestHeader(‘Authorization’, ‘Basic Y2tfZGRiZTEzYWQxZTQ3YjA3ZDdlZWZlZDIyMzM5ZTg1NmNhYzRiNmE5NTpjc19mYjc3NDM4NzZiZTQwMGE5ODViMGYwZTE5MjhlNzQxZGYzYzA3NmFk’); }, contentType: “application/json; charset=utf-8″, url: ‘/wp-json/wc/v3/products/categories?per_page=100&parent=0’, success: function (data) { jQuery.each(data,function(i, v){ if (v.name !== ‘Uncategorized’){ let $option = jQuery(”,{value:v.id, html:v.name}); $categories.append($option); }; }); let categoria = 21; if (categoria){ $categories.val(categoria); } jQuery(‘#spinnerDropdown’).hide(); jQuery(‘#formProducts’).show(); getSubCategories(); }, error: function () { alert(‘Debe cerrar sesión para acceder a esa página’)} }); } function getSubCategories(){ let $categories = jQuery(‘#categories’); let category = $categories.val(); let $subcategories = jQuery(‘#subcategories’); $subcategories.find(‘option:gt(0)’).remove(); jQuery(‘#spinnerProducts’).show(); jQuery(‘#products’).hide(); if (category !== ‘0’){ jQuery.ajax({ type: “GET”, beforeSend: function (xhr) { xhr.setRequestHeader(‘Authorization’, ‘Basic Y2tfZGRiZTEzYWQxZTQ3YjA3ZDdlZWZlZDIyMzM5ZTg1NmNhYzRiNmE5NTpjc19mYjc3NDM4NzZiZTQwMGE5ODViMGYwZTE5MjhlNzQxZGYzYzA3NmFk’); }, contentType: “application/json; charset=utf-8″, url: ‘/wp-json/wc/v3/products/categories?per_page=100&parent=’+category, success: function (data) { jQuery.each(data,function(i, v){ let $option = jQuery(”,{value:v.id, html:v.name}); $subcategories.append($option); }); getProducts(); }, error: function () { alert(‘Debe cerrar sesión para acceder a esa página’)} }); } else { getProducts(); } } function getProducts(){ let $categories = jQuery(‘#categories’); let category = $categories.val(); let $subcategories = jQuery(‘#subcategories’); let subcategory = $subcategories.val(); let $products = jQuery(‘#products’); $products.empty(); let search = jQuery(‘#search’).val(); let url = ‘/wp-json/wc/v3/products?per_page=100&orderby=title&order=asc&search=’+search; if (category !== ‘0’){ if (subcategory === ‘0’){ url += ‘&category=’ + category; } else { url += ‘&category=’ + subcategory; } } jQuery(‘#spinnerProducts’).show(); jQuery(‘#products’).hide(); jQuery.ajax({ type: “GET”, beforeSend: function (xhr) { xhr.setRequestHeader(‘Authorization’, ‘Basic Y2tfZGRiZTEzYWQxZTQ3YjA3ZDdlZWZlZDIyMzM5ZTg1NmNhYzRiNmE5NTpjc19mYjc3NDM4NzZiZTQwMGE5ODViMGYwZTE5MjhlNzQxZGYzYzA3NmFk’); }, contentType: “application/json; charset=utf-8”, url: url, success: function (data) { jQuery.each(data,function(i, v){ let $div = jQuery(‘
‘, {class:’col-md-4 mb-4’}); let $a = jQuery(‘‘,{href:v.permalink, class:’card shadow d-block text-center’}); let cssImage = {‘height’:150}; if (v.images.length>0){ cssImage.background = ‘url(‘+v.images[0].src+’) center no-repeat’; cssImage[‘background-size’] = ‘contain’; } else{ cssImage.background = “url(‘/wp-content/uploads/woocommerce-placeholder.png’) center no-repeat”; cssImage[‘background-size’] = ‘contain’; } $a.append(jQuery(‘
‘, {css:cssImage})); $a.append(jQuery(‘
‘, {html:v.name, class:’p-2’ })); $div.append($a); $products.append($div); }); jQuery(‘#spinnerProducts’).hide(); jQuery(‘#products’).show(); }, error: function () { alert(‘Debe cerrar sesión para acceder a esa página’)} }); } jQuery(‘#categories’).on(‘change’, function(){ getSubCategories(); }); jQuery(‘#subcategories’).on(‘change’, function(){ getProducts(); }); jQuery(‘#formProducts’).on(‘submit’, function(){ getProducts(); return false; }); function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf(‘?’) + 1).split(‘&’); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } getCategories();