REST API Reference
Complete API reference for developers integrating with Magical Shop Builder programmatically.
Overview
The REST API (class-mpd-rest-api.php, 1571 lines) exposes endpoints under the mpd/v1 namespace. All endpoints require manage_options capability (administrator role).
Base URL:
https://yoursite.com/wp-json/mpd/v1/
Authentication: Use WordPress REST API authentication (nonce, application passwords, or OAuth).
All REST API endpoints require administrator privileges (manage_options capability). They are not designed for frontend/public use.
Settings Endpoints
GET /settings
Get all plugin settings.
Response: JSON object with all settings groups:
general— General plugin settingssingle_product— Single product page settingscart_checkout— Cart and checkout settingsmy_account— My Account page settingsperformance— Performance optimization settingspreloader— Preloader configurationremote_server— Remote layout server settings
POST /settings
Update plugin settings.
Body: JSON object with settings to update.
Template Endpoints
GET /templates
Get all templates. Supports an optional ?type= query parameter to filter by template type.
POST /templates
Create a new template.
Body: JSON object with title, type, and layout.
// POST /templates
{
"title": "Custom Product Page",
"type": "single-product",
"layout": "default"
}
{
"id": 42,
"title": "Custom Product Page",
"type": "single-product",
"layout": "default",
"status": "draft",
"created": "2025-01-15T10:30:00",
"modified": "2025-01-15T10:30:00"
}
GET /templates/{id}
Get a single template by ID.
PUT/PATCH /templates/{id}
Update an existing template.
DELETE /templates/{id}
Delete a template.
GET /templates/{id}/conditions
Get display conditions for a template.
POST /templates/{id}/conditions
Update display conditions for a template.
POST /templates/{id}/duplicate
Duplicate an existing template.
POST /templates/{id}/priority
Update the display priority of a template.
Widget Endpoints
GET /widgets
Get the full widget list with each widget’s enable/disable status.
POST /widgets
Update widget enable/disable status.
Stats Endpoint
GET /stats
Get dashboard statistics.
Response body fields:
| Field | Description |
|---|---|
templates.total |
Total template count |
templates.draft |
Draft template count |
products.total |
Total WooCommerce products |
woocommerce.orders_today |
Orders placed today |
woocommerce.orders_this_week |
Orders this week |
woocommerce.revenue_today |
Today’s revenue |
plugin.version |
Plugin version |
plugin.is_pro |
Whether Pro is active |
plugin.install_date |
Installation date |
License Endpoints
GET /license
Get current license status.
POST /license
Activate a license.
Body: JSON object with license_key.
DELETE /license
Deactivate the current license.
Pre-Layout Endpoints
GET /prelayouts
Get all pre-built layouts.
GET /prelayouts/{id}
Get a single pre-built layout by ID.
GET /prelayouts/{id}/preview
Get layout preview HTML.
POST /prelayouts/import
Import a pre-built layout into a template.
Body: JSON object with layout_id and template_id.
GET /prelayouts/by-type/{type}
Get pre-built layouts filtered by template type.
AJAX Actions (Non-REST)
For frontend functionality, the plugin uses WordPress AJAX actions instead of REST endpoints:
| Action | Auth | Description |
|---|---|---|
mpd_load_tab_products |
Both | Load products for tab widget by category |
mpd_load_more_products |
Both | Infinite scroll / load more products |
mpd_filter_products |
Both | Filter products by price, attributes, etc. |
| AJAX Search Handler | Both | Live product search suggestions |
Nonces: mpd_tab_ajax_nonce, mpd_shop_archive_nonce
Localized JavaScript Objects
The following data objects are available in frontend JavaScript via wp_localize_script:
| Object | Description |
|---|---|
mpdGlobalWidgets |
AJAX URL, nonce, cart/checkout URLs, i18n strings |
mpdTabAjax |
AJAX URL, nonce for tab widget |
mpdAjaxSearch |
AJAX URL, shop URL, currency symbol |
mpdShopArchive |
AJAX URL, nonce, i18n strings for archive |
mpd_checkout_params |
AJAX URL, nonce for checkout |
mpdAdmin |
Admin API URL, nonce, plugin info, Pro status |
Helper Functions
Key PHP helper functions developers can use in themes and custom plugins:
| Function | Description |
|---|---|
mpd_is_pro_active() |
Check if Pro add-on is active |
mpd_get_version() |
Get current plugin version |
mpd_is_elementor_active() |
Check if Elementor is installed and active |
mpd_is_elementor_pro_active() |
Check if Elementor Pro is active |
mpd_has_elementor_theme_builder() |
Check for Theme Builder support |
mpd_is_woocommerce_active() |
Check if WooCommerce is active |
mpd_is_block_checkout() |
Detect WC Block Checkout usage |
mpd_is_block_cart() |
Detect WC Block Cart usage |
mpd_get_template_for_location($location, $context) |
Find matching template for a given location |
mpd_get_wc_page_type() |
Detect current WC page type |
mpd_get_cart_count() |
Get number of items in cart |
mpd_get_cart_total() |
Get cart total amount |
mpd_get_mini_cart() |
Get mini cart HTML |