/**
* Libs
*/
/**
* Utils
*/
function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this, args = arguments;
var later = function () {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
toastr.options.showEasing = 'swing';
toastr.options.showMethod = 'slideDown';
toastr.options.hideMethod = 'slideUp';
/**
* Draw Product Item In search
*/
function drawItemSearch({ product }) {
var price = null;
if (product.has_sale_price) {
price = `
${product.formatted_sale_price}
${product.formatted_price}
`
} else {
price = `
${product.formatted_sale_price}
`
}
return `
${drawOptions(product)}
${drawFilds(product)}`;
$("#productDitalModalFormConent").html(html)
}
// Draw Rating
function drawRating(product) {
var ratingHtml= '';
if (product.rating) {
ratingHtml = `
${product.rating.total_count || '0'}
${window.translate.product_reviews_x_count}
`;
}
return ratingHtml;
}
// Draw Options
function drawOptions(product) {
var optionsHtml = '';
const items = [];
if (product?.options?.length > 0) {
for (var i = 0; i < product.options.length; i++) {
const option = product.options[i];
const choices = [];
for (var j = 0; j < option.choices.length; j++) {
choices.push(`