Documentation · Frontend Guide

Favorites

This document covers the favorites (wishlist) feature of the ADP Car Market Hub WordPress Plugin: how visitors save vehicles, how the favorites page works, what data is shown, and what limitations apply.

When to use this document

Read this document if you are setting up the favorites feature for the first time, configuring which vehicle details appear on the favorites page, or helping a visitor understand how to save and revisit vehicles.

Overview

The favorites feature allows visitors to save vehicles they are interested in and view them later on a dedicated favorites page. Saved vehicle IDs are stored in the browser's localStorage. No account or login is required.

When a visitor opens the favorites page, the plugin retrieves the current vehicle data for all saved IDs from a REST API endpoint and renders the list dynamically. This means the favorites page always reflects the current state of the vehicle listing, including any price changes or vehicles that have been removed since they were saved.

Requirements or prerequisites

  • The favorites feature must be enabled in the plugin settings (it is enabled by default).
  • A favorites page must exist in WordPress with the [as24ci_favorites] shortcode in its content.
  • The WordPress REST API must be publicly accessible for the favorites page to load vehicle data.

Step-by-step instructions

Set up the favorites page

  1. In the WordPress admin, go to Pages → Add New.
  2. Give the page a title such as "My Favorites" or "Saved Vehicles".
  3. In the page content, add the shortcode [as24ci_favorites].
  4. Publish the page.

The favorites page renders a container that is populated by JavaScript on page load. No additional configuration of the shortcode is required.

Save a vehicle as a visitor

  1. On the vehicle archive, locate a vehicle card. A favorites button (heart icon) appears on the card when the favorites feature and the favorite_btn element are both enabled.
  2. Click the heart button to add the vehicle to your favorites. The button changes state to indicate the vehicle is saved.
  3. Click the button again to remove the vehicle from your favorites.

The same favorites button is available on individual vehicle detail pages in the sticky floating action bar.

View saved favorites

  1. Navigate to the favorites page.
  2. The page loads and calls the plugin's REST endpoint to retrieve current data for all saved vehicle IDs.
  3. Each saved vehicle is displayed as a card with its image, title, price, and configured specification fields.
  4. Click "More details" on a card to open the vehicle's full detail page.

If no vehicles are saved, the page displays "You have no saved favorites yet."

Configuration reference

Favorites settings

SettingLocationDescription
Enable favoritesPlugin settings → Settings (or Setup Wizard)Enables or disables the entire favorites feature
Favorites fieldsLayout Manager → FavoritesWhich vehicle fields are shown on each favorites card

Favorites page fields

Which vehicle fields are shown on each favorites card is controlled by the Layout Manager → Favorites zone. The following fields are supported and can be individually enabled or disabled:

Field IDDescription
priceSelling price (formatted with currency)
mileageMileage in km
firstRegistrationYearRegistration year
fuelTypeFuel type
transmissionTypeTransmission
bodyTypeBody type
conditionTypeCondition (new or used)
horsePowerPower in HP
bodyColorTextExterior color
doorsNumber of doors
seatsNumber of seats
driveTypeDrive type
co2EmissionCO₂ emissions in g/km
consumptionCombinedCombined fuel consumption in l/100 km
energyLabelEnergy label
firstRegistrationDateFirst registration date (formatted)
warrantyTypeWarranty type

Fields with no value for a vehicle, or numeric fields with a value of zero, are omitted from that vehicle's card. The order of fields follows the zone configuration.

Archive card favorites button

The favorites button appears on vehicle archive cards when:

  • The favorites feature is enabled in the plugin settings (FEATURE_FAVORITES).
  • The favorite_btn element is enabled in the Layout Manager → Archive Cards zone.

The button displays a heart icon and toggles the saved state when clicked.

Operational notes

  • Vehicle IDs are stored in browser localStorage. Favorites persist across page navigation and survive page reloads within the same browser. Clearing browser data (cookies and local storage) removes all saved favorites.
  • Favorites are not shared across devices or browsers. There is no server-side account storage for favorites.
  • The favorites page fetches vehicle data from the REST endpoint POST /wp-json/as24ci/v1/favorites on each page load. The request body contains an array of post IDs.
  • The REST endpoint enforces a maximum of 50 vehicles per request. If more than 50 vehicles are stored in localStorage, only the first 50 are retrieved.
  • Only published vehicles of the correct post type are returned by the REST endpoint. Vehicles that have been unpublished or deleted since they were saved are silently excluded from the response.
  • The registration year is resolved using a priority chain: first from the mapped meta key for firstRegistrationYear, then from the legacy _as24ci_year meta key, and finally from the Vehicle Field Resolver which checks the custom table and raw data columns.
  • Dates (first registration date) are formatted using the WordPress site date format setting.
  • Numeric fields such as power and fuel consumption are omitted if their value is zero or empty, so that the card does not show "0 HP" or "0.0 l/100 km".
  • The favorites JavaScript asset is enqueued on vehicle archive pages, single vehicle pages, and pages containing the [as24ci_favorites] or [as24ci_archive] shortcode.
  • The favorites CSS and any configured design inline styles are enqueued alongside the JavaScript.

Troubleshooting

The favorites button does not appear on vehicle cards.

  • Verify the favorites feature is enabled in the plugin settings.
  • Check the Layout Manager → Archive Cards zone and confirm favorite_btn is enabled.

The favorites page shows "Loading favorites…" and does not update.

  • Check that the WordPress REST API is accessible. Many security plugins or server configurations block REST API access to non-logged-in users.
  • Open the browser's developer console and check for JavaScript errors or failed network requests.
  • Confirm the page contains the [as24ci_favorites] shortcode.

The favorites page shows "Could not load favorites."

  • The REST request to /wp-json/as24ci/v1/favorites failed or returned an error. Check that the REST API is functioning correctly.
  • Verify the site's permalink settings allow REST API URLs to be resolved.

Saved vehicles disappear after a browser restart.

  • localStorage persists across browser restarts in all modern browsers. If favorites are disappearing, the browser may be configured to clear storage on close, or a privacy mode (incognito/private window) may be in use.

A vehicle that was saved is no longer shown on the favorites page.

  • The vehicle may have been unpublished or deleted from the WordPress admin after it was saved. The REST endpoint only returns published vehicles.

The favorites page shows only a subset of saved vehicles.

  • The REST endpoint returns a maximum of 50 vehicles. If more than 50 vehicles are saved in localStorage, only the first 50 are retrieved.