Hook: mam_post_id_for_eta

Signature

$eta_id = apply_filters( 'mam_post_id_for_eta', int $task_id );
Parameter Type Description
$task_id int The ride order id (the driver’s current_assignment).

Return the id of the post/order whose dest_lat / dest_lon meta the ETA should be routed against. Unfiltered, that is the ride order itself. Return 0 (or anything not > 0) to skip the ETA computation — the order’s eta meta is then set to 'NA'.


When it fires

On every GPS ping (mam_gps_ping subaction), just before the Mapbox Directions call that turns the driver’s current position into an arrival estimate. The same filter is applied by the workflow delivery-routing sibling (mam-saas-manager-workflow-delivery-routing), so a callback registered once serves both ping paths — check the target’s post type if you need to behave differently per flow.

The ETA resolver handles two shapes:

  • WooCommerce order (the ride-share case): dest_lat/dest_lon are read through the WooCommerce CRUD layer (HPOS-safe).
  • Regular post: coordinates are read from post meta, backfilled once from the post’s parent (lat/lon meta) if dest_id was never set.

The resulting minutes-to-arrival drive the eta order meta (shown live to the rider) and the “arriving in 2 minutes” notification.


Example — route the ETA to a different target

// Compute the ETA against a venue post instead of the order's own destination.
add_filter( 'mam_post_id_for_eta', function ( $task_id ) {
    $order = wc_get_order( $task_id );
    if ( $order && ( $venue_id = (int) $order->get_meta( 'my_venue_id' ) ) ) {
        return $venue_id; // must carry dest_lat / dest_lon meta
    }
    return $task_id;
} );

Example — disable ETA for specific rides

add_filter( 'mam_post_id_for_eta', function ( $task_id ) {
    $order = wc_get_order( $task_id );
    return ( $order && $order->get_meta( 'manager_assigned' ) ) ? 0 : $task_id;
} );

Notes

  • Whatever id you return must have dest_lat / dest_lon (order meta for orders, post meta for posts) — without them the resolver reports “no venue” and the ride’s eta falls back per the Mapbox recipe.
  • ETA quality depends on the Mapbox token; with no token the duration falls back to a fixed 10 minutes.


Metadata

Field Value
Article type Hook Reference
Plugin slug mam-woocommerce-ride-share
Applies to plugin version 1.3.1+
Category Extending MAM Suite
Hook type filter
Audience PHP developer
Last verified 2026-06-10
Contents

    Need Support?

    Can't find the answer you're looking for? Don't worry we're here to help!