Gatemi Shipping Developer Reference

The free edition applies no filters of its own; it is one WC_Shipping_Method subclass, GMSHF_Method, with method id gmshf_table_rate. Everything else on this page is the full edition's (namespace GatemiShipping, prefix gmship_).

Shipping method ids

Edition Method id Rate ids
Free gmshf_table_rate gmshf_table_rate:<instance>
Full gmship_table_rate Per order: gmship_table_rate:<instance>:<row id>. Other modes: gmship_table_rate:<instance>

Use these ids in restriction targets: gmship_table_rate covers every instance.

Filters — Full edition

gmship_condition_types and gmship_evaluate_condition

Add a condition. gmship_condition_types filters the vocabulary — an array keyed by type id, each with label, group (destination, cart, products, customer, order), value_type (choice, number, text_list, boolean), operators, options, unit, contexts (rate, restriction) and help.

gmship_evaluate_condition decides one condition. Return true or false to decide it; return null to let the engine evaluate it. It runs before the built-in types, so it can also override them.

Argument Type
$result `bool null`
$condition array type, operator, value
$context GatemiShippingRulesContext The package or cart being tested

Context has public country, state, postcode, city, items, coupons, roles, logged_in, payment_method, chosen_shipping_methods, and methods subtotal( $tax ), total( $tax ), weight(), volume(), item_count(), line_count(), product_ids(), category_ids(), tag_ids(), shipping_class_ids(), skus().

add_filter( 'gmship_condition_types', function ( $types ) {
	$types['weekday'] = array(
		'label'      => 'Day of the week',
		'group'      => 'order',
		'value_type' => 'text_list',
		'operators'  => array( 'in', 'not_in' ),
		'contexts'   => array( 'rate', 'restriction' ),
		'help'       => 'Mon, Tue, …',
	);
	return $types;
} );

add_filter( 'gmship_evaluate_condition', function ( $result, $condition ) {
	if ( 'weekday' !== $condition['type'] ) {
		return $result;
	}
	$today = wp_date( 'D' );
	$in    = in_array( $today, (array) $condition['value'], true );
	return 'not_in' === $condition['operator'] ? ! $in : $in;
}, 10, 2 );

A type with no answer does not match.

gmship_row_cost

What one row charges for one unit, after its own floor and ceiling and before the handling fee and method limits.

Argument Type
$cost float The row's cost
$row GatemiShippingRatesRateRow The row
$context Context The unit's goods
$config GatemiShippingRatesMethodConfig The instance's settings

gmship_rate_offers

The finished rates before they are added with add_rate().

Argument Type
$offers RateOffer[] Each has suffix, label, description, cost (a number or per-item array), row_ids
$package array The WooCommerce package
$method ShippingMethod The method instance

Anything in the list that is not a RateOffer is ignored.

// Rename the options for wholesale customers.
add_filter( 'gmship_rate_offers', function ( $offers ) {
	if ( current_user_can( 'wholesale_customer' ) ) {
		foreach ( $offers as $offer ) {
			$offer->label .= ' (trade)';
		}
	}
	return $offers;
} );

gmship_conditions_include_tax

Whether subtotal and total conditions are compared including tax. Default: wc_prices_include_tax().

gmship_volatile_conditions

The condition types that force WooCommerce to recalculate cached rates by being injected into the package. Default array( 'payment_method' ).

gmship_restriction_targets

The shipping methods and payment methods a restriction can name, as id => label. The second argument says which list it is: 'shipping' or 'payment'.

gmship_settings

The plugin settings (debug, delete_data) after defaults are merged.

Licensing and boot

gmship_license_api_url, gmship_update_cache_ttl, gmship_update_retry_ttl, gmship_sync_cache_ttl and gmship_modules, as in every Gatemi plugin.

Actions — Full edition

  • gmship_booted — after every module has booted; receives the container.

WooCommerce hooks used — Full edition

Hook Priority Does
woocommerce_shipping_methods 10 Registers gmship_table_rate
woocommerce_cart_shipping_packages 20 Injects the chosen payment method when a restriction needs it
woocommerce_package_rates 100 Shipping restrictions
woocommerce_available_payment_gateways 100 Payment restrictions (not in wp-admin)
woocommerce_no_available_payment_methods_message 10 Payment rule sentences
woocommerce_no_shipping_available_html, woocommerce_cart_no_shipping_available_html 10 Cannot-ship and no-match sentences on the classic cart and checkout
woocommerce_store_api_cart_errors 10 The same sentences on the blocks
woocommerce_shipping_zone_method_deleted 10 Deletes the instance's rate rows

Tables — Full edition

{prefix}gmship_rates, keyed by KEY instance_order (instance_id, sort_order):

Column Type
rate_id bigint, primary key
instance_id bigint
sort_order smallint
label, description varchar
conditions longtext (JSON group)
cost_flat, cost_item, cost_weight decimal(19,4)
cost_percent decimal(10,4)
cost_min, cost_max decimal(19,4), NULL = none
is_abort, stops, enabled tinyint(1)
abort_reason varchar(255)

{prefix}gmship_restrictions — the same table and shape as Gatemi Conditional Shipping uses: restriction_id, title, target_type (shipping|payment), action (hide|show_only), targets (JSON list), conditions (JSON), message, sort_order, enabled.

The schema version is in the option gmship_schema_version; the installer also runs on admin_init, so a plugin updated by copying files still gets its tables. Rate rows are cached in the object-cache group gmship.

The condition JSON

{
  "match": "all",
  "rules": [
    { "type": "weight", "operator": "gt", "value": 10 },
    { "match": "any", "rules": [
      { "type": "postcode", "operator": "matches_any", "value": ["HS*", "ZE*"] },
      { "type": "shipping_class", "operator": "contains_any", "value": ["14"] }
    ] }
  ]
}

Shipping classes, categories, tags and products are stored by id.

CSV format — Full edition

One file per method instance, header first. Columns are matched by header name, so they may be reordered or left out; a file with no recognisable header is rejected.

Header Column
Name label
Note description
Applies when (JSON) conditions
Flat cost cost_flat
Cost per item cost_item
Cost per weight unit cost_weight
Percent of goods cost_percent
Minimum cost cost_min
Maximum cost cost_max
Stop here stops
Cannot ship is_abort
Reason abort_reason
Active enabled

The export link is admin-post.php?action=gmship_export_rates and needs manage_woocommerce.

Options

Option Edition
woocommerce_gmshf_table_rate_<instance>_settings Free Each instance's settings
woocommerce_gmship_table_rate_<instance>_settings Full Each instance's settings
gmship_settings Full debug, delete_data
gmship_schema_version Full (shared) Table schema version
gmship_license Full Licence

Cron — Full edition

gmship_license_check — twice daily, only once a licence key is entered.

CSS

No storefront stylesheet or script is loaded by either edition. Admin assets load only on the zone method screen and the Rules section.

Shopping Cart
Scroll to Top