The WordPress example
A whole shop as a WordPress plugin, in the package examples/shop: sign in as Ann (support), Ben (a customer) or Cara (the warehouse), each in a browser of their own, and try everything these pages cover.

| On the page | What makes it |
|---|---|
| The order of Ben follows as Ann moves it on, and Ben alone gets a notice | the order:{id} room, sent to by its REST route with except( tab() ), and to_user() (sending) |
| The chat of Ann and Ben, with typing, reactions and read ticks | <wordplus-chat> on the chat:{a}:{b} room, which lets pages send them. The site keeps the conversation from the webhook and gives it back from its chat/messages route (keeping the conversation). The name and picture of the other side above it from the directory |
| Who is in the shop, with a call button for each | <wordplus-online> on the shop presence room, the name and role of each member |
| A call that can bring in more staff | calls( 'support:{a}:{b}', … ) with people (calls) and the call screen |
| The daily meeting | <wordplus-room>, a group call |
| The order timeline, and what the cloud carried of it | the order room history (rooms). Its wire route seals the update as the site sends it, with the room key (encryption) |
| How many are looking at the mugs | the product:{id} room, public and counted (presence) |
| The webhooks the site got | on( '*' ), which sends each on to the shop webhooks room (sending) |
Try it online at wordpress.docs.wordplus.cloud: this example as a demo, where every visitor gets a shop of their own for a day, and its links open Ben and Cara in windows of their own. Its calls end after 10 minutes and its meetings after 15. Under each card, See the code shows the parts of this example that make it, on the server and on the page: the lines between #region demo: <card> and #endregion in its files.
Run it
Its people are users 34, 42 and 43 of the site, made when the plugin is activated, so it goes on a WordPress site of its own: it refuses a site that already has users of those ids or names. site.mjs makes one on SQLite, which the built-in PHP server serves:
cd examples/shop
export WORDPLUS_SITE=… WORDPLUS_SECRET=… # the key and secret of your app, with http://localhost:8080 among its addresses
node site.mjs ../../.site http://localhost:8080
php -S localhost:8080 -t ../../.site ../../.site/router.php
Open http://localhost:8080/example-shop/ in two browsers (or a private window), sign in as Ann in one and Ben in the other, and move the order on, chat, and call. On a site of your own instead: npm install && npm run build and composer install in examples/shop, copy the folder into wp-content/plugins/, activate API demo, and connect the site to WordPlus Cloud from its row on the Plugins screen.
Its files
| File | |
|---|---|
example-shop.php | the plugin: the rooms and calls it declares and its webhooks, the shop people as users, its order and chat in an option, its REST routes, and its pages at /example-shop/ |
demo.php | the demo part alone (WORDPLUS_DEMO=1): a shop for each visitor, its windows, a connection for each of them (the wordplus_realtime_config filter perUser), and the frame around the page |
templates/page.php | the page: the package scripts with the user settings, and the shop data |
shop/shop.js | the page script: the order, the product, the chat, who is in the shop, the webhooks, the meeting and the call screen. The same file runs the shop in the example of every guide |
wordpress.js | what shop.js imports from @wordplus/realtime, on the scripts of the package (wordplusRealtimeCalls.page()). npm run build bundles the two into assets/ |
site.mjs | a WordPress site of its own for the example, to try it |