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.
/v1/store/cartÖrnek İstek
curl -X GET "https://marka.prod.loyetta.com/api/v1/store/cart" \
-H "Authorization: Bearer {musteri-tokeni}" \
-H "Accept: application/json"Yanıt
{
"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
| Alan | Tür | Açıklama |
|---|---|---|
regular_total | integer | Tüm öğelerin toplam fiyatı (puan cinsinden, indirimler öncesi) |
items | array | Sepet öğeleri dizisi |
items[].quantity | integer | Bu ürünün sepetteki miktarı |
items[].product | object | Ü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.
/v1/store/cart/addİstek Gövdesi
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
product_id | string | Evet | Eklenecek ürünün ID'si |
quantity | integer | Hayır | Eklenecek miktar (varsayılan: 1, minimum: 1) |
Örnek İstek
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.
{
"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)
{
"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.
/v1/store/cart/removeİstek Gövdesi
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
product_id | string | Evet | Kaldırılacak ürünün ID'si |
Örnek İstek
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.
{
"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.
/v1/store/cart/increaseİstek Gövdesi
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
product_id | integer | Evet | Miktarı artırılacak ürünün ID'si |
Örnek İstek
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.
/v1/store/cart/decreaseİstek Gövdesi
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
product_id | integer | Evet | Miktarı azaltılacak ürünün ID'si |
Örnek İstek
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.