Gatemi Name Your Price Developer Reference

Read from the plugin code. The free edition is plain WordPress PHP (GMNPF_* classes, constants GMNPF_*); the full edition is namespaced (GatemiNameYourPrice, constants GMNP_*).

Filters — Full edition

Filter Arguments What it changes
gmnp_rules array $rules, int $product_id The band for one product: enabled (bool), min, max, suggested (floats; 0.0 means "none"). Must return an array with enabled.
gmnp_settings array $settings The settings after defaults are merged in.
gmnp_modules array $modules The ordered module list the plugin boots.
gmnp_license_api_url string $url The gatemi.com licensing endpoint.
gmnp_update_cache_ttl int $seconds How long the update payload is cached.

gmnp_rules is the one decider: the field, the add-to-cart check, the cart and the catalog price all read through it, so changing it changes all of them together.

The free edition applies no filters.

Example: a higher minimum for one customer role

add_filter( 'gmnp_rules', function ( $rules, $product_id ) {
	if ( $rules['enabled'] && current_user_can( 'wholesale_customer' ) ) {
		$rules['min'] = max( $rules['min'], 20.0 );
		if ( $rules['suggested'] > 0 ) {
			$rules['suggested'] = max( $rules['suggested'], $rules['min'] );
		}
	}
	return $rules;
}, 10, 2 );

Keep suggested inside the band yourself when you change it — the plugin's own tidying runs before the filter.

Actions

Full edition: gmnp_booted fires once every module has booted, with the plugin's container. Neither edition fires any other action of its own.

WooCommerce hooks used

Hook Priority Purpose
woocommerce_before_add_to_cart_button 10 Prints the box.
woocommerce_add_to_cart_validation 10 Refuses an amount outside the band.
woocommerce_add_cart_item_data 10 Stores the clamped amount on the line.
woocommerce_get_cart_item_from_session 10 Restores it from the session.
woocommerce_before_calculate_totals 20 Sets each line's price from its amount.
woocommerce_checkout_create_order_line_item 10 Records the amount on the order line.
woocommerce_get_price_html 100 "From …" or the catalog text.
woocommerce_structured_data_product 10 Full edition: removes offers.
woocommerce_cart_item_name 10 Full edition: prints the chosen amount.

If you add your own price changes, run them before priority 20 on woocommerce_before_calculate_totals or they will be overwritten on named-price lines.

Option

gmnp_settings — shared by both editions. Keys: enabled, label, description, prefill, show_hint, show_from, catalog_text, default_min. The free edition reads enabled and label only. The full edition keeps its licence state in gmnp_license and its update cache in the transient gmnp_update_payload.

Meta keys

Key On Value
_gmnp_enabled product, variation (full edition) yes; absent means off
_gmnp_min product, variation amount as a string; absent means none
_gmnp_max product, variation Full edition: amount; absent means no ceiling
_gmnp_suggested product, variation amount
_gmnp_price order line item the amount the customer named (float)

Request and cart keys

  • Posted field: gmnp_price (on WooCommerce's own add-to-cart form).
  • Cart item data key: gmnp_price, the clamped float.

Both are shared by the two editions, so a cart in progress survives a switch of edition.

Example: reading the named amount on an order

foreach ( $order->get_items() as $item ) {
	$named = $item->get_meta( '_gmnp_price' );
	if ( '' !== $named ) {
		// $named is what the customer chose to pay per unit.
	}
}

CSS classes

Class Element
.gmnp-field Wrapper around the label, box and hint
.gmnp-label The label
.gmnp-input The number box (id and name gmnp_price)
.gmnp-hint "Minimum …" / "Between … and …"
.gmnp-description Full edition: the sentence under the box
.gmnp-chosen Full edition: the amount under the cart item name

The stylesheet is assets/css/price.css, enqueued on the storefront only while the plugin is switched on.

What it does not have

No database tables, no REST routes, no shortcodes, no cron events of its own (the full edition's only event is the licence check), and no storefront JavaScript.

Shopping Cart
Scroll to Top