Skip to content
ms3ProductSets
ms3ProductSets
Dynamic product recommendations for MiniShop3. Manual links, auto rules, manager templates
  • MODX 3
  • PHP 8.1
  • miniShop3
  1. Extras
  2. ms3ProductSets
  3. For developers
  4. Flows and scenarios

Flows ​

Manager walkthroughs: manager scenarios.

Flow diagrams ​

Server-side snippet output:

AJAX render from the storefront:

1. Render a set block on the frontend ​

  1. Template calls the snippet: MODX [[!ms3ProductSets? ... ]], Fenom {'ms3ProductSets' | snippet : [ ... ]}.
  2. Snippet validates and normalizes parameters (type, max_items, resource_id, category_id, …).
  3. Product IDs come from msps_get_products_by_type.
  4. If the result is empty: returns '' or emptyTpl.
  5. If IDs exist:
    • with return=ids returns CSV of IDs
    • else calls msProducts and renders cards
  6. With tplWrapper, wraps the final HTML.
  7. With toPlaceholder, stores output in a placeholder.

2. AJAX render via JS API ​

  1. window.ms3ProductSets.render('#selector', options).
  2. JS POSTs action=get_set to connector.php.
  3. Connector runs snippet ms3ProductSets with POST params.
  4. HTML is injected into the container. An empty response hides the container.

3. Add to cart from a set card ​

  1. Stock chunk tplSetItem uses a MiniShop3 form (ms3_form), not data-add-to-cart.
  2. productsets.js first POSTs MiniShop3 Web API (ms3Config.actionUrl, route /api/v1/cart/add) when that URL exists.
  3. Fallback: connector action=add_to_cart → $ms3->cart->add(). There is no msCartAdd call.
  4. Connector JSON: {success, added, message}.
  5. On MiniShop3 API success JS also fires ms3:cart:updated. Toast + msps:cart:update.

4. Create a set template (manager) ​

  1. UI sends save_template.
  2. Connector validates name and related_product_ids.
  3. msps_save_template INSERT/UPDATE in ms3_product_set_templates.
  4. UI refreshes the template list.

5. Apply template to a category ​

  1. UI sends apply_template (template_id, parent_id/parent_ids, replace).
  2. Category expands recursively to all msProduct resources.
  3. For each product, links are created in ms3_product_sets.
  4. UI receives applied (number of inserted links).

6. Unbind template from a category ​

  1. UI sends unbind_template.
  2. Connector resolves template type and name.
  3. Deletes only rows matching type + template_name.
  4. TV links and other templates are untouched.

7. Add entire set to cart ​

  1. Click a button with data-add-set (in tplSetVIP or tplSetWrapper).
  2. JS finds the container from the button (.msps__vip-set, .msps__wrapper or [data-set-type]).
  3. Collects IDs from data-msps-product-ids, then cards, then input[name="id"].
  4. Calls addToCart(productId, 1) for each ID in order.
  5. Shows toast set_added and dispatches msps:cart:update with product_ids.

8. TV sync when saving a product ​

  1. Plugin OnDocFormSave runs.
  2. If the product template has set TVs, sync runs.
  3. Empty TV: only rows without template_name (from TV) are removed. Template-based links keep template_name.
  4. Non-empty TV: only rows with empty template_name (TV rows) are rewritten. Template links stay.