Gaia and its docs are under construction. It's releasing soon!

Wishlists

Introduction

Gaia's wishlist feature allows customers to easily add and remove products. By enabling wishlist collections, customers can create and manage collections, helping them organize their saved products more effectively.

Enabling multiple collections

Out of the box, Gaia ships with the single wishlist enabled. You can turn on wishlist collections instead by going to config/gaia.php and changing the mode to multiple

'wishlists' => [
-   'mode' => 'single',
+   'mode' => 'multiple',
]

Max wishlists

By default, customers can have up to 5 collections. You can increase this within config/gaia.php too.

'wishlists' => [
    'max_collections' => 5,

    ...
]

Reducing the number of collections after going live will result in customers wishlists being removed from the frontend.

Using the Wishlist API

All cart management routes are protected by the Illuminate\Auth\Middleware\Authenticate middleware, which ensures a user is logged in.

Get User Wishlists

Retrieves the current wishlists for the authenticated user.

GET /!/gaia/account/wishlists
fetch('/!/gaia/account/wishlists');

Create a New Wishlist

Creates a new wishlist.

POST /!/gaia/account/wishlist/create
fetch('/!/gaia/account/wishlist/create', {
    method: 'POST',
    body: JSON.stringify({
        name: 'My New Wishlist',
        product_id: '12345'
    }),
});

Parameters

  • name: (string) The name of the wishlist.
  • product_id: (string) The ID of the product to add.

Update Wishlist

Updates a wishlist to add a product.

POST /!/gaia/account/wishlist/update/
fetch('/!/gaia/account/wishlist/update/', {
    method: 'POST',
    body: JSON.stringify({
        product_id: '12345',
        wishlist_ids: [1, 2, 3],
    }),
});

Parameters

  • product_id: (string) The ID of the product to add.
  • wishlist_ids: (array) The IDs of the wishlists to update.

Manage Wishlist Items

Manages wishlist items, adding or removing products based on the wishlist IDs.

POST /!/gaia/account/wishlist/manage/
fetch('/!/gaia/account/wishlist/manage/', {
    method: 'POST',
    body: JSON.stringify({
        product_id: '12345',
        wishlist_ids: [1, 2, 3],
    }),
});

Parameters

  • product_id: (string) The ID of the product to manage.
  • wishlist_ids: (array) The IDs of the wishlists to update.

Remove Item from Wishlist

Removes an item from the wishlists.

DELETE /!/gaia/account/wishlist/removeItem/
fetch('/!/gaia/account/wishlist/removeItem/', {
    method: 'DELETE',
    body: JSON.stringify({
        product_id: '12345',
        wishlist_ids: [1, 2, 3],
    }),
});

Parameters

  • product_id: (string) The ID of the product to remove.
  • wishlist_ids: (array) The IDs of the wishlists to update.

Rename Wishlist

Renames a wishlist based on the ID passed as a URL Parameter.

PATCH /!/gaia/account/wishlist/rename/{id}
fetch('/!/gaia/account/wishlist/rename/1', {
    method: 'PATCH',
    body: JSON.stringify({
        name: 'Updated Wishlist Name',
    }),
});

Parameters

  • name: (string) The new name of the wishlist.
  • id: (string) The ID of the wishlist to rename.

Delete Wishlist

Deletes a wishlist.

DELETE /!/gaia/account/wishlist/destroy/{id}
fetch('/!/gaia/account/wishlist/destroy/1', {
    method: 'DELETE',
});

Parameters

  • id: (string) The ID of the wishlist to delete.

Error handling

The API uses standard HTTP status codes for error responses:

  • 404: Wishlist not found.
  • 500: Server error.

Error responses will include a JSON object with an error key containing a descriptive message.

Limitations

  • The API operates within the limitations of the backend system's configurations.
  • Some operations may require additional authentication or permissions.