$product = {"id":7956208648291,"title":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏","handle":"iphone-12-pro-mod-nx-magsafe-eme11","description":null,"published_at":"2026-01-28T09:42:55+08:00","created_at":"2026-01-26T14:39:08+08:00","vendor":"RHINOSHIELD Taiwan B2B","type":"","tags":["10%","20%","30%","40%","50%","brand-Apple","designer","designer-emerald","device-iPhone 12 Pro","merge","reseller-emerald"],"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":43966976884835,"title":"Navy Blue","option1":"Navy Blue","option2":null,"option3":null,"sku":"MPB01185J5-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147194368099,"product_id":7956208648291,"position":5,"created_at":"2026-01-26T14:39:51+08:00","updated_at":"2026-01-26T14:39:53+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/4322cfe70d8b1131a3d01891757a8130976fc63c.webp?v=1769409593","variant_ids":[43966976884835]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703432876131,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/4322cfe70d8b1131a3d01891757a8130976fc63c.webp?v=1769409593"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43966982652003,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"MPB01185C1-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147194695779,"product_id":7956208648291,"position":6,"created_at":"2026-01-26T14:39:51+08:00","updated_at":"2026-01-26T14:39:53+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fedd64c7868cbf4345771acca2b7897cf1b9b938.webp?v=1769409593","variant_ids":[43966982652003]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703433203811,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fedd64c7868cbf4345771acca2b7897cf1b9b938.webp?v=1769409593"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43966983077987,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"MPB0118524-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147193352291,"product_id":7956208648291,"position":2,"created_at":"2026-01-26T14:39:50+08:00","updated_at":"2026-01-26T14:39:52+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f401c50015c7fa7c82b02f257014bb261dc6b308.webp?v=1769409592","variant_ids":[43966983077987]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703431860323,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f401c50015c7fa7c82b02f257014bb261dc6b308.webp?v=1769409592"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43966984749155,"title":"Graphite","option1":"Graphite","option2":null,"option3":null,"sku":"MPB0118569-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147195285603,"product_id":7956208648291,"position":7,"created_at":"2026-01-26T14:39:52+08:00","updated_at":"2026-01-26T14:39:54+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa051c387ea3cf9f1b4b3e5bbf3b9396e2bf3cdf.webp?v=1769409594","variant_ids":[43966984749155]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703433793635,"position":7,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa051c387ea3cf9f1b4b3e5bbf3b9396e2bf3cdf.webp?v=1769409594"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43966986846307,"title":"White","option1":"White","option2":null,"option3":null,"sku":"MPB0118504-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147193057379,"product_id":7956208648291,"position":1,"created_at":"2026-01-26T14:39:49+08:00","updated_at":"2026-01-26T14:39:51+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/1897dbc954b34720849f06c73f43621e1e26faf4.webp?v=1769409591","variant_ids":[43966986846307]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703431565411,"position":1,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/1897dbc954b34720849f06c73f43621e1e26faf4.webp?v=1769409591"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}],"images":["\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/1897dbc954b34720849f06c73f43621e1e26faf4.webp?v=1769409591","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f401c50015c7fa7c82b02f257014bb261dc6b308.webp?v=1769409592","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/abac25b95b2a84a38054867114f6511d5f9f7732.webp?v=1769409592","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/7ceb443745f9b160cc4ffc06c192b2cc17f2b8fe.webp?v=1769409593","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/4322cfe70d8b1131a3d01891757a8130976fc63c.webp?v=1769409593","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fedd64c7868cbf4345771acca2b7897cf1b9b938.webp?v=1769409593","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa051c387ea3cf9f1b4b3e5bbf3b9396e2bf3cdf.webp?v=1769409594","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/c22360ea151268569296d718d29d7ddc11b37a2a.webp?v=1769409595","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/be57dbd2801a354f109e39db3e3603e5d781c21d.webp?v=1769409595","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/b08f35b8fe63c6a6dfbd1cd219366cfaf5267edf.webp?v=1769409596","\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/b77f82dff0b245e2b606f3effe71d70db7c1beb0.webp?v=1769409596"],"featured_image":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/1897dbc954b34720849f06c73f43621e1e26faf4.webp?v=1769409591","options":["color"],"media":[{"alt":null,"id":26703431565411,"position":1,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/1897dbc954b34720849f06c73f43621e1e26faf4.webp?v=1769409591"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/1897dbc954b34720849f06c73f43621e1e26faf4.webp?v=1769409591","width":2000},{"alt":null,"id":26703431860323,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f401c50015c7fa7c82b02f257014bb261dc6b308.webp?v=1769409592"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f401c50015c7fa7c82b02f257014bb261dc6b308.webp?v=1769409592","width":2000},{"alt":null,"id":26703432220771,"position":3,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/abac25b95b2a84a38054867114f6511d5f9f7732.webp?v=1769409592"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/abac25b95b2a84a38054867114f6511d5f9f7732.webp?v=1769409592","width":2000},{"alt":null,"id":26703432515683,"position":4,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/7ceb443745f9b160cc4ffc06c192b2cc17f2b8fe.webp?v=1769409593"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/7ceb443745f9b160cc4ffc06c192b2cc17f2b8fe.webp?v=1769409593","width":2000},{"alt":null,"id":26703432876131,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/4322cfe70d8b1131a3d01891757a8130976fc63c.webp?v=1769409593"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/4322cfe70d8b1131a3d01891757a8130976fc63c.webp?v=1769409593","width":2000},{"alt":null,"id":26703433203811,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fedd64c7868cbf4345771acca2b7897cf1b9b938.webp?v=1769409593"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fedd64c7868cbf4345771acca2b7897cf1b9b938.webp?v=1769409593","width":2000},{"alt":null,"id":26703433793635,"position":7,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa051c387ea3cf9f1b4b3e5bbf3b9396e2bf3cdf.webp?v=1769409594"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa051c387ea3cf9f1b4b3e5bbf3b9396e2bf3cdf.webp?v=1769409594","width":2000},{"alt":null,"id":26703434121315,"position":8,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/c22360ea151268569296d718d29d7ddc11b37a2a.webp?v=1769409595"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/c22360ea151268569296d718d29d7ddc11b37a2a.webp?v=1769409595","width":2000},{"alt":null,"id":26703434612835,"position":9,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/be57dbd2801a354f109e39db3e3603e5d781c21d.webp?v=1769409595"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/be57dbd2801a354f109e39db3e3603e5d781c21d.webp?v=1769409595","width":2000},{"alt":null,"id":26703435071587,"position":10,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/b08f35b8fe63c6a6dfbd1cd219366cfaf5267edf.webp?v=1769409596"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/b08f35b8fe63c6a6dfbd1cd219366cfaf5267edf.webp?v=1769409596","width":2000},{"alt":null,"id":26703435595875,"position":11,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/b77f82dff0b245e2b606f3effe71d70db7c1beb0.webp?v=1769409596"},"aspect_ratio":1.0,"height":2000,"media_type":"image","src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/b77f82dff0b245e2b606f3effe71d70db7c1beb0.webp?v=1769409596","width":2000}],"requires_selling_plan":false,"selling_plan_groups":[],"content":null};
$isMerge = null;
$variants = [{"id":43966976884835,"title":"Navy Blue","option1":"Navy Blue","option2":null,"option3":null,"sku":"MPB01185J5-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147194368099,"product_id":7956208648291,"position":5,"created_at":"2026-01-26T14:39:51+08:00","updated_at":"2026-01-26T14:39:53+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/4322cfe70d8b1131a3d01891757a8130976fc63c.webp?v=1769409593","variant_ids":[43966976884835]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703432876131,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/4322cfe70d8b1131a3d01891757a8130976fc63c.webp?v=1769409593"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43966982652003,"title":"Lavender","option1":"Lavender","option2":null,"option3":null,"sku":"MPB01185C1-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147194695779,"product_id":7956208648291,"position":6,"created_at":"2026-01-26T14:39:51+08:00","updated_at":"2026-01-26T14:39:53+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fedd64c7868cbf4345771acca2b7897cf1b9b938.webp?v=1769409593","variant_ids":[43966982652003]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703433203811,"position":6,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fedd64c7868cbf4345771acca2b7897cf1b9b938.webp?v=1769409593"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43966983077987,"title":"Black","option1":"Black","option2":null,"option3":null,"sku":"MPB0118524-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147193352291,"product_id":7956208648291,"position":2,"created_at":"2026-01-26T14:39:50+08:00","updated_at":"2026-01-26T14:39:52+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f401c50015c7fa7c82b02f257014bb261dc6b308.webp?v=1769409592","variant_ids":[43966983077987]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703431860323,"position":2,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/f401c50015c7fa7c82b02f257014bb261dc6b308.webp?v=1769409592"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43966984749155,"title":"Graphite","option1":"Graphite","option2":null,"option3":null,"sku":"MPB0118569-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147195285603,"product_id":7956208648291,"position":7,"created_at":"2026-01-26T14:39:52+08:00","updated_at":"2026-01-26T14:39:54+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa051c387ea3cf9f1b4b3e5bbf3b9396e2bf3cdf.webp?v=1769409594","variant_ids":[43966984749155]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703433793635,"position":7,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/fa051c387ea3cf9f1b4b3e5bbf3b9396e2bf3cdf.webp?v=1769409594"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}},{"id":43966986846307,"title":"White","option1":"White","option2":null,"option3":null,"sku":"MPB0118504-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147193057379,"product_id":7956208648291,"position":1,"created_at":"2026-01-26T14:39:49+08:00","updated_at":"2026-01-26T14:39:51+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/1897dbc954b34720849f06c73f43621e1e26faf4.webp?v=1769409591","variant_ids":[43966986846307]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703431565411,"position":1,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/1897dbc954b34720849f06c73f43621e1e26faf4.webp?v=1769409591"}},"requires_selling_plan":false,"selling_plan_allocations":[],"quantity_rule":{"min":1,"max":null,"increment":1}}];
$defaultVariant = {"id":43966976884835,"title":"Navy Blue","option1":"Navy Blue","option2":null,"option3":null,"sku":"MPB01185J5-EME11","requires_shipping":true,"taxable":true,"featured_image":{"id":35147194368099,"product_id":7956208648291,"position":5,"created_at":"2026-01-26T14:39:51+08:00","updated_at":"2026-01-26T14:39:53+08:00","alt":null,"width":2000,"height":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/4322cfe70d8b1131a3d01891757a8130976fc63c.webp?v=1769409593","variant_ids":[43966976884835]},"available":true,"name":"iPhone 12 \/ 12 Pro Mod NX (MagSafe 兼容) Emerald Studio 夏 - 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-EME11","featured_media":{"alt":null,"id":26703432876131,"position":5,"preview_image":{"aspect_ratio":1.0,"height":2000,"width":2000,"src":"\/\/b2b.rhinoshield.tw\/cdn\/shop\/files\/4322cfe70d8b1131a3d01891757a8130976fc63c.webp?v=1769409593"}},"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: "停產"
}