$product = {"id":7893893251171,"title":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女","handle":"iphone-12-pro-mod-nx-printable-chu02","description":null,"published_at":"2025-10-09T09:18:04+08:00","created_at":"2025-10-07T10:38:24+08:00","vendor":"RHINOSHIELD Taiwan B2B","type":"","tags":["10%","20%","30%","40%","50%","brand-Apple","designer","designer-chubbynida","device-iPhone 12 Pro","merge","reseller-chubbynida"],"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":43763677855843,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"NPB01185C1-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553412092003,"product_id":7893893251171,"position":2,"created_at":"2025-10-07T10:38:26+08:00","updated_at":"2025-10-07T10:38:28+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/49908232f11d3b5094d9300ed7e2d13590a5c86c.webp?v=1759804708","variant_ids":[43763677855843]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123059691619,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/49908232f11d3b5094d9300ed7e2d13590a5c86c.webp?v=1759804708"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43763682213987,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"NPB0118524-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553413402723,"product_id":7893893251171,"position":6,"created_at":"2025-10-07T10:38:31+08:00","updated_at":"2025-10-07T10:38:33+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/aab10e07386b85000ebe49fb940941dd63eb6ce8.webp?v=1759804713","variant_ids":[43763682213987]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123061035107,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/aab10e07386b85000ebe49fb940941dd63eb6ce8.webp?v=1759804713"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43763682279523,"title":"White","option1":"White","option2":null,"option3":null,"sku":"NPB0118504-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553414352995,"product_id":7893893251171,"position":10,"created_at":"2025-10-07T10:38:34+08:00","updated_at":"2025-10-07T10:38:36+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/165dc1dc38e55851fcd2df03a69c68e7f938ef97.webp?v=1759804716","variant_ids":[43763682279523]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123061985379,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/165dc1dc38e55851fcd2df03a69c68e7f938ef97.webp?v=1759804716"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43763682345059,"title":"Navy Blue","option1":"Navy Blue","option2":null,"option3":null,"sku":"NPB01185J5-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553411829859,"product_id":7893893251171,"position":1,"created_at":"2025-10-07T10:38:25+08:00","updated_at":"2025-10-07T10:38:27+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/509fb775d54860cc638336f9e5fc661781052e62.webp?v=1759804707","variant_ids":[43763682345059]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123059462243,"position":1,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/509fb775d54860cc638336f9e5fc661781052e62.webp?v=1759804707"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43763682377827,"title":"Graphite","option1":"Graphite","option2":null,"option3":null,"sku":"NPB0118569-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553413894243,"product_id":7893893251171,"position":8,"created_at":"2025-10-07T10:38:32+08:00","updated_at":"2025-10-07T10:38:34+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8265d785274cff26efb163b33045e8003b9f982e.webp?v=1759804714","variant_ids":[43763682377827]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123061526627,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8265d785274cff26efb163b33045e8003b9f982e.webp?v=1759804714"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}],"images":["\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/509fb775d54860cc638336f9e5fc661781052e62.webp?v=1759804707","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/49908232f11d3b5094d9300ed7e2d13590a5c86c.webp?v=1759804708","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/6c75d577ba1f9f60d285a254dce6bbb33a88fa14.webp?v=1759804709","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/6414f6e031cf57636ca7f78ac3e5aad1ca409f48.webp?v=1759804709","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/e99b2f81a48f1f1e6c79c5e78629cf87a3f240a8.webp?v=1759804710","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/aab10e07386b85000ebe49fb940941dd63eb6ce8.webp?v=1759804713","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/389da0c701f398860bcd43b260b710bc11db7f92.webp?v=1759804714","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8265d785274cff26efb163b33045e8003b9f982e.webp?v=1759804714","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/20cd10e12f5f7e0d88b5e699ee2c942409735334.webp?v=1759804715","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/165dc1dc38e55851fcd2df03a69c68e7f938ef97.webp?v=1759804716","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/9c6610a0f76df06c1e6297e4f9cf4446191faa73.webp?v=1759804717"],"featured_image":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/509fb775d54860cc638336f9e5fc661781052e62.webp?v=1759804707","options":["color"],"media":[{"alt":null,"id":26123059462243,"position":1,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/509fb775d54860cc638336f9e5fc661781052e62.webp?v=1759804707"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/509fb775d54860cc638336f9e5fc661781052e62.webp?v=1759804707","width":2000},{"alt":null,"id":26123059691619,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/49908232f11d3b5094d9300ed7e2d13590a5c86c.webp?v=1759804708"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/49908232f11d3b5094d9300ed7e2d13590a5c86c.webp?v=1759804708","width":2000},{"alt":null,"id":26123060019299,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/6c75d577ba1f9f60d285a254dce6bbb33a88fa14.webp?v=1759804709"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/6c75d577ba1f9f60d285a254dce6bbb33a88fa14.webp?v=1759804709","width":2000},{"alt":null,"id":26123060379747,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/6414f6e031cf57636ca7f78ac3e5aad1ca409f48.webp?v=1759804709"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/6414f6e031cf57636ca7f78ac3e5aad1ca409f48.webp?v=1759804709","width":2000},{"alt":null,"id":26123060838499,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/e99b2f81a48f1f1e6c79c5e78629cf87a3f240a8.webp?v=1759804710"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/e99b2f81a48f1f1e6c79c5e78629cf87a3f240a8.webp?v=1759804710","width":2000},{"alt":null,"id":26123061035107,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/aab10e07386b85000ebe49fb940941dd63eb6ce8.webp?v=1759804713"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/aab10e07386b85000ebe49fb940941dd63eb6ce8.webp?v=1759804713","width":2000},{"alt":null,"id":26123061297251,"position":7,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/389da0c701f398860bcd43b260b710bc11db7f92.webp?v=1759804714"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/389da0c701f398860bcd43b260b710bc11db7f92.webp?v=1759804714","width":2000},{"alt":null,"id":26123061526627,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8265d785274cff26efb163b33045e8003b9f982e.webp?v=1759804714"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8265d785274cff26efb163b33045e8003b9f982e.webp?v=1759804714","width":2000},{"alt":null,"id":26123061756003,"position":9,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/20cd10e12f5f7e0d88b5e699ee2c942409735334.webp?v=1759804715"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/20cd10e12f5f7e0d88b5e699ee2c942409735334.webp?v=1759804715","width":2000},{"alt":null,"id":26123061985379,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/165dc1dc38e55851fcd2df03a69c68e7f938ef97.webp?v=1759804716"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/165dc1dc38e55851fcd2df03a69c68e7f938ef97.webp?v=1759804716","width":2000},{"alt":null,"id":26123062247523,"position":11,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/9c6610a0f76df06c1e6297e4f9cf4446191faa73.webp?v=1759804717"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/9c6610a0f76df06c1e6297e4f9cf4446191faa73.webp?v=1759804717","width":2000}],"requires_selling_plan":false,"selling_plan_groups":[],"content":null};
$isMerge = null;
$variants = [{"id":43763677855843,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"NPB01185C1-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553412092003,"product_id":7893893251171,"position":2,"created_at":"2025-10-07T10:38:26+08:00","updated_at":"2025-10-07T10:38:28+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/49908232f11d3b5094d9300ed7e2d13590a5c86c.webp?v=1759804708","variant_ids":[43763677855843]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123059691619,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/49908232f11d3b5094d9300ed7e2d13590a5c86c.webp?v=1759804708"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43763682213987,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"NPB0118524-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553413402723,"product_id":7893893251171,"position":6,"created_at":"2025-10-07T10:38:31+08:00","updated_at":"2025-10-07T10:38:33+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/aab10e07386b85000ebe49fb940941dd63eb6ce8.webp?v=1759804713","variant_ids":[43763682213987]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123061035107,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/aab10e07386b85000ebe49fb940941dd63eb6ce8.webp?v=1759804713"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43763682279523,"title":"White","option1":"White","option2":null,"option3":null,"sku":"NPB0118504-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553414352995,"product_id":7893893251171,"position":10,"created_at":"2025-10-07T10:38:34+08:00","updated_at":"2025-10-07T10:38:36+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/165dc1dc38e55851fcd2df03a69c68e7f938ef97.webp?v=1759804716","variant_ids":[43763682279523]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123061985379,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/165dc1dc38e55851fcd2df03a69c68e7f938ef97.webp?v=1759804716"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43763682345059,"title":"Navy Blue","option1":"Navy Blue","option2":null,"option3":null,"sku":"NPB01185J5-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553411829859,"product_id":7893893251171,"position":1,"created_at":"2025-10-07T10:38:25+08:00","updated_at":"2025-10-07T10:38:27+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/509fb775d54860cc638336f9e5fc661781052e62.webp?v=1759804707","variant_ids":[43763682345059]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123059462243,"position":1,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/509fb775d54860cc638336f9e5fc661781052e62.webp?v=1759804707"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43763682377827,"title":"Graphite","option1":"Graphite","option2":null,"option3":null,"sku":"NPB0118569-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553413894243,"product_id":7893893251171,"position":8,"created_at":"2025-10-07T10:38:32+08:00","updated_at":"2025-10-07T10:38:34+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8265d785274cff26efb163b33045e8003b9f982e.webp?v=1759804714","variant_ids":[43763682377827]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123061526627,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8265d785274cff26efb163b33045e8003b9f982e.webp?v=1759804714"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}];
$defaultVariant = {"id":43763677855843,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"NPB01185C1-CHU02","requires_shipping":true,"taxable":true,"featured_image":{"id":34553412092003,"product_id":7893893251171,"position":2,"created_at":"2025-10-07T10:38:26+08:00","updated_at":"2025-10-07T10:38:28+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/49908232f11d3b5094d9300ed7e2d13590a5c86c.webp?v=1759804708","variant_ids":[43763677855843]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX Chubbynida 魚眼少女 - 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-CHU02","featured_media":{"alt":null,"id":26123059691619,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/49908232f11d3b5094d9300ed7e2d13590a5c86c.webp?v=1759804708"}},"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: "停產"
}