Portal Data Formats

Data that is provided to the Portal (Customer Portals) during front-end rendering is provided first as localized JS object data. In other words it is passed into the Portal React App via localized PHP conversion to native JS objects. This is handled using the WP Localize function. The result is that all PHP converted data available at load is found in the global JS variable SACOM_PortalData.

After loading is complete, any additional data loaded into the Portal will be done via API calls using wp.fetch(). This is appropriate when either the data is subjected to change during use of the portal, or when there are concerns about the performance of loading the data initially.

As a practical example the Invoice Component loads a Portal Section using the ‘sacom_portal_section_register’ filter. During this filter hook callback the Invoice Component passes data by adding it to the PortalSectionModel data property. It adds two important sets of data, the Invoice Model Definition and an array of existing Invoices.

Powered by BetterDocs