$product = {"id":7911162609763,"title":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW","handle":"iphone-12-pro-mod-nx-magsafe-printable-pos05","description":null,"published_at":"2025-11-05T10:54:28+08:00","created_at":"2025-11-04T10:25:12+08:00","vendor":"RHINOSHIELD Taiwan B2B","type":"","tags":["10%","20%","30%","40%","50%","brand-Apple","designer","designer-posterlad","device-iPhone 12 Pro","merge","reseller-posterlad"],"price":110000,"price_min":110000,"price_max":110000,"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":43811818668131,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"MPB01185C1-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728945418339,"product_id":7911162609763,"position":4,"created_at":"2025-11-04T10:25:20+08:00","updated_at":"2025-11-04T10:25:21+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8935a9ac5a1e130a33b9db62a57c10721a5a3e07.webp?v=1762223121","variant_ids":[43811818668131]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - Lavender","public_title":"Lavender","options":["Lavender"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB01185C1-POS05","featured_media":{"alt":null,"id":26296813912163,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8935a9ac5a1e130a33b9db62a57c10721a5a3e07.webp?v=1762223121"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43811823779939,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"MPB0118524-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728946434147,"product_id":7911162609763,"position":9,"created_at":"2025-11-04T10:25:24+08:00","updated_at":"2025-11-04T10:25:26+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/38ab077cf926c23a18c7889852a6164932d12163.webp?v=1762223126","variant_ids":[43811823779939]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - Black","public_title":"Black","options":["Black"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB0118524-POS05","featured_media":{"alt":null,"id":26296814895203,"position":9,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/38ab077cf926c23a18c7889852a6164932d12163.webp?v=1762223126"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43811823812707,"title":"Navy Blue","option1":"Navy Blue","option2":null,"option3":null,"sku":"MPB01185J5-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728946532451,"product_id":7911162609763,"position":10,"created_at":"2025-11-04T10:25:25+08:00","updated_at":"2025-11-04T10:25:27+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cecd9acf93167047925ba878191d784722bae927.webp?v=1762223127","variant_ids":[43811823812707]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - Navy Blue","public_title":"Navy Blue","options":["Navy Blue"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB01185J5-POS05","featured_media":{"alt":null,"id":26296815026275,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cecd9acf93167047925ba878191d784722bae927.webp?v=1762223127"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43811823845475,"title":"Graphite","option1":"Graphite","option2":null,"option3":null,"sku":"MPB0118569-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728945090659,"product_id":7911162609763,"position":3,"created_at":"2025-11-04T10:25:19+08:00","updated_at":"2025-11-04T10:25:21+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2f4fbd3146243abc3f7f04ed99ced67b884a4453.webp?v=1762223121","variant_ids":[43811823845475]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - Graphite","public_title":"Graphite","options":["Graphite"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB0118569-POS05","featured_media":{"alt":null,"id":26296813551715,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2f4fbd3146243abc3f7f04ed99ced67b884a4453.webp?v=1762223121"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43811824042083,"title":"White","option1":"White","option2":null,"option3":null,"sku":"MPB0118504-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728945647715,"product_id":7911162609763,"position":5,"created_at":"2025-11-04T10:25:21+08:00","updated_at":"2025-11-04T10:25:22+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/d332bec3a8ad6982fcc02c77a782ed383884fea3.webp?v=1762223122","variant_ids":[43811824042083]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - White","public_title":"White","options":["White"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB0118504-POS05","featured_media":{"alt":null,"id":26296814108771,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/d332bec3a8ad6982fcc02c77a782ed383884fea3.webp?v=1762223122"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}],"images":["\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/af0b4b7b25ab4111ae737f795eb730d5ebc76bef.webp?v=1762223119","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/233961e29b4d83639e5064b5a76afca1ae338a88.webp?v=1762223120","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2f4fbd3146243abc3f7f04ed99ced67b884a4453.webp?v=1762223121","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8935a9ac5a1e130a33b9db62a57c10721a5a3e07.webp?v=1762223121","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/d332bec3a8ad6982fcc02c77a782ed383884fea3.webp?v=1762223122","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/181385fcf3ece1ea00372bf62d2abb89193eafb2.webp?v=1762223123","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cd6897361fc80d42bdc93004923fcbe909cbd3da.webp?v=1762223124","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/26031579d129006c183529bca0d01640fa010c04.webp?v=1762223125","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/38ab077cf926c23a18c7889852a6164932d12163.webp?v=1762223126","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cecd9acf93167047925ba878191d784722bae927.webp?v=1762223127","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5c7d0497e004c9d5120c353d8a112710e94171d5.webp?v=1762223128"],"featured_image":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/af0b4b7b25ab4111ae737f795eb730d5ebc76bef.webp?v=1762223119","options":["color"],"media":[{"alt":null,"id":26296812961891,"position":1,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/af0b4b7b25ab4111ae737f795eb730d5ebc76bef.webp?v=1762223119"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/af0b4b7b25ab4111ae737f795eb730d5ebc76bef.webp?v=1762223119","width":2000},{"alt":null,"id":26296813322339,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/233961e29b4d83639e5064b5a76afca1ae338a88.webp?v=1762223120"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/233961e29b4d83639e5064b5a76afca1ae338a88.webp?v=1762223120","width":2000},{"alt":null,"id":26296813551715,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2f4fbd3146243abc3f7f04ed99ced67b884a4453.webp?v=1762223121"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2f4fbd3146243abc3f7f04ed99ced67b884a4453.webp?v=1762223121","width":2000},{"alt":null,"id":26296813912163,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8935a9ac5a1e130a33b9db62a57c10721a5a3e07.webp?v=1762223121"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8935a9ac5a1e130a33b9db62a57c10721a5a3e07.webp?v=1762223121","width":2000},{"alt":null,"id":26296814108771,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/d332bec3a8ad6982fcc02c77a782ed383884fea3.webp?v=1762223122"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/d332bec3a8ad6982fcc02c77a782ed383884fea3.webp?v=1762223122","width":2000},{"alt":null,"id":26296814272611,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/181385fcf3ece1ea00372bf62d2abb89193eafb2.webp?v=1762223123"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/181385fcf3ece1ea00372bf62d2abb89193eafb2.webp?v=1762223123","width":2000},{"alt":null,"id":26296814567523,"position":7,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cd6897361fc80d42bdc93004923fcbe909cbd3da.webp?v=1762223124"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cd6897361fc80d42bdc93004923fcbe909cbd3da.webp?v=1762223124","width":2000},{"alt":null,"id":26296814731363,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/26031579d129006c183529bca0d01640fa010c04.webp?v=1762223125"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/26031579d129006c183529bca0d01640fa010c04.webp?v=1762223125","width":2000},{"alt":null,"id":26296814895203,"position":9,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/38ab077cf926c23a18c7889852a6164932d12163.webp?v=1762223126"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/38ab077cf926c23a18c7889852a6164932d12163.webp?v=1762223126","width":2000},{"alt":null,"id":26296815026275,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cecd9acf93167047925ba878191d784722bae927.webp?v=1762223127"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cecd9acf93167047925ba878191d784722bae927.webp?v=1762223127","width":2000},{"alt":null,"id":26296815124579,"position":11,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5c7d0497e004c9d5120c353d8a112710e94171d5.webp?v=1762223128"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/5c7d0497e004c9d5120c353d8a112710e94171d5.webp?v=1762223128","width":2000}],"requires_selling_plan":false,"selling_plan_groups":[],"content":null};
$isMerge = null;
$variants = [{"id":43811818668131,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"MPB01185C1-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728945418339,"product_id":7911162609763,"position":4,"created_at":"2025-11-04T10:25:20+08:00","updated_at":"2025-11-04T10:25:21+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8935a9ac5a1e130a33b9db62a57c10721a5a3e07.webp?v=1762223121","variant_ids":[43811818668131]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - Lavender","public_title":"Lavender","options":["Lavender"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB01185C1-POS05","featured_media":{"alt":null,"id":26296813912163,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8935a9ac5a1e130a33b9db62a57c10721a5a3e07.webp?v=1762223121"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43811823779939,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"MPB0118524-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728946434147,"product_id":7911162609763,"position":9,"created_at":"2025-11-04T10:25:24+08:00","updated_at":"2025-11-04T10:25:26+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/38ab077cf926c23a18c7889852a6164932d12163.webp?v=1762223126","variant_ids":[43811823779939]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - Black","public_title":"Black","options":["Black"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB0118524-POS05","featured_media":{"alt":null,"id":26296814895203,"position":9,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/38ab077cf926c23a18c7889852a6164932d12163.webp?v=1762223126"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43811823812707,"title":"Navy Blue","option1":"Navy Blue","option2":null,"option3":null,"sku":"MPB01185J5-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728946532451,"product_id":7911162609763,"position":10,"created_at":"2025-11-04T10:25:25+08:00","updated_at":"2025-11-04T10:25:27+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cecd9acf93167047925ba878191d784722bae927.webp?v=1762223127","variant_ids":[43811823812707]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - Navy Blue","public_title":"Navy Blue","options":["Navy Blue"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB01185J5-POS05","featured_media":{"alt":null,"id":26296815026275,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/cecd9acf93167047925ba878191d784722bae927.webp?v=1762223127"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43811823845475,"title":"Graphite","option1":"Graphite","option2":null,"option3":null,"sku":"MPB0118569-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728945090659,"product_id":7911162609763,"position":3,"created_at":"2025-11-04T10:25:19+08:00","updated_at":"2025-11-04T10:25:21+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2f4fbd3146243abc3f7f04ed99ced67b884a4453.webp?v=1762223121","variant_ids":[43811823845475]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - Graphite","public_title":"Graphite","options":["Graphite"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB0118569-POS05","featured_media":{"alt":null,"id":26296813551715,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2f4fbd3146243abc3f7f04ed99ced67b884a4453.webp?v=1762223121"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43811824042083,"title":"White","option1":"White","option2":null,"option3":null,"sku":"MPB0118504-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728945647715,"product_id":7911162609763,"position":5,"created_at":"2025-11-04T10:25:21+08:00","updated_at":"2025-11-04T10:25:22+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/d332bec3a8ad6982fcc02c77a782ed383884fea3.webp?v=1762223122","variant_ids":[43811824042083]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - White","public_title":"White","options":["White"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB0118504-POS05","featured_media":{"alt":null,"id":26296814108771,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/d332bec3a8ad6982fcc02c77a782ed383884fea3.webp?v=1762223122"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}];
$defaultVariant = {"id":43811818668131,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"MPB01185C1-POS05","requires_shipping":true,"taxable":true,"featured_image":{"id":34728945418339,"product_id":7911162609763,"position":4,"created_at":"2025-11-04T10:25:20+08:00","updated_at":"2025-11-04T10:25:21+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8935a9ac5a1e130a33b9db62a57c10721a5a3e07.webp?v=1762223121","variant_ids":[43811818668131]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) PosterLad NOW - Lavender","public_title":"Lavender","options":["Lavender"],"price":110000,"weight":0,"compare_at_price":null,"inventory_quantity":0,"inventory_management":null,"inventory_policy":"deny","barcode":"MPB01185C1-POS05","featured_media":{"alt":null,"id":26296813912163,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8935a9ac5a1e130a33b9db62a57c10721a5a3e07.webp?v=1762223121"}},"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: "停產"
}