$product = {"id":6977467416675,"title":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌","handle":"iphone-12-pro-max-solidsuit-classic-magsafe-oz32","description":null,"published_at":"2023-07-31T18:01:51+08:00","created_at":"2023-07-22T20:11:41+08:00","vendor":"RHINOSHIELD Taiwan B2B","type":"設計師SolidSuit MagSafe專區-華納兄弟百年慶典 Warner Bros 100th Anniversary","tags":["10%","20%","30%","40%","50%","brand-Apple","designer","designer-marvel","device-iPhone 12 Pro Max","merge","reseller-marvel"],"price":125000,"price_min":125000,"price_max":125000,"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":40565623685219,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"MST0118752-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849043555,"product_id":6977467416675,"position":3,"created_at":"2025-11-24T11:18:50+08:00","updated_at":"2025-11-24T11:18:52+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/0f1e51b76e5c1e55c8ea40c7cacf5e304995157a.webp?v=1763954332","variant_ids":[40565623685219]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Black","public_title":"Black","options":["Black"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST0118752-OZ32","featured_media":{"alt":null,"id":26397667098723,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/0f1e51b76e5c1e55c8ea40c7cacf5e304995157a.webp?v=1763954332"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":40565623816291,"title":"Cobalt Blue","option1":"Cobalt Blue","option2":null,"option3":null,"sku":"MST01187O9-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849305699,"product_id":6977467416675,"position":5,"created_at":"2025-11-24T11:18:51+08:00","updated_at":"2025-11-24T11:18:53+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/87d47032c07cb5ff562e86abf47d2ea784ef5aae.webp?v=1763954333","variant_ids":[40565623816291]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Cobalt Blue","public_title":"Cobalt Blue","options":["Cobalt Blue"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST01187O9-OZ32","featured_media":{"alt":null,"id":26397667360867,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/87d47032c07cb5ff562e86abf47d2ea784ef5aae.webp?v=1763954333"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":40565624045667,"title":"Shell Beige","option1":"Shell Beige","option2":null,"option3":null,"sku":"MST011870B-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849731683,"product_id":6977467416675,"position":8,"created_at":"2025-11-24T11:18:53+08:00","updated_at":"2025-11-24T11:18:55+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8dd1317dd9278957601f8fd7e98b2b2ba6ed4ac3.webp?v=1763954335","variant_ids":[40565624045667]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Shell Beige","public_title":"Shell Beige","options":["Shell Beige"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST011870B-OZ32","featured_media":{"alt":null,"id":26397667885155,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8dd1317dd9278957601f8fd7e98b2b2ba6ed4ac3.webp?v=1763954335"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":40565624143971,"title":"Classic Blue","option1":"Classic Blue","option2":null,"option3":null,"sku":"MST011870C-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849240163,"product_id":6977467416675,"position":4,"created_at":"2025-11-24T11:18:51+08:00","updated_at":"2025-11-24T11:18:53+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/039071da2270cf5e243f78eb0b8861d5d887c1fd.webp?v=1763954333","variant_ids":[40565624143971]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Classic Blue","public_title":"Classic Blue","options":["Classic Blue"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST011870C-OZ32","featured_media":{"alt":null,"id":26397667295331,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/039071da2270cf5e243f78eb0b8861d5d887c1fd.webp?v=1763954333"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":40565624176739,"title":"Parakeet Green","option1":"Parakeet Green","option2":null,"option3":null,"sku":"MST011870E-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849502307,"product_id":6977467416675,"position":6,"created_at":"2025-11-24T11:18:52+08:00","updated_at":"2025-11-24T11:18:54+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2d9f0278261dcb26fae97fae33c40a8aa4c21263.webp?v=1763954334","variant_ids":[40565624176739]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Parakeet Green","public_title":"Parakeet Green","options":["Parakeet Green"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST011870E-OZ32","featured_media":{"alt":null,"id":26397667557475,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2d9f0278261dcb26fae97fae33c40a8aa4c21263.webp?v=1763954334"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}],"images":["\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/SolidSuitTPE-53-187-OZ32_1a84c4fe-dff5-4731-a558-4af25607a80c.png?v=1690027903","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8b38aca5e07e09a6a077b9219bf150337414d9db.webp?v=1763954331","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/0f1e51b76e5c1e55c8ea40c7cacf5e304995157a.webp?v=1763954332","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/039071da2270cf5e243f78eb0b8861d5d887c1fd.webp?v=1763954333","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/87d47032c07cb5ff562e86abf47d2ea784ef5aae.webp?v=1763954333","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2d9f0278261dcb26fae97fae33c40a8aa4c21263.webp?v=1763954334","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/7d41e17f9d399f2576707b88a408794fc9dd98e2.webp?v=1763954334","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8dd1317dd9278957601f8fd7e98b2b2ba6ed4ac3.webp?v=1763954335","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/a62acb855bc51c7ebf30c8437bfc54043e05a00b.webp?v=1763954335"],"featured_image":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/SolidSuitTPE-53-187-OZ32_1a84c4fe-dff5-4731-a558-4af25607a80c.png?v=1690027903","options":["color"],"media":[{"alt":null,"id":22622008213603,"position":1,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/SolidSuitTPE-53-187-OZ32_1a84c4fe-dff5-4731-a558-4af25607a80c.png?v=1690027903"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/SolidSuitTPE-53-187-OZ32_1a84c4fe-dff5-4731-a558-4af25607a80c.png?v=1690027903","width":2000},{"alt":null,"id":26397666869347,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8b38aca5e07e09a6a077b9219bf150337414d9db.webp?v=1763954331"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8b38aca5e07e09a6a077b9219bf150337414d9db.webp?v=1763954331","width":2000},{"alt":null,"id":26397667098723,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/0f1e51b76e5c1e55c8ea40c7cacf5e304995157a.webp?v=1763954332"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/0f1e51b76e5c1e55c8ea40c7cacf5e304995157a.webp?v=1763954332","width":2000},{"alt":null,"id":26397667295331,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/039071da2270cf5e243f78eb0b8861d5d887c1fd.webp?v=1763954333"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/039071da2270cf5e243f78eb0b8861d5d887c1fd.webp?v=1763954333","width":2000},{"alt":null,"id":26397667360867,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/87d47032c07cb5ff562e86abf47d2ea784ef5aae.webp?v=1763954333"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/87d47032c07cb5ff562e86abf47d2ea784ef5aae.webp?v=1763954333","width":2000},{"alt":null,"id":26397667557475,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2d9f0278261dcb26fae97fae33c40a8aa4c21263.webp?v=1763954334"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2d9f0278261dcb26fae97fae33c40a8aa4c21263.webp?v=1763954334","width":2000},{"alt":null,"id":26397667688547,"position":7,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/7d41e17f9d399f2576707b88a408794fc9dd98e2.webp?v=1763954334"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/7d41e17f9d399f2576707b88a408794fc9dd98e2.webp?v=1763954334","width":2000},{"alt":null,"id":26397667885155,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8dd1317dd9278957601f8fd7e98b2b2ba6ed4ac3.webp?v=1763954335"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8dd1317dd9278957601f8fd7e98b2b2ba6ed4ac3.webp?v=1763954335","width":2000},{"alt":null,"id":26397668016227,"position":9,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/a62acb855bc51c7ebf30c8437bfc54043e05a00b.webp?v=1763954335"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/a62acb855bc51c7ebf30c8437bfc54043e05a00b.webp?v=1763954335","width":2000}],"requires_selling_plan":false,"selling_plan_groups":[],"content":null};
$isMerge = null;
$variants = [{"id":40565623685219,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"MST0118752-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849043555,"product_id":6977467416675,"position":3,"created_at":"2025-11-24T11:18:50+08:00","updated_at":"2025-11-24T11:18:52+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/0f1e51b76e5c1e55c8ea40c7cacf5e304995157a.webp?v=1763954332","variant_ids":[40565623685219]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Black","public_title":"Black","options":["Black"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST0118752-OZ32","featured_media":{"alt":null,"id":26397667098723,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/0f1e51b76e5c1e55c8ea40c7cacf5e304995157a.webp?v=1763954332"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":40565623816291,"title":"Cobalt Blue","option1":"Cobalt Blue","option2":null,"option3":null,"sku":"MST01187O9-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849305699,"product_id":6977467416675,"position":5,"created_at":"2025-11-24T11:18:51+08:00","updated_at":"2025-11-24T11:18:53+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/87d47032c07cb5ff562e86abf47d2ea784ef5aae.webp?v=1763954333","variant_ids":[40565623816291]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Cobalt Blue","public_title":"Cobalt Blue","options":["Cobalt Blue"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST01187O9-OZ32","featured_media":{"alt":null,"id":26397667360867,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/87d47032c07cb5ff562e86abf47d2ea784ef5aae.webp?v=1763954333"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":40565624045667,"title":"Shell Beige","option1":"Shell Beige","option2":null,"option3":null,"sku":"MST011870B-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849731683,"product_id":6977467416675,"position":8,"created_at":"2025-11-24T11:18:53+08:00","updated_at":"2025-11-24T11:18:55+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8dd1317dd9278957601f8fd7e98b2b2ba6ed4ac3.webp?v=1763954335","variant_ids":[40565624045667]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Shell Beige","public_title":"Shell Beige","options":["Shell Beige"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST011870B-OZ32","featured_media":{"alt":null,"id":26397667885155,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/8dd1317dd9278957601f8fd7e98b2b2ba6ed4ac3.webp?v=1763954335"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":40565624143971,"title":"Classic Blue","option1":"Classic Blue","option2":null,"option3":null,"sku":"MST011870C-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849240163,"product_id":6977467416675,"position":4,"created_at":"2025-11-24T11:18:51+08:00","updated_at":"2025-11-24T11:18:53+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/039071da2270cf5e243f78eb0b8861d5d887c1fd.webp?v=1763954333","variant_ids":[40565624143971]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Classic Blue","public_title":"Classic Blue","options":["Classic Blue"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST011870C-OZ32","featured_media":{"alt":null,"id":26397667295331,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/039071da2270cf5e243f78eb0b8861d5d887c1fd.webp?v=1763954333"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":40565624176739,"title":"Parakeet Green","option1":"Parakeet Green","option2":null,"option3":null,"sku":"MST011870E-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849502307,"product_id":6977467416675,"position":6,"created_at":"2025-11-24T11:18:52+08:00","updated_at":"2025-11-24T11:18:54+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2d9f0278261dcb26fae97fae33c40a8aa4c21263.webp?v=1763954334","variant_ids":[40565624176739]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Parakeet Green","public_title":"Parakeet Green","options":["Parakeet Green"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST011870E-OZ32","featured_media":{"alt":null,"id":26397667557475,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/2d9f0278261dcb26fae97fae33c40a8aa4c21263.webp?v=1763954334"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}];
$defaultVariant = {"id":40565623685219,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"MST0118752-OZ32","requires_shipping":true,"taxable":true,"featured_image":{"id":34832849043555,"product_id":6977467416675,"position":3,"created_at":"2025-11-24T11:18:50+08:00","updated_at":"2025-11-24T11:18:52+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/0f1e51b76e5c1e55c8ea40c7cacf5e304995157a.webp?v=1763954332","variant_ids":[40565623685219]},"available":true,"name":"iPhone 12 Pro Max SolidSuit (MagSafe 兼容) MARVEL 漫威系列 漫威Logo-迷你標誌 - Black","public_title":"Black","options":["Black"],"price":125000,"weight":1350,"compare_at_price":null,"inventory_quantity":2500,"inventory_management":null,"inventory_policy":"deny","barcode":"MST0118752-OZ32","featured_media":{"alt":null,"id":26397667098723,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/0f1e51b76e5c1e55c8ea40c7cacf5e304995157a.webp?v=1763954332"}},"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: "停產"
}