Hook: mam_submit_order

Signature

do_action( 'mam_submit_order' );

No arguments. The handler reads everything from the request:

Input Where Description
Cart payload raw request body (php://input) JSON with an orderDetails array; the first element is the cart (items, addresses, tips, taxes, fees, totals).
coupon $_REQUEST['coupon'] Optional coupon code echoed onto the order.
Acting customer mam_user_id() Resolved server-side by MAM Main from the app session — never from request parameters.

When it fires

mam-woocommerce registers the handler on this hook; anything that fires the action triggers a complete order submission. There are two ways an order submission starts:

  1. The primary app path — the app posts to admin-ajax.php?action=mam_woocommerce_manager with subaction mam_submit_order and the user’s app token (pid). This path calls the same pipeline directly (it does not fire the hook).
  2. The hook path — server-side code (another plugin, or an older dispatch flow) runs do_action( 'mam_submit_order' ) during a request that carries the cart payload.

Warning — this handler terminates the request. It ends with wp_send_json() + die(), returning a JSON payload (status, order_id, message, plus refreshed app data in jsonData). Only fire it when JSON-and-exit is the desired outcome.

The legacy alias tsl_submit_order (and the duplicate filter registrations of both names) exists only for app builds in the wild and is scheduled for removal on Dec 1, 2026 — use the action mam_submit_order.


What the pipeline does

  1. Authorizes: the order is created for the server-resolved user only; with no resolved user the submission is denied (escape hatch: mam_wc_user_can_submit_order).
  2. Validates the cart payload and lets pre-processors veto or take over (woocommerce_before_order_modify_cart, mam_woocommerce_menu_before_order_processing).
  3. Creates the WC_Order with items, addresses, tips, taxes, and fees, then charges via mam_pmt_charge_card (or places a hold — see Configure checkout for the app).
  4. Filters the result through mam_wc_order_completed and responds.

Example — trigger a submission from a custom dispatcher

// Inside an authenticated request that carries the order JSON body:
if ( has_action( 'mam_submit_order' ) ) {
    do_action( 'mam_submit_order' ); // responds with JSON and exits
}


Metadata

Field Value
Article type Hook Reference
Plugin slug mam-woocommerce
Applies to plugin version 26.19.3+
Category Extending MAM Suite
Hook type action (a filter registration also exists for back-compat)
Audience PHP developer
Last verified 2026-06-10
Contents

    Need Support?

    Can't find the answer you're looking for? Don't worry we're here to help!