@@ -881,11 +891,16 @@
// Info is now { sku, title } or null
const sku = info ? info.sku : null;
- if (sku && sku !== state.sku) {
- state.setSku(info); // Pass whole object
- this.loadMedia();
- }
- })
+ if (sku && sku !== state.sku) {
+ state.setSku(info); // Pass whole object
+ this.loadMedia();
+ } else if (!sku && !state.sku) {
+ // If we don't have a SKU and haven't shown error yet
+ if (document.getElementById('error-ui').style.display !== 'flex') {
+ this.loadMedia();
+ }
+ }
+ })
.getSelectedProductInfo();
},
@@ -897,7 +912,18 @@
if (!sku) {
const domSku = document.getElementById('current-sku').innerText;
if (domSku && domSku !== '...') sku = domSku;
+ }
+ // CHECK FOR MISSING SKU
+ if (!sku || sku === '...') {
+ console.warn("No SKU found. Showing error.");
+ document.getElementById('loading-ui').style.display = 'none';
+ document.getElementById('main-ui').style.display = 'none';
+ document.getElementById('error-ui').style.display = 'flex';
+ return;
+ }
+
+ if (!title) {
const domTitle = document.getElementById('current-title').innerText;
if (domTitle && domTitle !== 'Loading...') title = domTitle;
}