You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 19, 2023. It is now read-only.
Paul Kilmurray edited this page Nov 8, 2015
·
10 revisions
Now that you have added a new menu item using POS Params and you've enqueued your custom javascript file, it's now time to add your page to the application router.
WooCommerce POS uses Backbone Marionette to provide a framework for routing and rendering views. If you are not familiar with Marionette you should read the docs on AppRouter and ItemView which will be used below. Note that both the POS application and Marionette framework are available as global variables.
// my-custom-pos-page.js(function(app,Marionette){// create a new Marionette ViewvarView=Marionette.ItemView.extend({template: function(){return'Hello World!';}});// create a new application Route (Controller)varCustomRoute=app.Route.extend({render: function(){varcontainer=app.layout.getRegion('main');varview=newView();container.show(view);}});// add the route to the application RoutervarCustomRouter=app.Router.extend({routes: {'my-custom-page' : function(){returnnewCustomRoute();}}});newCustomRouter();}(POS,Marionette));
This simple examples renders 'Hello World' to the main application region. Obviously routes (controllers) and views can be a lot more complicated. For more details examples you should review the WooCommerce POS source code.