$product = {"id":7951313862755,"title":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly","handle":"iphone-12-pro-mod-nx-tan04","description":null,"published_at":"2026-01-13T10:11:17+08:00","created_at":"2026-01-12T17:16:10+08:00","vendor":"RHINOSHIELD Taiwan B2B","type":"","tags":["10%","20%","30%","40%","50%","brand-Apple","designer","designer-tanakashen","device-iPhone 12 Pro","merge","reseller-tanakashen"],"price":90000,"price_min":90000,"price_max":90000,"available":true,"price_varies":false,"compare_at_price":null,"compare_at_price_min":0,"compare_at_price_max":0,"compare_at_price_varies":false,"variants":[{"id":43946341269603,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"NPB01185C1-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094068297827,"product_id":7951313862755,"position":3,"created_at":"2026-01-12T17:16:15+08:00","updated_at":"2026-01-12T17:16:17+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/111eb7892a04f4eee63ce0fb8108a193c14487bb.webp?v=1768209377","variant_ids":[43946341269603]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - Lavender","public_title":"Lavender","options":["Lavender"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB01185C1-TAN04","featured_media":{"alt":null,"id":26650724106339,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/111eb7892a04f4eee63ce0fb8108a193c14487bb.webp?v=1768209377"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43946345365603,"title":"Graphite","option1":"Graphite","option2":null,"option3":null,"sku":"NPB0118569-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094069444707,"product_id":7951313862755,"position":8,"created_at":"2026-01-12T17:16:20+08:00","updated_at":"2026-01-12T17:16:22+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/ca56bb667d0c5ad9c8bc3cf922e99317f6a9e675.webp?v=1768209382","variant_ids":[43946345365603]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - Graphite","public_title":"Graphite","options":["Graphite"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB0118569-TAN04","featured_media":{"alt":null,"id":26650725253219,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/ca56bb667d0c5ad9c8bc3cf922e99317f6a9e675.webp?v=1768209382"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43946345431139,"title":"Navy Blue","option1":"Navy Blue","option2":null,"option3":null,"sku":"NPB01185J5-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094069837923,"product_id":7951313862755,"position":10,"created_at":"2026-01-12T17:16:21+08:00","updated_at":"2026-01-12T17:16:23+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cf50b7d3cc932348176e3294ada760853cae7638.webp?v=1768209383","variant_ids":[43946345431139]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - Navy Blue","public_title":"Navy Blue","options":["Navy Blue"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB01185J5-TAN04","featured_media":{"alt":null,"id":26650725646435,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cf50b7d3cc932348176e3294ada760853cae7638.webp?v=1768209383"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43946345496675,"title":"White","option1":"White","option2":null,"option3":null,"sku":"NPB0118504-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094068920419,"product_id":7951313862755,"position":6,"created_at":"2026-01-12T17:16:17+08:00","updated_at":"2026-01-12T17:16:19+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5d851a0b607e705bd009c38b392ae3e37c57075c.webp?v=1768209379","variant_ids":[43946345496675]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - White","public_title":"White","options":["White"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB0118504-TAN04","featured_media":{"alt":null,"id":26650724728931,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5d851a0b607e705bd009c38b392ae3e37c57075c.webp?v=1768209379"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43946345594979,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"NPB0118524-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094068559971,"product_id":7951313862755,"position":4,"created_at":"2026-01-12T17:16:16+08:00","updated_at":"2026-01-12T17:16:18+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/10e196945cefda28023b1454b688753ff9fb1ae9.webp?v=1768209378","variant_ids":[43946345594979]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - Black","public_title":"Black","options":["Black"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB0118524-TAN04","featured_media":{"alt":null,"id":26650724401251,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/10e196945cefda28023b1454b688753ff9fb1ae9.webp?v=1768209378"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}],"images":["\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f79975e9fca02ae66bf53af215457231d98bd276.webp?v=1768209377","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/c0cb13e9e2919b480735dd9c80619908b4045fca.webp?v=1768209377","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/111eb7892a04f4eee63ce0fb8108a193c14487bb.webp?v=1768209377","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/10e196945cefda28023b1454b688753ff9fb1ae9.webp?v=1768209378","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/577e88f3ed8217b4dea28048517158964d302da4.webp?v=1768209378","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5d851a0b607e705bd009c38b392ae3e37c57075c.webp?v=1768209379","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa55ae2772e9811b916ab01bf6bd69e08fb896c9.webp?v=1768209382","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/ca56bb667d0c5ad9c8bc3cf922e99317f6a9e675.webp?v=1768209382","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/599854ec1a1bc1360824c0b0c81f5ed5b8b85a3e.webp?v=1768209383","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cf50b7d3cc932348176e3294ada760853cae7638.webp?v=1768209383","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/db9475b452608a607e567e310a0e08d76947f173.webp?v=1768209383"],"featured_image":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f79975e9fca02ae66bf53af215457231d98bd276.webp?v=1768209377","options":["color"],"media":[{"alt":null,"id":26650723811427,"position":1,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f79975e9fca02ae66bf53af215457231d98bd276.webp?v=1768209377"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f79975e9fca02ae66bf53af215457231d98bd276.webp?v=1768209377","width":2000},{"alt":null,"id":26650723975267,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/c0cb13e9e2919b480735dd9c80619908b4045fca.webp?v=1768209377"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/c0cb13e9e2919b480735dd9c80619908b4045fca.webp?v=1768209377","width":2000},{"alt":null,"id":26650724106339,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/111eb7892a04f4eee63ce0fb8108a193c14487bb.webp?v=1768209377"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/111eb7892a04f4eee63ce0fb8108a193c14487bb.webp?v=1768209377","width":2000},{"alt":null,"id":26650724401251,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/10e196945cefda28023b1454b688753ff9fb1ae9.webp?v=1768209378"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/10e196945cefda28023b1454b688753ff9fb1ae9.webp?v=1768209378","width":2000},{"alt":null,"id":26650724597859,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/577e88f3ed8217b4dea28048517158964d302da4.webp?v=1768209378"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/577e88f3ed8217b4dea28048517158964d302da4.webp?v=1768209378","width":2000},{"alt":null,"id":26650724728931,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5d851a0b607e705bd009c38b392ae3e37c57075c.webp?v=1768209379"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5d851a0b607e705bd009c38b392ae3e37c57075c.webp?v=1768209379","width":2000},{"alt":null,"id":26650724958307,"position":7,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa55ae2772e9811b916ab01bf6bd69e08fb896c9.webp?v=1768209382"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa55ae2772e9811b916ab01bf6bd69e08fb896c9.webp?v=1768209382","width":2000},{"alt":null,"id":26650725253219,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/ca56bb667d0c5ad9c8bc3cf922e99317f6a9e675.webp?v=1768209382"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/ca56bb667d0c5ad9c8bc3cf922e99317f6a9e675.webp?v=1768209382","width":2000},{"alt":null,"id":26650725482595,"position":9,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/599854ec1a1bc1360824c0b0c81f5ed5b8b85a3e.webp?v=1768209383"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/599854ec1a1bc1360824c0b0c81f5ed5b8b85a3e.webp?v=1768209383","width":2000},{"alt":null,"id":26650725646435,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cf50b7d3cc932348176e3294ada760853cae7638.webp?v=1768209383"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cf50b7d3cc932348176e3294ada760853cae7638.webp?v=1768209383","width":2000},{"alt":null,"id":26650725810275,"position":11,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/db9475b452608a607e567e310a0e08d76947f173.webp?v=1768209383"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/db9475b452608a607e567e310a0e08d76947f173.webp?v=1768209383","width":2000}],"requires_selling_plan":false,"selling_plan_groups":[],"content":null};
$isMerge = null;
$variants = [{"id":43946341269603,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"NPB01185C1-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094068297827,"product_id":7951313862755,"position":3,"created_at":"2026-01-12T17:16:15+08:00","updated_at":"2026-01-12T17:16:17+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/111eb7892a04f4eee63ce0fb8108a193c14487bb.webp?v=1768209377","variant_ids":[43946341269603]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - Lavender","public_title":"Lavender","options":["Lavender"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB01185C1-TAN04","featured_media":{"alt":null,"id":26650724106339,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/111eb7892a04f4eee63ce0fb8108a193c14487bb.webp?v=1768209377"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43946345365603,"title":"Graphite","option1":"Graphite","option2":null,"option3":null,"sku":"NPB0118569-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094069444707,"product_id":7951313862755,"position":8,"created_at":"2026-01-12T17:16:20+08:00","updated_at":"2026-01-12T17:16:22+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/ca56bb667d0c5ad9c8bc3cf922e99317f6a9e675.webp?v=1768209382","variant_ids":[43946345365603]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - Graphite","public_title":"Graphite","options":["Graphite"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB0118569-TAN04","featured_media":{"alt":null,"id":26650725253219,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/ca56bb667d0c5ad9c8bc3cf922e99317f6a9e675.webp?v=1768209382"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43946345431139,"title":"Navy Blue","option1":"Navy Blue","option2":null,"option3":null,"sku":"NPB01185J5-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094069837923,"product_id":7951313862755,"position":10,"created_at":"2026-01-12T17:16:21+08:00","updated_at":"2026-01-12T17:16:23+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cf50b7d3cc932348176e3294ada760853cae7638.webp?v=1768209383","variant_ids":[43946345431139]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - Navy Blue","public_title":"Navy Blue","options":["Navy Blue"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB01185J5-TAN04","featured_media":{"alt":null,"id":26650725646435,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cf50b7d3cc932348176e3294ada760853cae7638.webp?v=1768209383"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43946345496675,"title":"White","option1":"White","option2":null,"option3":null,"sku":"NPB0118504-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094068920419,"product_id":7951313862755,"position":6,"created_at":"2026-01-12T17:16:17+08:00","updated_at":"2026-01-12T17:16:19+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5d851a0b607e705bd009c38b392ae3e37c57075c.webp?v=1768209379","variant_ids":[43946345496675]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - White","public_title":"White","options":["White"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB0118504-TAN04","featured_media":{"alt":null,"id":26650724728931,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5d851a0b607e705bd009c38b392ae3e37c57075c.webp?v=1768209379"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43946345594979,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"NPB0118524-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094068559971,"product_id":7951313862755,"position":4,"created_at":"2026-01-12T17:16:16+08:00","updated_at":"2026-01-12T17:16:18+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/10e196945cefda28023b1454b688753ff9fb1ae9.webp?v=1768209378","variant_ids":[43946345594979]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - Black","public_title":"Black","options":["Black"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB0118524-TAN04","featured_media":{"alt":null,"id":26650724401251,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/10e196945cefda28023b1454b688753ff9fb1ae9.webp?v=1768209378"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}];
$defaultVariant = {"id":43946341269603,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"NPB01185C1-TAN04","requires_shipping":true,"taxable":true,"featured_image":{"id":35094068297827,"product_id":7951313862755,"position":3,"created_at":"2026-01-12T17:16:15+08:00","updated_at":"2026-01-12T17:16:17+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/111eb7892a04f4eee63ce0fb8108a193c14487bb.webp?v=1768209377","variant_ids":[43946341269603]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX 田中 Shen Sparkly - Lavender","public_title":"Lavender","options":["Lavender"],"price":90000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"NPB01185C1-TAN04","featured_media":{"alt":null,"id":26650724106339,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/111eb7892a04f4eee63ce0fb8108a193c14487bb.webp?v=1768209377"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}};
$device_handle = null;
$brand_handle = null;
$type = "";
var sellingStatus
// 只有設計款(SKU 含 '-')才需要合圖
if ($isMerge && $defaultVariant.sku.includes('-')) {
$(document).ready(function() {
var productImg = $product.images[0];
var bumperImg = window.getProductImageUrl($defaultVariant.sku.split('-')[0]);
var layers = ($type === 'mod-nx-backplate' || $type === 'mod-backplate')
? [productImg, bumperImg]
: [bumperImg, productImg];
window.mergeProductImages(layers).then(function (mergedImg) {
$('.merged-img').attr('src', mergedImg);
});
});
};
var sellingStatusData
window.fetchSellingStatus().then(data => {
try {
sellingStatusData = data;
} catch (error) {
sellingStatusData = null
console.error('Unable to parse selling status', error)
}
$(document).ready(function() {
handleSellingStatus($defaultVariant.sku);
});
})
function handleSellingStatus(currentSku) {
if (!sellingStatusData) {
console.error('No selling status available!')
return
}
const sellingStatusElement = document.getElementById('selling-status')
const addToCartButton = document.getElementById('AddToCart-product-template')
const currentProductSku = currentSku.replace(/-(.*)$/, '-')
if ($variants) {
const flattenedSellingStatus = [...sellingStatusData.pending, ...sellingStatusData.preorder]
const matchSellingStatusProduct = flattenedSellingStatus.filter(product => currentProductSku === product.sku)
if (matchSellingStatusProduct.length > 0) {
const isProductPending = matchSellingStatusProduct[0].status === 'pending'
const matchDate = matchSellingStatusProduct[0].date
sellingStatus = isProductPending
? "缺貨中"
: "預購完成出貨日:" + matchDate
sellingStatusElement.textContent = sellingStatus
if (sellingStatus.includes("缺貨中")){
addToCartButton.disabled ='true';
addToCartButton.textContent = "缺貨中無法加入購物車"
} else {
addToCartButton.textContent = "加到購物車"
}
} else {
sellingStatusElement.textContent = ''
addToCartButton.textContent = "加到購物車"
};
};
};
document.addEventListener('DOMContentLoaded', function () {
var currentVariantSelect = document.getElementById('SingleOptionSelector-0')
currentVariantSelect.addEventListener('change', function() {
var currentSku = $('#current_sku').text()
var skuElement = document.getElementById('current-sku')
skuElement.textContent = currentSku
handleSellingStatus(currentSku)
});
});
// Override default values of shop.strings for each template.
// Alternate product templates can change values of
// add to cart button, sold out, and unavailable states here.
theme.productStrings = {
addToCart: "加到購物車",
soldOut: "售完",
unavailable: "停產"
}