Skip to content
Čeština

Developer filters

If you can’t find a filter or action here that you need, contact me with where and how you’d like it added, and I’ll gladly do so, to keep future plugin updates safe.

The filter returns the order statuses for which the order status is no longer updated based on data from Mailstep.

apply_filters('kbnt_mailstep_blocked_statuses_update', ['completed',
'failed', 'cancelled', 'refunded']);
  • $statuses (array) Order statuses

The filter is located in the file includes/class-kbnt-mailstep-orders.php.

The filter returns the slugs of payment methods that are considered cash on delivery.

apply_filters('kbnt_mailstep_cod_payment_methods', ['cod', 'dobirka']);
  • $methods (array) Slugs of payment methods considered cash on delivery.

The filter is located in the files includes/class-kbnt-mailstep-api.php, includes/class-kbnt-mailstep-orders.php.

Lets you introduce a fallback for couriers that aren’t set. It accepts an array with the WooCommerce delivery method ID as the key and the Mailstep Courier ID as the value.

apply_filters('kbnt_mailstep_fallback_couriers', []);
  • $fallback_couriers (array) WC method_id → Mailstep courier_id.
add_filter('kbnt_mailstep_fallback_couriers', function(){
return [
"local_pickup" => 123,
];
});

The filter is located in the file includes/class-kbnt-mailstep-api.php.

Lets you modify the Courier ID.

apply_filters('kbnt_mailstep_get_order_courier_id', get_option('wc_kbnt_mailstep_settings_shipping_' . $shipping_method->get_method_id() . ':' . $shipping_method->get_instance_id(), false), $order, $shipping_method->get_method_id(), $shipping_method->get_instance_id());
  • $courier_id (int) Courier ID (according to the Kybernaut Mailstep settings).
  • $order (WC_Order) The order.
  • $method_id (string) The delivery method ID.
  • $instance_id (string) The delivery method instance ID.

The filter is located in the file includes/class-kbnt-mailstep-api.php.


The filter returns the individual parameters sent to Mailstep and lets developers modify them.

apply_filters('kbnt_mailstep_order_set', $parameters, $order);
  • $parameters (array) The individual parameters sent to Mailstep.
  • $order (WC_Order) The order.

The filter is located in the file includes/class-kbnt-mailstep-api.php.


The filter lets you exclude warehouses from the Mailstep stock status synchronization. You can find the Store IDs either from Mailstep or in the log. After a change, clear the synchronization cache.

apply_filters('kbnt_mailstep_sync_excluded_store_ids', []);
  • $exluded_store_ids (array) A list of warehouse IDs (string).

The filter is located in the file includes/class-kbnt-mailstep-inventory-sync.php.


kbnt_mailstep_sync_inventory_products_per_sync

Section titled “kbnt_mailstep_sync_inventory_products_per_sync”

The filter returns how many products are synchronized with the stock level in Mailstep at once.

apply_filters('kbnt_mailstep_sync_inventory_products_per_sync', 300);
  • $products_per_sync (int) The number of products synchronized at once.

The filter is located in the file includes/class-kbnt-mailstep-inventory-sync.php.


The filter lets you set how often the automatic stock synchronization runs. After a change, turn stock synchronization off and on again so it gets rescheduled.

apply_filters('kbnt_mailstep_sync_inventory_recurrence', 'hourly');
  • $recurrence (string) How often the event should subsequently repeat. You can find the permitted values in the wp_get_schedules() function.

The filter is located in the file includes/class-kbnt-mailstep-inventory-sync.php.


The filter lets you select a single warehouse to be used for the Mailstep stock status synchronization. You can find the Store ID either from Mailstep or in the log. After a change, clear the synchronization cache.

apply_filters('kbnt_mailstep_sync_only_store_id', "")
  • $store_id (string) The warehouse ID.

The filter is located in the file includes/class-kbnt-mailstep-inventory-sync.php.


kbnt_mailstep_unreleased_stock_order_statuses

Section titled “kbnt_mailstep_unreleased_stock_order_statuses”

This setting lets you work with “blocked” stock, i.e. it adds goods not yet released by Mailstep to the shop’s stock level and thus prevents artificially inflating the stock. By default it contains “Pending payment” (Pending), “On hold” (On hold) and “Mailstep – Input error”, but you can adjust them this way. After adjusting, you must clear the stock cache.

apply_filters('kbnt_mailstep_unreleased_stock_order_statuses', ['wc-pending', 'wc-inputerror', 'wc-on-hold']);
  • $statuses (array) Order statuses

The filter is located in the file includes/class-kbnt-mailstep-inventory-sync.php.


The filter lets you skip an order item (product) so that it isn’t sent to Mailstep. Return true to skip the given item. It’s used, for example, by the WooCommerce Product Bundles integration to omit the bundle’s parent product.

apply_filters('kbnt_mailstep_skip_order_item', false, $product);
  • $skip (bool) Whether to skip the item (default false).
  • $product (WC_Product) The order item’s product.

The filter is located in the file includes/class-kbnt-mailstep-api.php.


The filter sets the time limit (in seconds) for requests to the Mailstep API.

apply_filters('kbnt_mailstep_api_timeout', 90);
  • $timeout (int) The time limit in seconds (default 90).

The filter is located in the file includes/class-kbnt-mailstep-api.php.


kbnt_mailstep_get_order_id_from_order_number

Section titled “kbnt_mailstep_get_order_id_from_order_number”

The filter lets you customize how a WooCommerce order ID is looked up from an order number in Mailstep – useful with custom order numbering.

apply_filters('kbnt_mailstep_get_order_id_from_order_number', $order_id, $order_number);
  • $order_id (int|false) The looked-up order ID.
  • $order_number (string) The order number from Mailstep.

The filter is located in the file includes/admin/wc-tools.php.


The filter determines how many days back are searched when pulling order statuses from Mailstep (Mailstep only allows filtering by date). The default value is 30 days; the “Mailstep – force update order status” action is hidden for older orders.

apply_filters('kbnt_mailstep_status_lookback_days', 30);
  • $days (int) The number of days back (default 30).

The filter is located in the file kybernaut-mailstep.php.


The filter returns the product statuses that are included in product queries (e.g. during stock synchronization).

apply_filters('kbnt_mailstep_allowed_product_statuses', ['publish', 'draft', 'private']);
  • $statuses (array) Product statuses (default publish, draft, private).

The filter is located in the file includes/class-kbnt-mailstep-products.php.


kbnt_mailstep_order_failed_to_send_notification_recipient

Section titled “kbnt_mailstep_order_failed_to_send_notification_recipient”

The filter returns the recipients of the admin e-mail notification that is sent when an order fails to be sent to Mailstep.

apply_filters('kbnt_mailstep_order_failed_to_send_notification_recipient', [get_option('admin_email')]);
  • $recipients (array) An array of e-mail addresses (default: the administrator’s e-mail).

The filter is located in the file includes/add-order-status.php.


The filter returns the mapping of numeric Mailstep statuses (0–14) to WooCommerce order status slugs.

apply_filters('kbnt_mailstep_order_statuses_pairs', $statuses);
  • $statuses (array) An array in the form Mailstep ID → WooCommerce status slug.
add_filter('kbnt_mailstep_order_statuses_pairs', function ($statuses) {
$keep_statuses = ['cancelled', 'refunded', 'completed', 'inputerror'];
foreach ($statuses as $key => $value) {
if (!in_array($value, $keep_statuses)) {
unset($statuses[$key]);
}
}
$statuses[4] = 'completed';
return $statuses;
});

The filter is located in the file kybernaut-mailstep.php.


Actions (hooks) – the following items let you attach your own code to the plugin’s events using add_action().


kbnt_mailstep_status_get_process_order_by_order

Section titled “kbnt_mailstep_status_get_process_order_by_order”

The action runs for each order when pulling statuses from Mailstep and is the main extension point for processing an order status. By default, status mapping, handling of the intermediate “On the way” status, and blocking of order cancellation are hooked onto it (priorities 10/20/30).

do_action('kbnt_mailstep_status_get_process_order_by_order', $order, $mailstep_status);
  • $order (WC_Order) The order.
  • $mailstep_status (stdClass) The status object from Mailstep.
add_action('kbnt_mailstep_status_get_process_order_by_order', function ($order, $mailstep_status) {
if ((int) $mailstep_status->status_id === 10) {
$order->add_order_note('Mailstep status 10 received.');
}
}, 40, 2);

The action is located in the file kybernaut-mailstep.php.


The action runs with the shipment’s tracking number (tracking ID) obtained from Mailstep, so you can work with it further – for example, save it to the order.

do_action('kbnt_mailstep_add_tracking_id', $tracking_id, $order);
  • $tracking_id (string) The shipment’s tracking number from Mailstep.
  • $order (WC_Order) The order.
add_action('kbnt_mailstep_add_tracking_id', function ($tracking_id, $order) {
if (class_exists('WC_Shipment_Tracking_Api')) {
WC_Shipment_Tracking_Api::add_tracking_number($order->get_id(), $tracking_id, 'mailstep', current_time('mysql'), '');
}
}, 100, 2);

The action is located in the file includes/class-kbnt-mailstep-orders.php.


kbnt_mailstep_inventory_sync_update_product_stock

Section titled “kbnt_mailstep_inventory_sync_update_product_stock”

The action runs for each product during stock synchronization from Mailstep (after a stock change is detected).

do_action('kbnt_mailstep_inventory_sync_update_product_stock', $product, $new_stock, $parent_id);
  • $product (WC_Product) The product (or variation).
  • $new_stock (int) The new stock level.
  • $parent_id (int|false) The parent product’s ID for variations, otherwise false.
add_action('kbnt_mailstep_inventory_sync_update_product_stock', function ($product, $new_stock, $parent_id) {
// Custom handling after a product stock update.
}, 10, 3);

The action is located in the file includes/class-kbnt-mailstep-inventory-sync.php.


The action runs when an order fails to be sent to Mailstep (e.g. an API error or no response).

do_action('kbnt_mailstep_order_failed_to_send', $order, $error_message);
  • $order (WC_Order) The order.
  • $error_message (string) A description of the error.

The action is located in the file includes/class-kbnt-mailstep-api.php.

Was this page helpful?