Skip to content
Leanmerce Availability

Supported Core hooks

Use the public domain results and repositories; do not write dpaw_* records or private Pro tables directly. Current supported hooks are:

  • leanmerce_availability_locations( AvailabilityLocation[] $locations, LocationRepository $repository)
  • leanmerce_availability_resolved( ResolvedAvailability $result, WC_Product $product, AvailabilityResolver $resolver)
  • leanmerce_availability_public_data( array $data, ResolvedAvailability $result, StorefrontPresenter $presenter)
  • leanmerce_availability_shipping_rule( ?array $rule, $rate, string $rate_id, ShippingMethodMap $map)
  • leanmerce_availability_validation_message( string $message, string $reason, WC_Product $product)
  • leanmerce_availability_system_report( array $report, SystemReport $builder)

The public variation payload contains product ID and location ID/label/boolean state/message. Availability is boolean/inherited; quantity: null is not zero. Extensions must preserve capabilities, cache/index updates, assignment-save events and WooCommerce stock authority. Internal option names are compatibility storage, not a public write API.

Filters load after active Core has registered its services; Pro-only classes cannot be assumed in a Free extension. Return the same documented type you receive. A safe read-only example is:

add_filter( 'leanmerce_availability_public_data', function ( array $data, $resolved, $presenter ) {
    $data['my_extension_observed'] = true;
    return $data;
}, 10, 3 );

leanmerce_availability_locations must return AvailabilityLocation objects. leanmerce_availability_resolved must return ResolvedAvailability. leanmerce_availability_shipping_rule returns the existing rule or null. Validation-message and system-report filters return string and array respectively. Treat passed repositories/domain services as authoritative; never write private Pro tables, Core options or WooCommerce _stock directly. Anything not exposed through these named filters is private.