Gatemi Returns Developer Reference

Both editions share their storage on purpose, so everything under Storage applies to both. The free edition applies one filter of its own, gmrtf_email; the rest are the full edition's.

Filters

gmrtf_email (free edition) and gmrt_email — Full edition

Filters a customer email just before wp_mail(). Return false to hold it back; the decision it reports stands either way.

Argument Type
$message array|false to, subject, body (plain text)
$event string received, approved, declined, refunded, or (full edition) the exchange email
$request array The request row
// Copy every return email to the warehouse.
add_filter( 'gmrt_email', function ( $message, $event, $request ) {
	if ( is_array( $message ) && 'approved' === $event ) {
		wp_mail( 'warehouse@example.com', $message['subject'], $message['body'] );
	}
	return $message;
}, 10, 3 );

The shop's own "New return request" email goes to the site's admin address (Settings → General) and is not filtered.

gmrt_settings — Full edition

The merged settings array, after defaults. Return a modified array to override a setting in code.

gmrt_reasons — Full edition

The reasons a customer picks from, in order (array of strings). Only a reason in this list is stored on a request.

gmrt_window_days — Full edition

The window, in days, for one product — applied after the product, category and store settings.

Argument Type
$days int The resolved window
$product_id int The product (a variation's parent)

gmrt_returnable — Full edition

Whether a product may be returned at all. Use it where a store keeps its own list of final-sale goods.

// Gift cards are never returnable.
add_filter( 'gmrt_returnable', function ( $returnable, $product_id ) {
	return $returnable && ! has_term( 'gift-cards', 'product_cat', $product_id );
}, 10, 2 );

gmrt_report_batch — Full edition

How many orders the returns report reads per page. Default 100, clamped to 1–500.

gmrt_modules, gmrt_license_api_url, gmrt_update_cache_ttl — Full edition

The boot module list, the gatemi.com licensing endpoint (for staging mirrors) and how long the update payload is cached, in seconds.

Actions — Full edition

gmrt_booted

Fires once the plugin has booted, with its service container as the only argument.

Storage

Tables

Created with dbDelta(); the schema version is in the option gmrt_db_version.

{prefix}gmrt_requests — one row per request.

Column
id Primary key
reference RMA- + 8 characters, unique
order_id, customer_id, email Whose return
status requested, approved, declined, refunded, exchanged
resolution refund, exchange, credit
reason, note, merchant_note What was said
refund_id, refund_amount, restocking_fee, refund_method, coupon_code The money
window_ends_at, requested_at, decided_at, refunded_at The dates

{prefix}gmrt_request_items — one row per returned line: request_id, order_item_id, product_id, variation_id, name, qty, unit_amount, unit_tax. The unit figures are the order line's own, frozen when the request is made.

Options

Option
gmrt_settings The settings (shared by both editions)
gmrt_db_version Schema version (shared)
gmrt_endpoint_added Marks that the My Account endpoint's rewrite rules were flushed
gmrt_license Full edition licence state

Order meta

_gmrt_returned_qty — line item id ⇒ quantity currently held by returns. Read and written through the order's own meta API, so it works under HPOS and the legacy order store alike.

Product and term meta — Full edition writes, free edition reads one

Key On Values
_gmrt_non_returnable Product yes final sale, no always returnable, absent follows its categories
_gmrt_non_returnable product_cat term yes final sale (covers sub-categories)
_gmrt_window_days Product or product_cat term Days, 0–3650; absent follows the next level up

The free edition reads only _gmrt_non_returnable = yes on a product.

Coupons — Full edition

Store credit is a WooCommerce coupon coded CREDIT- + the reference's eight characters: fixed_cart, usage limit 1, one per customer, restricted to the billing email.

My Account

Endpoint gmrt-returns (My Account → Returns, inserted before Logout)
Order argument gmrt_order — the form for one order
Order action key gmrt-return (on woocommerce_my_account_my_orders_actions)
Form nonce gmrt_request
Form fields gmrt_qty[<order item id>], gmrt_order, gmrt_submit, gmrt_note, and (full edition) gmrt_reason, gmrt_resolution

The order's own page gets a Returns section on woocommerce_order_details_after_order_table.

Full edition: the printable return note is served at the site's home URL with ?gmrt_note=<request id> and a nonce gmrt_note_<id>, to a shop manager or to the customer the request belongs to. It is noindex and sent with no-cache headers.

Admin

WooCommerce → Returns, page slug gmrt-returns, capability manage_woocommerce. One request: &request=<id>. Full edition tabs: &tab=report and &tab=settings.

CSS classes

The storefront stylesheet is loaded only on My Account. Classes shared by both editions, so your own CSS survives an upgrade:

Class Element
.gmrt-account The Returns page wrapper
.gmrt-policy Your policy text above the form
.gmrt-form, .gmrt-lines, .gmrt-qty The form, its line table and the quantity boxes
.gmrt-field, .gmrt-choice A form field; a resolution choice (full edition)
.gmrt-requests, .gmrt-status The list of requests and a status label
.gmrt-message A notice such as "Nothing on this order can be returned online now"
.gmrt-order-returns The Returns section on an order's page
.gmrt-policy {
	border-left: 3px solid currentColor;
	padding-left: 1em;
}

There is no JavaScript to hook: every action is an ordinary form post that redirects.

Shopping Cart
Scroll to Top