Page Metaboxes
To add metaboxes to individual pages, you will need to register an addon, client-side using react. This lets you render whatever you want in the metabox, hook into page content, or display whatever you want in the sidebar.Registering an Addon
To add a custom addon, you need to call theregisterAddon function. This function can be accessed from the window.surecart object. It accepts 2 parameters, name & settings.
registerAddon(name, settings)
The name of the addon.
Getting Page Data
SureCart uses WordPress Core Data (WordPress’ flavor of Redux) to store data. This means you can use familiar WordPress redux functions to get SureCart data.Get The Current Page ID
In order to query page data, you need to get the current page id. This function is available in the globalwindow.surecart object.
Query Page Data
You can use theuseSelect function to query page data. If we are on the order page, we can get the order data from the id.
Querying an Order
Querying A Product
Order Page Example
In this example we are adding a custom order display. We are using some WordPress redux functions to query orders and display them in a custom way.Admin List Tables
SureCart provides the ability to customize the list table views in its admin pages—like Orders, Products, Invoices, and more—by adding custom columns. This can help you display additional information relevant to your store’s workflow, at-a-glance, without needing to open individual records.Adding Custom Columns
Since we are using WordPress tables, you can use themanage_{$post_type}_posts_columns functions WordPress provides to add custom columns. The page is the page query parameter found in the url.
1
Add the column
First we need to add our column to the list of columns.
2
Add the column content
Next we need to add the content for our column.