
- MODX 3
- PHP 8.1
- miniShop3


The component hooks into cart cost calculation via this MiniShop3 event.
| Property | Value |
|---|---|
| Event | msOnGetCartCost |
| Purpose | Apply discount to cart total |
scriptProperties) | Key | Type | Description |
|---|---|---|
cost | float | Current calculated cart cost |
cart | mixed | Cart (object/structure depends on MS3 version) |
draft | object|null | Order draft |
The plugin passes the array to FtbDiscountService::apply($scriptProperties).
returnedValues) $modx->event->returnedValues['cost'] = $newCost;MiniShop3 uses returnedValues['cost'] when set.
When the discount is applied, the plugin also sets:
returnedValues['ftb_discount']['amount']returnedValues['ftb_discount']['message']If multiple plugins subscribe to msOnGetCartCost, the final cost depends on MODX plugin priority.
The component can show a “First-order discount” banner.
Add to the order form template/chunk:
[[!ms3ftbDiscountBanner]]{$modx->runSnippet('ms3ftbDiscountBanner', [])}The snippet:
ftb_discount_type, ftb_discount_value, ms3_currencyThe ftb_discount plugin on OnWebPageInit/OnWebPagePrerender loads:
assets/components/ms3firsttimebuyerdiscount/css/*.css)assets/components/ms3firsttimebuyerdiscount/js/ftb-order.js)window.MS3FTB_ELIGIBLE_URLftb-order.js:
email and phone on the order formms3.orderAPI.add(...)updateOrderCosts / getCost)assets/components/ms3firsttimebuyerdiscount/eligible.phpassets/components/ms3firsttimebuyerdiscount/eligible.php returns:
{"eligible": true}or
{"eligible": false}based on getPaidOrdersCountByContact(email, phone, 0).
ms3_status_for_stat Used to define “paid” orders when checking first-time buyer.
ms3_status_new Automatically added by the service to the list of statuses as first-order marker.
If ms3_status_for_stat is empty, the service treats paid orders as 0 and logs a warning to the ftb log (once per request).
The component uses:
MiniShop3\Model\msOrderMiniShop3\Model\msOrderAddressFor guests it uses join msOrder.id = msOrderAddress.order_id.