Przejdź do głównej treści

Przegląd

Uzyskaj dostęp do publicznych informacji swojego sklepu, w tym nazwy, opisu, logo, banera i ustawień waluty.

Pobierz szczegóły sklepu

Pobierz kompletne informacje o swoim sklepie.
const response = await komerza.getStore();

Zwraca

Zwraca ApiResponse<Store>:
interface Store {
  id: string; // Identyfikator sklepu
  name: string; // Nazwa sklepu
  description: string; // Opis sklepu (obsługuje markdown)
  url: string; // Subdomena sklepu
  customDomain?: string; // Niestandardowa domena jeśli ustawiona
  currencyCode: string; // Kod waluty ISO 4217 (np. "USD")
  domain: string; // Pełna domena
  rating: number; // Średnia ocena sklepu
  maintenanceReason?: string; // Jeśli sklep jest w trybie konserwacji
  branding?: {
    iconFileName?: string; // Nazwa pliku logo
    bannerFileName?: string; // Nazwa pliku banera
    accentColor?: string; // Kolor akcentu sklepu
    isAutomaticCurrencyConversionEnabled?: boolean;
  };
  products: ProductReference[]; // Lista produktów
  categories: Category[]; // Lista kategorii
  affiliateOptions?: {
    isEnabled: boolean;
    defaultReturnPercentage: number;
    defaultPercentageOff: number;
    canConvertAffiliateBalance: boolean;
    isPublicRegistrationEnabled: boolean;
    isLinkEditingEnabled: boolean;
  };
  dateCreated: string; // Znacznik czasu ISO 8601
}

interface Category {
  id: string;
  name: string;
  slug: string;
  visibility: number;
  order: number;
  storeId: string;
  productCount: number;
  products: string[]; // Lista ID produktów
  dateCreated: string;
}

Przykład

// Wyświetl informacje o sklepie
async function wyswietlInfoSklepu() {
  const response = await komerza.getStore();

  if (response.success) {
    const store = response.data;

    document.getElementById("store-name").textContent = store.name;
    document.getElementById("store-description").textContent =
      store.description;
    document.getElementById("product-count").textContent =
      `${store.products.length} produktów`;

    console.log(`Sklep używa waluty ${store.currencyCode}`);
  }
}

Pobierz logo sklepu

Uzyskaj URL do obrazu logo Twojego sklepu.
const logoUrl = await komerza.getStoreLogoUrl();

Zwraca

Zwraca ciąg zawierający pełny URL do obrazu logo.

Przykład

// Wyświetl logo sklepu
async function wyswietlLogo() {
  const logoUrl = await komerza.getStoreLogoUrl();

  const img = document.createElement("img");
  img.src = logoUrl;
  img.alt = "Logo sklepu";
  document.getElementById("logo-container").appendChild(img);
}

Pobierz baner sklepu

Uzyskaj URL do obrazu banera Twojego sklepu.
const bannerUrl = await komerza.getStoreBannerUrl();