Loyetta

Sepet

Alışveriş sepeti, kullanıcıların sipariş vermeden önce ürünleri toplamasına olanak tanır. Her kullanıcının ödeme veya manuel temizleme yapılana kadar kalıcı olan tek bir sepeti vardır.


Sepeti Getir

Mevcut kullanıcının tüm öğeleriyle birlikte alışveriş sepetini alın.

GET/v1/store/cart

Örnek İstek

bash
curl -X GET "https://marka.prod.loyetta.com/api/v1/store/cart" \
  -H "Authorization: Bearer {musteri-tokeni}" \
  -H "Accept: application/json"

Yanıt

json
{
  "success": true,
  "data": {
    "regular_total": 12050,
    "items": [
      {
        "quantity": 2,
        "product": {
          "id": "1a5c77ff",
          "title": "Kablosuz Kulaklık",
          "sku": "WH-001",
          "description": "<p>Premium kablosuz kulaklık.</p>",
          "regular_price": 5000,
          "sale_price": 4000,
          "thumbnail": "https://example.com/kulaklik.jpg",
          "gallery": []
        }
      },
      {
        "quantity": 1,
        "product": {
          "id": "2b6d88aa",
          "title": "Telefon Kılıfı",
          "sku": "PC-001",
          "description": "<p>Koruyucu telefon kılıfı.</p>",
          "regular_price": 2050,
          "sale_price": null,
          "thumbnail": "https://example.com/kilif.jpg",
          "gallery": []
        }
      }
    ]
  }
}

Sepet Nesnesi

AlanTürAçıklama
regular_totalintegerTüm öğelerin toplam fiyatı (puan cinsinden, indirimler öncesi)
itemsarraySepet öğeleri dizisi
items[].quantityintegerBu ürünün sepetteki miktarı
items[].productobjectÜrün detayları (Ürün Nesnesi'ne bakın)

Sepete Ekle

Alışveriş sepetine bir ürün ekleyin. Ürün zaten sepette varsa, miktarı artırılır.

POST/v1/store/cart/add

İstek Gövdesi

ParametreTürZorunluAçıklama
product_idstringEvetEklenecek ürünün ID'si
quantityintegerHayırEklenecek miktar (varsayılan: 1, minimum: 1)

Örnek İstek

bash
curl -X POST "https://marka.prod.loyetta.com/api/v1/store/cart/add" \
  -H "Authorization: Bearer {musteri-tokeni}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "product_id": "1a5c77ff",
    "quantity": 2
  }'

Yanıt

Güncellenmiş sepet nesnesini döndürür.

json
{
  "success": true,
  "data": {
    "regular_total": 10000,
    "items": [
      {
        "quantity": 2,
        "product": {
          "id": "1a5c77ff",
          "title": "Kablosuz Kulaklık",
          "sku": "WH-001",
          "regular_price": 5000,
          "sale_price": 4000,
          "thumbnail": "https://example.com/kulaklik.jpg",
          "gallery": []
        }
      }
    ]
  }
}

Hata Yanıtı (422)

json
{
  "success": false,
  "message": "The product ID is required.",
  "errors": {
    "product_id": ["The selected product does not exist or is not available."]
  }
}

Sepetten Kaldır

Bir ürünü alışveriş sepetinden tamamen kaldırın.

POST/v1/store/cart/remove

İstek Gövdesi

ParametreTürZorunluAçıklama
product_idstringEvetKaldırılacak ürünün ID'si

Örnek İstek

bash
curl -X POST "https://marka.prod.loyetta.com/api/v1/store/cart/remove" \
  -H "Authorization: Bearer {musteri-tokeni}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "product_id": "1a5c77ff"
  }'

Yanıt

Güncellenmiş sepet nesnesini döndürür.

json
{
  "success": true,
  "data": {
    "regular_total": 0,
    "items": []
  }
}

Miktarı Artır

Sepetteki bir ürünün miktarını 1 artırın. Ürün sepette yoksa, 1 miktarıyla eklenir.

POST/v1/store/cart/increase

İstek Gövdesi

ParametreTürZorunluAçıklama
product_idintegerEvetMiktarı artırılacak ürünün ID'si

Örnek İstek

bash
curl -X POST "https://marka.prod.loyetta.com/api/v1/store/cart/increase" \
  -H "Authorization: Bearer {musteri-tokeni}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "product_id": 1
  }'

Yanıt

Güncellenmiş sepet nesnesini döndürür.


Miktarı Azalt

Sepetteki bir ürünün miktarını 1 azaltın. Miktar 0'a ulaşırsa, öğe otomatik olarak sepetten kaldırılır.

POST/v1/store/cart/decrease

İstek Gövdesi

ParametreTürZorunluAçıklama
product_idintegerEvetMiktarı azaltılacak ürünün ID'si

Örnek İstek

bash
curl -X POST "https://marka.prod.loyetta.com/api/v1/store/cart/decrease" \
  -H "Authorization: Bearer {musteri-tokeni}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "product_id": 1
  }'

Yanıt

Güncellenmiş sepet nesnesini döndürür.

Tüm sepet işlemleri güncellenmiş sepet nesnesini döndürür, bu da herhangi bir değişiklikten sonra arayüzünüzü yenilemenizi kolaylaştırır.