The Customer requires validation to be added before an item is added into a cart in POS. For example, an item must belong to a certain list to be purchased from POS. Or any criteria whatsoever.
When an item is being added into a cart, one of the requests triggered is SaveCartVersionedDataRequest. We can add a pre-trigger to this request as a Commerce Runtime (CRT) extension. We’d need to implement the IRequestTriggerAsync interface and implement mandatory methods.
Build your CRT extension and place it in the Retail Server’s extension folder. Drop extension .dll in RetailServer\WebRoot\bin\Ext folder and modify CommerceRuntime.Ext configuration file by adding extension assembly reference in composition section of config file. Restart the Retail Server after adding an extension to it.
To debug locally you can also add this extension .dll in C:\Program Files (x86)\Microsoft Dynamics 365\70\Retail Modern POS\ClientBroker\ext folder and add reference of extension assembly in CommerceRuntime.MPOSOffline.ext config file. Attach it to the IIS process of the Retail Server.
For Retail SDK build, you’d need to add this CRT extension to CommerceRuntime.ext config in RetailSDK>Assets and customization.settings in RetailSDK>BuildTools.