Favourite Products
Favourite Products provides users with a convenient and efficient method to bookmark and save their preferred items for future purchases. This feature enables users to create a personalized collection of products they are interested in, allowing for easy access.
All favourite product API methods require “Authentication” for security. The token is included in the HTTP request header under the Authorization
field, as demonstrated in the provided request examples.
POST
Add a Favourite Product
This method adds a product to the user's list of favourite products. Before adding a product, it checks whether it is already in the list by looking up the user and product ID or the product base code. If the FAVOURITE_SKU_IS_ACTIVE
dynamic setting is true, it checks using the product ID; otherwise, it uses the product base code. If the product is already in the list, it throws a 406 error. If not, it adds the product to the list. If multiple entries are found, it returns the first one found.
Path: /wishlists/favourite-products/
Request Body
{
“product”: {product_id}
}
Example Request
curl --location --request GET ‘{host}/wishlists/favourite-products/‘ \
--header 'Authorization: Token {token}’ \
--header 'Content-Type: application/json' \
--data ‘{"product":"8"}'
Example Response (200 OK)
{
"pk": 4,
"product": 9
}
Example Response (406 Not Acceptable)
If a product is already in the favourite products list, the server will throw an error.
{
"non_field_errors": "Ürün zaten favori listenizde mevcut.",
"error_code": "favourite_product_100"
}
DELETE
Remove a Favourite Product
This method is used to remove a product from the user's list of favourite products.
Path: /wishlists/favourite-products/{product_id}/
Example Request
curl --location --request DELETE '{host}/wishlists/favourite-products/1/' \
--header 'Authorization: Token {token}'
Response (204 No Content)
There is no content to send in the response payload body.
GET
List Favourite Products
This method is used to fetch the list of a user's favourite products. It can be filtered by product_id
, base_code__in
, and product_name
. Both product_id
and base_code__in
can accept either a list or a single parameter. If the FAVOURITE_SKU_IS_ACTIVE
dynamic setting is true, favourite products are ordered by product_id
; otherwise, they are ordered by product__base_code
. Additionally, products are fetched along with their basket offers.
Path: /wishlists/favourite-products/
Example Request
curl --location '{host}/wishlists/favourite-products/?product_id=500&base_code__in=1KCICK0860&product__name=test' \
--header 'Authorization: Token {token}'
Example Response (200 OK)
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"pk": 2,
"product": {
"pk": 9,
"name": "Leonce 160x220+60x80+160x240cm Tek Kişilik Saten Nevresim Takımı",
"sku": "1KNTTC0134",
"base_code": "1KNTTC0134",
"attributes": {
"renk": "sarı",
"min_miktar": 3,
"filtre_renk2": "Ekru"
},
"attribute_set": 8,
"attributes_kwargs": {
"filtre_renk2": {
"value": "Kırmızı",
"label": "Kırmızı"
},
"filtre_renk1": {
"value": "Gri",
"label": "Gri"
}
},
"extra_attributes": {},
"productimage_set": [],
"price": "129.90",
"in_stock": false,
"currency_type": "try",
"retail_price": "324.75",
"unit_type": null,
"tax_rate": "8.00",
"absolute_url": "/product/9/",
"productvideo_set": [],
"product_type": "1",
"price_type": "default",
"form_schema": null,
"is_ready_to_basket": false,
"stock": null,
"data_source": null,
"basket_offers": [],
"extra_data": {}
}
},
{
"pk": 1,
"product": {
"pk": 8,
"name": "Phaeton 160x220+60x80+160x240cm Tek Kişilik Saten Nevresim Takımı",
"sku": "2672881091842",
"base_code": "1KNTTC0137",
"attributes": {
"renk": "sarı",
"filtre_renk2": "Ekru",
"filtre_renk1": "Mürdüm",
"urun_artis_degeri": 2
},
"attribute_set": 8,
"attributes_kwargs": {
"renk": {
"value": "KOYU MÜRDÜM",
"label": "KOYU MÜRDÜM"
},
"filtre_renk1": {
"value": "Mürdüm",
"label": "Mürdüm"
}
},
"extra_attributes": {},
"productimage_set": [
{
"pk": 469,
"status": "active",
"image": "/media/products/2017/01/23/6432/2c73e077-8b83-429c-bab9-2909b33b983b.jpg",
"order": 0,
"created_date": "2017-01-24T10:37:40.173696Z",
"specialimage_set": []
},
{
"pk": 3393,
"status": "active",
"image": "/media/products/2017/01/23/6432/7d523b5b-8d33-4467-a526-da912871fc91.jpg",
"order": 1,
"created_date": "2017-01-24T10:40:43.133208Z",
"specialimage_set": []
}
],
"price": "129.90",
"in_stock": true,
"currency_type": "try",
"retail_price": "324.75",
"unit_type": "qty",
"tax_rate": "8.00",
"absolute_url": "/ev-tekstili-tek-kisilik-nevresim-takimlari-saten-nevresim-takimlari/phaeton-160x220-60x80-160x240cm-tek-kisilik-saten-nevresim-takimi-2672881091842/",
"productvideo_set": [],
"product_type": "0",
"price_type": "default",
"form_schema": null,
"is_ready_to_basket": false,
"stock": 8,
"data_source": {
"pk": 1,
"name": "bayram ticaret",
"slug": "bayram-ticaret",
"title": "Bayram Ticaret",
"supplier_code": "BAY",
"address": null,
"email": null,
"phone_number": null,
"fax_number": null,
"kep_address": null,
"mersis_number": null,
"trade_association": null,
"extras": {},
"price_list": 1,
"stock_list": 2,
"is_active": true
},
"basket_offers": [],
"extra_data": {
"variants": []
}
}
}
]
}