Skip to content
ms3Favorites
ms3Favorites
Wishlists for MiniShop3 and other resources — browser storage, DB sync
  1. Extras
  2. ms3Favorites
  3. Frontend setup

Frontend setup

Details on loading lexicon, styles and scripts are in Quick start. Below: connector, customization and chunks.

Integration check

For guests with no DB data, data comes from localStorage/cookie. For logged-in users and guests (when guest_db_enabled) — from DB by user_id or session_id.

Checklist: lexicon and favorites.js are loaded on every product page; button has data-favorites-toggle and data-id; ms3favorites.guest_db_enabled = Yes; for logged-in users — user is authenticated in web context.

Connector (AJAX)

URL: assets/components/ms3favorites/connector.php

Method: POST.

Actions:

  • Output favorites list — params ids (required), optional limit, tpl, emptyTpl, list, resource_type
  • sync — sync lists to DB (JSON). POST lists (JSON) or ids
  • create_share — create public link (JSON). POST list. Logged-in only
  • get_share — get data by token (JSON). POST token
  • copy_share — copy another user's list to yours (JSON). POST token, target_list
  • update_comment — update item note (JSON). POST product_id, list, comment. When comments_enabled
  • add_to_cart — add items to cart (JSON). POST ids or product_id
  • get_popularity — id→count map (JSON). POST ids, resource_type
  • clear — clear list (JSON). POST list, resource_type

Response: HTML for list; when no items — emptyTpl. For actions — JSON. If window.MODX_ASSETS_URL or window.MODX_BASE_URL is set, JS builds the connector URL.

Chunks

ChunkPurpose
tplFavoritesItemProduct card in Favorites list
tplFavoritesEmptyEmpty state (no items)
tplFavoritesPage/wishlist/ page (wrapper with tabs, cart buttons)
tplFavoritesPageItemItem on /wishlist/ (checkbox, note, remove button)
tplFavoritesPageDemoDemo: tabs + Catalog/Clear/Share buttons, ?list=
tplFavoritesListSelectorList selector dropdown (default, gifts, plans)
tplFavoritesSharePageShare page (wrapper)
tplMs3fBtnAdd/remove from favorites button (snippet ms3FavoritesBtn)
tplMs3fBtnWishlistBoxButton template: li.wishlist, box-icon, icon-heart, tooltip
tplMs3fCounterFavorites counter (snippet ms3FavoritesCounter)
tplMs3fListsRowFavorites list row (snippet ms3FavoritesLists)
tplMs3fListsWrapperWrapper for list of lists ([[+output]])
tplMs3fLexiconScriptFenom lexicon chunk (used by snippet ms3fLexiconScript)

data attributes (/wishlist/ page)

AttributeElementPurpose
data-favorites-add-allbuttonAdd all items in current list to cart
data-favorites-add-selectedbuttonAdd selected (by checkbox) to cart
data-favorites-cart-checkboxinput[checkbox]Item selection for “Add selected”
data-favorites-select-allinput[checkbox]Select/deselect all checkboxes
data-favorites-clearbuttonClear current list
data-favorites-list-selectorselectList selector dropdown (chunk tplFavoritesListSelector)
data-favorites-commenttextareaItem note (when comments_enabled)
data-favorites-togglebuttonAdd/remove button (attribute data-id)
data-favorites-countspanItem count
data-favorites-sharebutton“Share list” button (attribute data-list)
data-favorites-page-containerdivWishlist page container
data-favorites-mode="list"divRemove card on “Remove” click

Chunks can be overridden (Fenom or MODX); tpl and emptyTpl are set in the snippet and in JS render().

Styles and BEM

Classes use ms3f prefix (BEM): ms3f__list, ms3f__item, etc. Styles: assets/components/ms3favorites/css/favorites.css. Default cards use Bootstrap (ms3-product-card, product-image-wrapper); include Bootstrap and catalog styles if needed.

On mobile — horizontal scroll for the list (.ms3f__list).

CSS variables

Override in your theme (:root or block container):

VariableDescription
--ms3f-bgCard background
--ms3f-borderBorder
--ms3f-radiusBorder radius
--ms3f-colorText color
--ms3f-price-colorPrice color
--ms3f-button-activeActive button color (item in list)
--toast-bgToast background
--toast-colorToast text
--toast-radiusToast radius

Example:

css
:root {
  --ms3f-bg: #fff;
  --ms3f-border: #eee;
  --ms3f-radius: 0.5rem;
  --ms3f-color: #333;
  --ms3f-price-color: #e74c3c;
  --ms3f-button-active: #e74c3c;
}

JavaScript API

javascript
window.ms3Favorites = {
  getList(name),        // Get list IDs
  getAllLists(),        // All lists {default:[], gifts:[]}
  add(id, list),        // Add item to list
  remove(id, list),     // Remove from list
  switchList(name),     // Switch active list
  render(selector, options),  // options: list, tpl, emptyTpl, limit
  updateCounter(), updateButtonStates(),
  sync(),               // Sync (POST lists)
  createShare(list),    // Create share link → token (logged-in only)
  copyFromShare(token), // Copy another user's list (target_list optional)
  addToCart(ids),       // Add items to MiniShop3 cart
  addSelectedToCart(),  // Add selected (checkbox)
  updateComment(productId, list, comment),  // Save note (up to 500 chars)
  clear(list)           // Clear list (action=clear)
};

mxQuickView and mFilter integration

mxQuickView: ms3Favorites subscribes to mxqv:loaded and mxqv:open. After content loads in the modal, updateButtonStates() runs — favorites buttons work without extra setup.

mFilter: When a results container exists ([data-mfilter-results], .mfilter-results or [data-mfilter-id]), ms3Favorites uses MutationObserver and calls updateButtonStates() on DOM updates. For a custom selector set window.ms3fConfig.mfilterContainer before loading favorites.js.