Use this file to discover all available pages before exploring further.
If you want to add custom UI elements to admin pages of SureCart like Order, Product, Customer, Affiliate pages etc. you can use this API to add either in the Main or the Sidebar area.
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.
To add a custom addon, you need to call the registerAddon function. This function can be accessed from the window.surecart object. It accepts 2 parameters, name & settings.
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.
import { useSelect } from "@wordpress/data";import { store } from "@wordpress/core-data";// fetch or get the order data from redux.const order = useSelect( (select) => select(store).getEntityRecord("surecart", "order", id, { // expand any nested resources you need. expand: ["checkout"], }), // the id from the previous function [id]);
import { useSelect } from "@wordpress/data";import { store } from "@wordpress/core-data";// fetch or get the order data from redux.const product = useSelect( (select) => select(store).getEntityRecord("surecart", "product", id, { // expand any nested resources you need. expand: ["prices", "variants"], }), // the id from the previous function [id]);// get nested prices.const prices = product?.prices;
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.
Since we are using WordPress tables, you can use the manage_{$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.
// sc-orders, sc-products, etc. which are found in the url.add_filter( 'manage_sc-products_columns', 'my_custom_column' );// Add a new column labeled "Metabox."function my_custom_column( $columns ) {$columns['metabox'] = 'Metabox';return $columns;}
2
Add the column content
Next we need to add the content for our column.
// sc-orders, sc-products, etc. which are found in the url.add_action( 'manage_sc-products_custom_column', 'my_custom_column_content', 10, 2 );function my_custom_column_content( $column_name, $data ) { // $data is the model object for the current row in the table. if ( 'metabox' === $column_name ) { // Replace this with whatever you want to display from $data. echo esc_html( $data->id ); }}
This lets you add any custom content to the admin list tables, while still providing access to the underlying data.