6/9
${data.index + 1}/${data.total}
Description
You may also like
Recently viewed
from
'.replace(/\{\{\s*price\s*\}\}/, product_price_currency) : product_price_currency;
const variantShowLimit = 2;
const private_id = 'product-tmpl-' + Math.random().toFixed(6).slice(-6)
const product_variants = data.variants || [];
const product_id = data.id;
const images = data.images || [];
const image = data.image || {};
const imageWidth = image.width;
let imageHeight = image.height;
if (product_grid_image_size !== 'natural') {
imageHeight = (imageWidth * parseFloat(product_grid_image_size)) / 100;
}
const price = Number(data.price_min);
let compareAtPrice = Number(data.compare_at_price);
let offRatio = data.off_ratio;
const type = data.type;
const isMock = data.isMock;
let product_image_hover_on = false;
for (let i = 0; i < product_variants.length; i++) {
const item = product_variants[i];
const vcap = Number(item.compare_at_price);
if (item.price == price && vcap > compareAtPrice) {
compareAtPrice = vcap;
offRatio = item.off_ratio;
}
}
let second_image = null;
if (settings_product_image_hover_on) {
for (let i = 1; i < images.length; i++) {
const img = images[i];
if (img.src && img.src.indexOf('video=') === -1) {
second_image = img;
product_image_hover_on = true;
break;
}
}
}
let sold_label_on = false;
let sale_label_on = false;
if (settings_product_save_label == null) {
settings_product_save_label = true;
}
if (!data.available && product_sold_out_label) {
sold_label_on = true;
}
if (settings_product_save_label && compareAtPrice > price && data.available) {
sale_label_on = true;
}
const diffPrice = compareAtPrice - price;
const variantValues = [];
const showVariants = [];
if (data.need_variant_image && settings_collection_color_swatches && settings_product_swatches_name.length > 0) {
for (let i = 0; i < (data.options || []).length; i++) {
const option = data.originData.options[i];
const optionName = option.name && option.name.toLowerCase();
if (settings_product_swatches_name.includes(optionName)) {
for (let j = 0; j < product_variants.length; j++) {
const variant = product_variants[j];
const value = variant.options[i].value;
if (!variantValues.includes(value)) {
variantValues.push(value);
showVariants.push(variant);
}
}
break;
}
}
}
return `
{{ price }}
${from_on}
-
-
${data.available ?
`
` : ''}
${function(){
let thumbSwitchName = '';
return (data.product.options || []).map((option, index) => {
const optionName = option.name || '';
const optionId = option.id || '';
const position = `option${index + 1}`;
let isThumbImage = false;
const thumbStyle = "image";
const variantType = "button";
if (data.product.need_variant_image && thumbSwitchName === '') {
const variantNames = ["color","size"] || [];
for (let i = 0, len = variantNames.length; i < len; i++) {
const name = variantNames[i].toLowerCase();
if (name === optionName.toLowerCase()) {
isThumbImage = true;
thumbSwitchName = name;
}
}
}
return (variantType == 'dropdown' && !isThumbImage) ? `
` : `
`
}).join('')
}()}
${function(){
const { currentOptName, originData: { selectData, value } } = data;
const optionValue = selectData ? selectData[currentOptName].value[0] : value;
return `${optionValue}`
}()}
${optionName.toLowerCase()}
${function(){
let thumbSwitchName = '';
return (data.product.options || []).map((option, index) => {
const optionName = option.name || '';
const optionId = option.id || '';
const position = `option${index + 1}`;
let isThumbImage = false;
const thumbStyle = "image";
const variantType = "button";
if (data.product.need_variant_image && thumbSwitchName === '') {
const variantNames = ["color","size"] || [];
for (let i = 0, len = variantNames.length; i < len; i++) {
const name = variantNames[i].toLowerCase();
if (name === optionName.toLowerCase()) {
isThumbImage = true;
thumbSwitchName = name;
}
}
}
return (variantType == 'dropdown' && !isThumbImage) ? `
` : `
`
}).join('')
}()}
${function(){
const { currentOptName, originData: { selectData, value } } = data;
const optionValue = selectData ? selectData[currentOptName].value[0] : value;
return `${optionValue}`
}()}
${optionName.toLowerCase()}