${function() {
const minInventory = parseInt('10');
const maxInventory = parseInt('50');
const randomInventory = Math.round(Math.random() * (maxInventory - minInventory)) + minInventory;
const customText = "Only {stock} item(s) left in stock!".replace(/\{stock\}/g, '' + randomInventory + ' ');
const barWidth = (randomInventory / maxInventory) * 100 + '%';
return `
`;
}()}
people are viewing this right now
Buy now
${function() {
let { prices } = data.data
const total_price = (prices && prices.total_price) || 0;
const subtotal_price = (prices && prices.subtotal_price) || 0;
return `
`
}()}
Product was out of stock.
${function(){
const variantData = data.variant || {"id":"3903d608-151a-4d0b-92c9-1ed2dca7f2dc","product_id":"6f0d0e16-69ce-4f35-a101-7f93d052623a","title":"Misses-2","weight_unit":"kg","inventory_quantity":1000,"sku":"S10719-1","barcode":"","position":1,"option1":"Misses","option2":"2","option3":"","note":"","image":{"src":"\/\/img.staticdj.com\/170b738b07fe5560af4254cef1352f50.jpeg","path":"170b738b07fe5560af4254cef1352f50.jpeg","width":620,"height":820,"alt":"","aspect_ratio":0.7560975609756098},"wholesale_price":[{"price":39.9,"min_quantity":1}],"weight":"0","compare_at_price":"149","price":"39.9","retail_price":"149","available":true,"url":"\/products\/ph-belted-wide-leg-pants-2?variant=3903d608-151a-4d0b-92c9-1ed2dca7f2dc","available_quantity":999999999,"options":[{"name":"Size Type","value":"Misses"},{"name":"Size","value":"2"}],"off_ratio":73,"flashsale_info":[],"sales":0};
return `
Sku : ${variantData && variantData.sku}
Weight : ${variantData && variantData.weight}${variantData && variantData.weight_unit}
Barcode : ${variantData && variantData.barcode}
`
}()}
${function() {
const postageFreeAmount = 499;
const custom_text = "Buy {amount} more to enjoy FREE Shipping";
const totalPrice = +data.total_price;
const diffPrice = postageFreeAmount - totalPrice;
const percentDiff = (diffPrice > 0 ? (totalPrice / postageFreeAmount * 100) : 100) + '%';
let tipText = "Your order is free delivery";
if (diffPrice > 0) {
tipText = custom_text.replace('{amount}', `
`);
}
return `
`;
}()}
${function() {
const minDays = parseInt('3');
const maxDays = parseInt('7');
const customText = "Estimated Delivery\uff1a{min_date} - {max_date}";
const minDate = new Date(Date.now() + (minDays * 86400000));
const maxDate = new Date(Date.now() + (maxDays * 86400000));
const formatDate = (minDate.getFullYear() == maxDate.getFullYear() && minDate.getFullYear() == new Date().getFullYear())
? new Intl.DateTimeFormat('en', { month: 'short', day: '2-digit' })
: new Intl.DateTimeFormat('en', { month: 'short', day: '2-digit', year: 'numeric' });
const tipText = customText.replace(/\{min_date\}/g, '' + formatDate.format(minDate) + ' ')
.replace(/\{max_date\}/g, '' + formatDate.format(maxDate) + ' ');
return `
`;
}()}