${function() {
const variantData = data.variant || {"id":"9a0f10a8-8fea-49ff-9772-4548341896f1","product_id":"06264470-990a-4f05-920b-78dc6f7e56fb","title":"\u7d05\u8272-L","weight_unit":"kg","inventory_quantity":0,"sku":"","barcode":"","position":1,"option1":"\u7d05\u8272","option2":"L","option3":"","note":"","image":{"src":"\/\/img.staticdj.com\/51ad21be50d4929a8391a547c5c55e01.webp","path":"51ad21be50d4929a8391a547c5c55e01.webp","width":800,"height":800,"alt":"","aspect_ratio":1},"wholesale_price":[{"price":1820,"min_quantity":1}],"weight":"0","compare_at_price":"3033","price":"1820","retail_price":"3033","available":true,"url":"\/products\/\u590f\u65b0\u6b3e\u65b0\u4e2d\u5f0f\u8759\u8760\u8896v\u9818\u76e4\u6263\u5b9a\u4f4d\u82b1\u771f\u7d72t\u6064\u5927\u78bc\u4e0a\u8863-zxm1990?variant=9a0f10a8-8fea-49ff-9772-4548341896f1","available_quantity":999999999,"options":[{"name":"\u984f\u8272","value":"\u7d05\u8272"},{"name":"\u5c3a\u5bf8","value":"L"}],"off_ratio":40,"flashsale_info":[],"sales":0};
const saveType = "percentage";
const saveText = "\u7bc0\u7701{{saved_amount}}";
const productLabelDiscountOn = true;
return `
-
${saveText.replace('\{\{saved_amount\}\}',
saveType == 'percentage'
? variantData.off_ratio + '%'
: ` `
)}
`;
}()}
顏色
: 紅色
${function(){
const optName = "顏色";
const optionValue = data.originData.selectData ? data.originData.selectData[optName].value : data.originData.value;
const optionValueText = optionValue ? (': ' + optionValue) : '';
return `
${optionValueText}
`
}()}
${function(){
const tipText = "\u8acb\u9078\u64c7\u4e00\u500b{{ name }}".replace(/\{\{\s+name\s+\}\}/g, data);
return `${tipText}
`
}()}
尺寸
: L
${function(){
const optName = "尺寸";
const optionValue = data.originData.selectData ? data.originData.selectData[optName].value : data.originData.value;
const optionValueText = optionValue ? (': ' + optionValue) : '';
return `
${optionValueText}
`
}()}
${function(){
const tipText = "\u8acb\u9078\u64c7\u4e00\u500b{{ name }}".replace(/\{\{\s+name\s+\}\}/g, data);
return `${tipText}
`
}()}
添加到購物車
NT$1,820.00
${function(){
const wholesale_enabled = false;
const qty = data.quantity || 1;
const currentSelectVariant = data.variant;
const defaultVariant = (data.product && data.product.variants && data.product.variants[0]);
const productVariant = {"id":"9a0f10a8-8fea-49ff-9772-4548341896f1","product_id":"06264470-990a-4f05-920b-78dc6f7e56fb","title":"\u7d05\u8272-L","weight_unit":"kg","inventory_quantity":0,"sku":"","barcode":"","position":1,"option1":"\u7d05\u8272","option2":"L","option3":"","note":"","image":{"src":"\/\/img.staticdj.com\/51ad21be50d4929a8391a547c5c55e01.webp","path":"51ad21be50d4929a8391a547c5c55e01.webp","width":800,"height":800,"alt":"","aspect_ratio":1},"wholesale_price":[{"price":1820,"min_quantity":1}],"weight":"0","compare_at_price":"3033","price":"1820","retail_price":"3033","available":true,"url":"\/products\/\u590f\u65b0\u6b3e\u65b0\u4e2d\u5f0f\u8759\u8760\u8896v\u9818\u76e4\u6263\u5b9a\u4f4d\u82b1\u771f\u7d72t\u6064\u5927\u78bc\u4e0a\u8863-zxm1990?variant=9a0f10a8-8fea-49ff-9772-4548341896f1","available_quantity":999999999,"options":[{"name":"\u984f\u8272","value":"\u7d05\u8272"},{"name":"\u5c3a\u5bf8","value":"L"}],"off_ratio":40,"flashsale_info":[],"sales":0};
const variantData = currentSelectVariant || defaultVariant || productVariant;
const wholesale_price = variantData.wholesale_price || [];
if(wholesale_enabled && wholesale_price.length > 0) {
let wholesaleIndex = wholesale_price.findIndex(item => {
return item.min_quantity > qty;
});
if(wholesaleIndex < 0){
wholesaleIndex = wholesale_price.length - 1;
}else if(wholesaleIndex > 0){
wholesaleIndex = wholesaleIndex - 1;
}
const wholesalePrice = wholesale_price[wholesaleIndex] || '';
return `
`
}else {
const price = variantData && variantData.price;
return price != undefined ? `
` : ' ';
}
}()}
立即購買
商品已售空。
商品不存在。
${function(){
const variantData = data.variant || {"id":"9a0f10a8-8fea-49ff-9772-4548341896f1","product_id":"06264470-990a-4f05-920b-78dc6f7e56fb","title":"\u7d05\u8272-L","weight_unit":"kg","inventory_quantity":0,"sku":"","barcode":"","position":1,"option1":"\u7d05\u8272","option2":"L","option3":"","note":"","image":{"src":"\/\/img.staticdj.com\/51ad21be50d4929a8391a547c5c55e01.webp","path":"51ad21be50d4929a8391a547c5c55e01.webp","width":800,"height":800,"alt":"","aspect_ratio":1},"wholesale_price":[{"price":1820,"min_quantity":1}],"weight":"0","compare_at_price":"3033","price":"1820","retail_price":"3033","available":true,"url":"\/products\/\u590f\u65b0\u6b3e\u65b0\u4e2d\u5f0f\u8759\u8760\u8896v\u9818\u76e4\u6263\u5b9a\u4f4d\u82b1\u771f\u7d72t\u6064\u5927\u78bc\u4e0a\u8863-zxm1990?variant=9a0f10a8-8fea-49ff-9772-4548341896f1","available_quantity":999999999,"options":[{"name":"\u984f\u8272","value":"\u7d05\u8272"},{"name":"\u5c3a\u5bf8","value":"L"}],"off_ratio":40,"flashsale_info":[],"sales":0};
return `
Sku : ${variantData && variantData.sku}
重量 : ${variantData && variantData.weight}${variantData && variantData.weight_unit}
條碼 : ${variantData && variantData.barcode}
`
}()}
×
${function(){
const limit = typeof data === 'number' ? data : 0;
return `
圖片/影片 (${limit || 0}/5 )
` }()}
${(function(){
const closeIcon =
'
';
if (item.type === 'image') {
return `
${closeIcon}
`
}
return `
${closeIcon}
`
})()}
匿名提交評論
class SpzCustomFileUpload extends SPZ.BaseElement {
constructor(element) {
super(element);
this.uploadCount_ = 0;
this.fileList_ = [];
}
buildCallback() {
this.action = SPZServices.actionServiceForDoc(this.element);
this.registerAction('upload', (data) => {
this.handleFileUpload_(data.event?.detail?.data || []);
});
this.registerAction('delete', (data) => {
this.handleFileDelete_(data?.args?.data);
});
this.registerAction('preview', (data) => {
this.handleFilePreview_(data?.args?.data);
});
this.registerAction('limit', (data) => {
this.handleFileLimit_();
});
this.registerAction('sizeLimit', (data) => {
this.handleFileSizeLimit_();
});
}
isLayoutSupported(layout) {
return layout == SPZCore.Layout.LOGIC;
}
setData_(count, file) {
this.uploadCount_ = count;
this.fileList_ = file;
}
handleFileUpload_(data) {
data.forEach(i => {
if(this.fileList_.some(j => j.url === i.url)) return;
this.fileList_.push(i);
})
this.uploadCount_++;
sessionStorage.setItem('fileList', JSON.stringify(this.fileList_));
this.triggerEvent_("handleFileUpload", { count: this.uploadCount_, files: this.fileList_});
if(this.fileList_.length >= 5){
document.querySelector('#review_upload').style.display = 'none';
}
if(this.fileList_.length > 0){
document.querySelector('.apps-reviews-write-anonymous-box').style.marginTop = '8px';
}
}
handleFileDelete_(index) {
this.fileList_.splice(index, 1);
this.uploadCount_--;
sessionStorage.setItem('fileList', JSON.stringify(this.fileList_));
this.triggerEvent_("handleFileDelete", { count: this.uploadCount_, files: this.fileList_});
document.querySelector('#review_upload').style.display = 'block';
if(this.fileList_?.length === 0){
document.querySelector('.apps-reviews-write-anonymous-box').style.marginTop = '132px';
}
}
handleFilePreview_(index) {
const finalPreviewData = this.fileList_[index];
const filePreviewModal = document.getElementById('filePreviewModal');
const fullScreenVideo = document.getElementById('fullScreenVideo');
const fullScreenImage = document.getElementById('fullScreenImage');
const previewModalClose = document.getElementById('previewModalClose');
const previewLoading = document.getElementById('previewLoading');
filePreviewModal.style.display = 'block';
previewLoading.style.display = 'flex';
if(finalPreviewData?.type === 'video'){
const media = this.mediaParse_(this.fileList_[index]?.url);
fullScreenVideo.addEventListener('canplaythrough', function() {
previewLoading.style.display = 'none';
});
fullScreenImage.src = '';
fullScreenImage.style.display = 'none';
fullScreenVideo.style.display = 'block';
fullScreenVideo.src = media.mp4 || '';
} else {
fullScreenImage.onload = function() {
previewLoading.style.display = 'none';
};
fullScreenVideo.src = '';
fullScreenVideo.style.display = 'none';
fullScreenImage.style.display = 'block';
fullScreenImage.src = finalPreviewData.url;
}
previewModalClose.addEventListener('click', function() {
filePreviewModal.style.display = 'none';
});
}
handleFileLimit_() {
alert(window.AppReviewsLocale.comment_file_limit || 'please do not upload files more than 5');
this.triggerEvent_("handleFileLimit");
}
handleFileSizeLimit_() {
alert(window.AppReviewsLocale.comment_file_size_limit || 'File size does not exceed 10M');
}
clear(){
this.fileList_ = [];
this.uploadCount_ = 0;
sessionStorage.setItem('fileList', JSON.stringify(this.fileList_));
this.triggerEvent_("handleClear", { count: this.uploadCount_, files: this.fileList_});
document.querySelector('#review_upload').style.display = 'block';
}
mediaParse_(url) {
var result = {};
try {
url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (str, key, value) {
try {
result[key] = decodeURIComponent(value);
} catch (e) {
result[key] = value;
}
});
result.preview_image = url.split('?')[0];
} catch (e) {};
return result;
}
triggerEvent_(name, data) {
const event = SPZUtils.Event.create(this.win, name, data);
this.action.trigger(this.element, name, event);
}
}
SPZ.defineElement('spz-custom-file-upload', SpzCustomFileUpload);
The review would not show in product details on storefront since it does not support to.