Gatemi Checkout Consent Developer Reference

The plugin is classic WordPress code: four GMCC_* classes in includes/, no autoloader, no JavaScript and no database tables. Constants: GMCC_VERSION, GMCC_FILE, GMCC_PATH, GMCC_URL. Text domain gatemi-checkout-consent.

Filter

gmcc_boxes

Filters the boxes shown at this checkout. It receives the active boxes — switched on and with wording — after normalization, in the merchant's order.

Argument Type
$boxes array<int,array<string,string>> Each box: id, label, required, error, enabled

The same filtered list is used to draw the boxes, to enforce required ones, to record ticks, and to register the Checkout block fields.

// Show the age box only when the cart holds something in the "wine" category.
add_filter( 'gmcc_boxes', function ( $boxes ) {
	if ( ! function_exists( 'WC' ) || ! WC()->cart ) {
		return $boxes;
	}
	$has_wine = false;
	foreach ( WC()->cart->get_cart() as $item ) {
		if ( has_term( 'wine', 'product_cat', $item['product_id'] ) ) {
			$has_wine = true;
			break;
		}
	}
	return $has_wine ? $boxes : array_values( array_filter( $boxes, function ( $box ) {
		return 'consent-age' !== $box['id'];
	} ) );
} );

Caveat for the Checkout block: the block fields are registered with WooCommerce on init, once per request, before a cart is loaded. A filter that depends on the cart is reliable on the classic checkout only. To keep a box off the block entirely, remove it unconditionally.

The plugin applies no other filters and fires no actions of its own.

Option

Option Holds
gmcc_boxes List of up to five boxes, each array( 'id', 'label', 'required', 'error', 'enabled' )

required and enabled are 'yes' or 'no'; anything else reads as 'no'. The label keeps what wp_kses_post() allows; the error is plain text. The list is normalized on read as well as on write.

Order meta

Key Holds
_gmcc_consents List of array( 'id' => …, 'label' => …, 'at' => 'Y-m-d H:i:s' ), UTC, one per ticked box
_wc_other/gatemi-checkout-consent/{id} Written by WooCommerce, not this plugin, on Checkout block orders: '1' for a tick

label is stored as plain text. Read the record through the order:

$order    = wc_get_order( $order_id );
$consents = (array) $order->get_meta( '_gmcc_consents' );
foreach ( $consents as $consent ) {
	printf( "%s — %s UTCn", $consent['label'], $consent['at'] );
}

Or with the plugin's own reader, which normalizes each entry:

$consents = GMCC_Consents::accepted( $order );

Field names

Checkout Name
Classic gmcc_{id} (posted value 1)
Checkout block gatemi-checkout-consent/{id}, location order, type checkbox

WooCommerce hooks the plugin uses

Hook What the plugin does
woocommerce_review_order_before_submit Prints the boxes (classic)
woocommerce_checkout_process Refuses a required box that was not ticked (classic)
woocommerce_checkout_create_order Writes _gmcc_consents (classic)
init Registers block fields with woocommerce_register_additional_checkout_field()
woocommerce_store_api_checkout_order_processed Reads the block ticks back, writes _gmcc_consents, saves the order
add_meta_boxes Adds the Consent panel (gmcc-consent) on shop_order and woocommerce_page_wc-orders
before_woocommerce_init Declares custom_order_tables and cart_checkout_blocks compatibility

Block registration is idempotent within a request, and a definition WooCommerce refuses is caught rather than allowed to break the page.

Admin

  • Screen slug: gmcc-settings (WooCommerce → Checkout Consent), capability manage_woocommerce.
  • Nonce action: gmcc_save_settings; posted under gmcc[boxes][n].

Stylesheets

Handle File Loaded
gmcc assets/css/consent.css Storefront, only when a box was drawn; also on both order screens
gmcc-admin assets/css/admin.css The settings screen only

CSS classes

Class Element
.gmcc-consents Wrapper around all boxes (classic)
.gmcc-consent One box's <p>; .gmcc-consent--required when required
.gmcc-consent-label The <label> around the input and text
.gmcc-consent-text The wording
.gmcc-consent-required The * (an <abbr>)
.gmcc-record, .gmcc-record-item, .gmcc-record-when The Consent panel
/* Put the consent wording in your checkout's small print size. */
.gmcc-consent-text { font-size: 0.9em; }

On the Checkout block the fields are WooCommerce's own markup, so these classes do not apply there.

Uninstall

uninstall.php deletes gmcc_boxes and nothing else. No order meta is touched.

Shopping Cart
Scroll to Top