Multifunctional Large-capacity four-in-one mobile phone expansion flash drive
₦59,000
₦158,000
SAVE 63%
${(function() {
var variantData = data.variant;
var productData = data.product;
var hasDiscount = false;
var discountPercentage = 0;
var currentPrice = 0;
var comparePrice = 0;
// 关键修复:更全面地检查所有可能的原价字段
if (variantData) {
currentPrice = variantData.price;
// 按优先级尝试获取原价
comparePrice = variantData.compare_at_price
|| variantData.compareAtPrice
|| (productData && productData.compare_at_price_max)
|| (productData && productData.compareAtPriceMax)
|| 0;
// 确保 comparePrice 是数字
comparePrice = Number(comparePrice) || 0;
currentPrice = Number(currentPrice) || 0;
if (comparePrice > currentPrice && currentPrice > 0) {
hasDiscount = true;
discountPercentage = Math.round(((comparePrice - currentPrice) / comparePrice) * 100);
}
} else if (productData) {
// 产品级别的价格
currentPrice = productData.price || productData.price_min || productData.priceMin || 0;
comparePrice = productData.compare_at_price_max
|| productData.compareAtPriceMax
|| productData.compare_at_price
|| productData.compareAtPrice
|| 0;
// 确保是数字
comparePrice = Number(comparePrice) || 0;
currentPrice = Number(currentPrice) || 0;
if (comparePrice > currentPrice && currentPrice > 0) {
hasDiscount = true;
discountPercentage = Math.round(((comparePrice - currentPrice) / comparePrice) * 100);
}
}
// 调试信息(生产环境可删除)
console.log('Price Debug:', {
variantData: variantData,
productData: productData,
currentPrice: currentPrice,
comparePrice: comparePrice,
hasDiscount: hasDiscount,
discountPercentage: discountPercentage
});
var priceHtml = '';
priceHtml += '
';
priceHtml += '
';
priceHtml += '
';
if (variantData || productData) {
priceHtml += '';
if (hasDiscount && comparePrice > 0) {
priceHtml += '';
}
}
priceHtml += '
';
if (hasDiscount && discountPercentage > 0) {
priceHtml += '
SAVE ' + discountPercentage + '%
';
}
priceHtml += '
';
return priceHtml;
})()}
${function(){
const tipText = "Please select a {{ name }}".replace(/\{\{\s+name\s+\}\}/g, data);
return `${tipText}
`
}()}
Product was out of stock.
Product is unavailable.
Notes
Due to manual measurements, please allow slight measurement deviations.
Due to the different display and lighting effects, the actual color of the item may be slightly different from the color displayed in the picture.