#Shop by Category
${(function() {
const productsInfo = data.products || data.product;
const product_display = originData?.product_display;
const show_atc = product_display ? !!product_display?.show_add_to_cart : true;
const show_discount_label = !!product_display?.show_discount_label;
const show_sales_progress = !!product_display?.sales_progress?.enabled;
const sales_progress_format = product_display?.sales_progress?.format || '';
const limit_purchase = originData.limit_purchase;
const productConfig = product_display ? JSON.parse(product_display?.config).color : '';
const sale_progress_bg = productConfig?.sale_bar_background_color || '#F2F2F2';
const sale_progress_bg_start = productConfig?.progress_sale_bar_background_color_start || '#FF9C57';
const sale_progress_bg_end = productConfig?.progress_sale_bar_background_color_end || '#FF4559';
const sale_count_text = productConfig?.sale_bar_atc_color || '#FC5161';
const discount_label_start = productConfig?.discount_sign_background_color_start || '#FF9C57';
const discount_label_end = productConfig?.discount_sign_background_color_end || '#FF4559';
const discount_label_text = productConfig?.discount_sign_color || '#FFFFFF';
//限时促销首页卡片尺寸
const discount_image_size = data.discount_image_size || '100%';
//点击加购按钮需要的参数
let discount_id = data.discount_id;
let apply_scenario = data.apply_scenario;
if(!productsInfo.length) return '';
return productsInfo.map(product => {
let price = product.price || 0;
let priceMin = product.price_min || 0;
let priceMax = product.price_max || 0;
let compareAtPriceMax = product.compare_at_price_max || 0;
let compareAtPrice = product.compare_at_price || 0;
let title = product.title || '';
let id = product.id || '';
let url = product.url || '';
let type = product.type || '';
let is_sold_out = false;
if (product.available == false && product.inventory_policy != 'continue') {
is_sold_out = true;
}
const soldOutLang1 = "Sold out";
const soldOutLang2 = "SOLD OUT";
const discountType = product.discount_type;
const noNeedBtn = discountType !== "DT_MIX_MATCH_BUNDLE" && discountType !== "DT_CLASSIC_BUNDLE";
const defaultVariantTitle = product.variants[0]?.title.replace('-', '/');
const flash_sale_info = product?.flash_sale_info;
const is_flashsale_sold_out = flash_sale_info?.discount_sales_rate == "100";
const show_product_sold_progress = flash_sale_info?.discount_sales_rate > 0;
const off_ratio = flash_sale_info?.off_ratio;
price = flash_sale_info?.discount_price || price;
discount_id = discount_id || product.discount_id;
apply_scenario = apply_scenario || product.apply_scenario;
let imageWidth;
if (product.image.width) {
imageWidth = product.image.width;
} else {
imageWidth = "300px";
}
let imageHeight;
if (product.image.height) {
imageHeight= product.image.height;
} else {
imageHeight = "300px";
}
if (discount_image_size !== 'natural') {
imageHeight = (imageWidth * parseFloat(discount_image_size)) / 100;
}
if (product.published) {
return `
`
} else {
return ``;
}
}).join('');
})()}
${function(){
let hour = data.d * 24 + data.h;
if(hour < 10){
hour = '0' + hour;
}
return `
-${off_ratio}%
${function(){
if (soldOutLang1){
return `
${soldOutLang1}
`
}else{
return `
${soldOutLang2}
`
}
}()}
${product.title}
Almost sold out
${flash_sale_info?.discount_sales}
${flash_sale_info?.discount_sales_rate}%
sold
${defaultVariantTitle}
End in
${data.dd}D
${data.hh}:
${hour}:
${data.mm}:
${data.ss}
.
${data.SSS}
Promo products limited to ${limit_user_product_discount} item per person
${function() {
const currentProduct = data.product;
return (currentProduct.options || []).map((option, index) => {
const optionName = option.name || '';
const optionId = option.id || '';
const position = `option${index + 1}`;
return `
${function() {
const value = (data.originData && data.originData.value) || data.value;
const isHasValue = value ? true : false;
return `
`;
}).join('')
}()}
${value}
`
}()}
The activity inventory has been sold out, flash sale discount will not be applied
FLASH SALE
View More