<!DOCTYPE html>
<html>
<head>
<title>Store</title>
<script src="https://cdn.komerza.com/komerza.min.js"></script>
<style>
.header {
text-align: center;
padding: 20px;
}
.logo {
max-width: 200px;
height: auto;
}
.banner {
width: 100%;
height: 300px;
background-size: cover;
background-position: center;
}
.store-info {
margin: 20px 0;
}
</style>
</head>
<body>
<div class="header">
<img id="logo" class="logo" alt="Store Logo" />
<h1 id="store-name"></h1>
<p id="store-description"></p>
<p id="store-stats"></p>
</div>
<div id="banner" class="banner"></div>
<div id="products"></div>
<script>
// Initialize
komerza.init("your-store-id");
// Load store information
async function loadStore() {
try {
// Get all store data in parallel
const [storeResponse, logoUrl, bannerUrl, formatter] =
await Promise.all([
komerza.getStore(),
komerza.getStoreLogoUrl(),
komerza.getStoreBannerUrl(),
komerza.createFormatter(),
]);
if (!storeResponse.success) {
console.error("Failed to load store:", storeResponse.message);
return;
}
const store = storeResponse.data;
// Display branding
document.getElementById("logo").src = logoUrl;
document.getElementById(
"banner"
).style.backgroundImage = `url('${bannerUrl}')`;
// Display store info
document.getElementById("store-name").textContent = store.name;
document.getElementById("store-description").textContent =
store.description;
document.getElementById(
"store-stats"
).textContent = `${store.products.length} products • ${store.rating}★ rating`;
// Display products with formatted prices
const productsHtml = store.products
.map((product) => {
const minPrice = Math.min(...product.variants.map((v) => v.cost));
const priceFormatted = formatter.format(minPrice);
return `
<div class="product">
<h3>${product.name}</h3>
<p>${product.description}</p>
<p class="price">From ${priceFormatted}</p>
</div>
`;
})
.join("");
document.getElementById("products").innerHTML = productsHtml;
} catch (error) {
console.error("Error loading store:", error);
}
}
// Load on page load
loadStore();
</script>
</body>
</html>