Skip to content
ms3ProductSets
ms3ProductSets
Dynamic product recommendations for MiniShop3 — manual links, auto rules, manager templates
  1. Extras
  2. ms3ProductSets
  3. For developers

API and interfaces

Snippet ms3ProductSets

Key parameters

ParameterDefaultDescription
typebuy_togetherSet type
resource_id / productIdcurrent resourceBase product ID
max_itemsms3productsets.max_itemsLimit (1..100)
category_id0Category for auto pick
set_id0VIP set number (for type=vip). 0 or omitted uses 1 — setting ms3productsets.vip_set_1.
tpltplSetItemCard chunk
emptyTpltplSetEmptyEmpty result chunk
hideIfEmptytruetrue -> empty string, false -> emptyTpl
exclude_ids''Excluded IDs
tplWrapper''Wrapper with placeholders output, type, count
sortby / sortdir'' / ASCIf sortby is empty, set order is preserved
showUnpublishedfalsePassed to msProducts
showHiddenfalsePassed to msProducts
includeTVs, includeThumbs, tvPrefix''Passed to msProducts
returndatadata, ids, json
toPlaceholder''Write output to placeholder

Supported type values

auto, vip, cross-sell, popcorn, also-bought, buy_together, similar, cart_suggestion, auto_sales, custom.

Per-type logic: Set types.

Call examples

fenom
{'ms3ProductSets' | snippet : [
  'type' => 'similar',
  'resource_id' => $_modx->resource.id,
  'max_items' => 6,
  'tpl' => 'tplSetItem'
]}
modx
[[!ms3ProductSets?
  &type=`similar`
  &resource_id=`[[*id]]`
  &max_items=`6`
  &tpl=`tplSetItem`
]]

Snippet mspsLexiconScript

Outputs:

  • window.mspsLexicon (keys for frontend messages);
  • window.mspsConfig (maxItems, lang).

Load before productsets.js.

Fenom: {'mspsLexiconScript' | snippet}MODX: [[!mspsLexiconScript]]

Connector assets/components/ms3productsets/connector.php

Front (web)

actionMethodParametersResponse
get_setPOSTtype, resource_id, category_id, set_id, max_items, tpl, emptyTpl, hideIfEmptyHTML
add_to_cartPOSTproduct_id, countJSON {success,message}

Manager (mgr, auth required)

actionPurposeMain parameters
get_templatesList set templates
save_templateCreate/update templateid, name, type, related_product_ids, sortorder
delete_templateDelete templateid
apply_templateApply template to categories/productstemplate_id, parent_id or parent_ids[], replace
unbind_templateUnbind template from categorytemplate_id, parent_id or parent_ids[]
get_resource_treeCategory tree (no products)parent_id, context_key
get_resourcesProduct list for pickerparent_id, template_id, query, limit

JS API (window.ms3ProductSets)

MethodPurpose
render(selector, options)Render set block via action=get_set
addToCart(productId, count)Add product via action=add_to_cart
addAllToCart(buttonOrContainer)Add whole set. DOM element (button with data-add-set or container) or CSS selector. Finds [data-product-id] and [data-add-to-cart], calls addToCart for each, then toast and msps:cart:update.
toast(message)Show frontend toast

Events after successful add:

  • addToCart: msps:cart:update with detail: { product_id, count }
  • addAllToCart: msps:cart:update with detail: { product_ids }

Plugins

PluginEventPurpose
ms3productsets_sync_tvOnDocFormSaveSync set TVs into ms3_product_sets
ms3productsets_on_resource_deleteOnResourceDeleteClean links for deleted resource