Hooks
Wolt Drive for WooCommerce includes PHP hooks for custom integrations that need to customize how delivery addresses are passed to Wolt.
These hooks are intended for developers. Add custom hook callbacks in your
theme’s functions.php, a child theme, or a small custom plugin.
woltdrive_checkout_dropoff_address
Filters the drop-off address used while WooCommerce calculates the Wolt Drive shipping rate on checkout.
Use this hook when your checkout page stores the customer’s delivery address in custom fields instead of WooCommerce’s native shipping address fields.
add_filter( 'woltdrive_checkout_dropoff_address', function ($dropoff_address, $package, $shipping_method) { $custom_address = WC()->session->get('custom_delivery_address');
if (! empty($custom_address)) { return $custom_address; }
return $dropoff_address; }, 10, 3);Parameters
| Parameter | Type | Description |
|---|---|---|
$dropoff_address | string | The default address built from WooCommerce’s checkout destination. |
$package | array | The WooCommerce shipping package used for the rate calculation. |
$shipping_method | WoltDrive\WooCommerce\ShippingMethod | The Wolt Drive shipping method instance. |
Returns
Return a non-empty formatted address string. If the value is not a string or is empty after trimming, the Wolt Drive rate is not added.
woltdrive_order_dropoff_address
Filters the drop-off address used when creating the Wolt Drive order from a WooCommerce order.
Use this hook when the finalized WooCommerce order does not store the delivery address in WooCommerce’s native shipping address fields.
add_filter( 'woltdrive_order_dropoff_address', function ($dropoff_address, $order) { $custom_address = $order->get_meta('_custom_delivery_address');
if (! empty($custom_address)) { return $custom_address; }
return $dropoff_address; }, 10, 2);Parameters
| Parameter | Type | Description |
|---|---|---|
$dropoff_address | string | The default address built from the WooCommerce order’s shipping address fields. |
$order | WC_Order | The WooCommerce order. |
Returns
Return the formatted address string that should be sent to Wolt as the drop-off address.
woltdrive_geocode_address
Filters the coordinates used for a formatted address sent to Wolt.
Use this hook when you already have latitude and longitude coordinates for an address, or when you need to use your own geocoding service.
add_filter( 'woltdrive_geocode_address', function ($coordinates, $formatted_address) { $custom_coordinates = my_custom_geocoder($formatted_address);
if ($custom_coordinates) { return [ 'lat' => (float) $custom_coordinates['lat'], 'lon' => (float) $custom_coordinates['lon'], ]; }
return $coordinates; }, 10, 2);Parameters
| Parameter | Type | Description |
|---|---|---|
$coordinates | `null | array` |
$formatted_address | string | The formatted address being sent to Wolt. |
Returns
Return null or an array with lat and lon values:
[ 'lat' => 37.9838, 'lon' => 23.7275,]If the returned array does not include valid lat and lon values, the plugin
ignores it and logs a warning.
Complete Custom Checkout Example
The checkout and order hooks usually need to be used together. The checkout hook controls whether the Wolt Drive shipping method appears, while the order hook controls the address sent when the Wolt Drive order is created.
add_filter( 'woltdrive_checkout_dropoff_address', function ($dropoff_address) { $address = WC()->session->get('custom_delivery_address');
return ! empty($address) ? $address : $dropoff_address; });
add_filter( 'woltdrive_order_dropoff_address', function ($dropoff_address, $order) { $address = $order->get_meta('_custom_delivery_address');
return ! empty($address) ? $address : $dropoff_address; }, 10, 2);Your custom checkout implementation is responsible for saving the delivery address to the WooCommerce session during checkout and to order meta when the order is created.