Plugin Page

WooCommerce Slovenská Pošta — BalíkoBOX, Balík na Poštu

View Plugin

Developer Reference

The plugin is designed with extensibility in mind. Developers can customize behavior through:

  • Hooks & Filters – Action and filter hooks for shipping cost calculation, pickup point queries, order address overrides, tracking, ePH shipment generation, and low-level API requests.
  • Template Reference – Overridable PHP templates for the checkout pickup point selector and dialog.

Text Domain

All translatable strings use the text domain wcsp.

__( 'Select pickup point', 'wcsp' );
_e( 'My Location', 'wcsp' );

Translation files (.po/.mo) are stored in the languages/ directory of the plugin. The plugin is fully translatable using standard WordPress i18n tools (Loco Translate, Poedit, etc.).


Plugin Class Structure

ClassFileRole
WCSP_WooCommerce_Slovenska_Postawoocommerce-slovenska-posta.phpBootstrap, license gate, enqueue scripts
WCSP_Admin_Settingsincludes/admin/class-admin-settings.phpSettings page rendering and save
WCSP_Shipping_Methodsincludes/class-shipping-methods.phpRegister shipping method classes
WCSP_Balik_Na_Postu_Shipping_Methodincludes/shipping-methods/balik-na-postu.phpBNP shipping calculation
WCSP_BalikoBOX_Shipping_Methodincludes/shipping-methods/balikobox.phpBBOX shipping calculation
WCSP_Checkoutincludes/class-checkout.phpCheckout UI injection and order validation
WCSP_Blocks_Integrationincludes/class-blocks-integration.phpWooCommerce Blocks integration bootstrap
WCSP_Checkout_Block_Integrationincludes/class-blocks-checkout-integration.phpCheckout block integration for pickup point fields
WCSP_Pickup_Pointsincludes/class-pickup-points.phpDatabase queries and data access
WCSP_Ajax_Handlersincludes/class-ajax-handlers.phpWordPress AJAX action handlers
WCSP_Order_Displayincludes/class-order-display.phpPickup point display on orders and emails
WCSP_Trackingincludes/class-tracking.phpTracking metaboxes, sync, and customer/email output
WCSP_Tracking_APIincludes/class-tracking-api.phpTracking API client and event normalization
WCSP_EPH_Managerincludes/class-eph-manager.phpePH admin workflows, bulk actions, and shipment creation
WCSP_EPH_APIincludes/class-eph-api.phpLow-level ePH REST client
WCSP_EPH_Loggerincludes/class-eph-logger.phpPersistent ePH request logging
WCSP_Package_Validatorincludes/class-package-validator.phpDimension validation logic
WCSP_Box_Packerincludes/class-box-packer.phpBin-packing algorithm
WCSP_Cronincludes/class-cron.phpScheduled update management
WCSP_Licenseincludes/class-license-manager.phpLicense validation and caching

PHP Requirements

  • PHP 8.1+ – the plugin uses PHP 8.1 language features including enums, readonly properties, and typed arguments.

Hooks & Filters

Action Hooks

Shipping Calculation

wcsp_before_calculate_shipping_bnp

Fires before the Balík na Poštu shipping cost is calculated.

add_action( 'wcsp_before_calculate_shipping_bnp', function( $package ) {
    // $package = WooCommerce package array
} );

wcsp_before_calculate_shipping_bbox

Fires before the BalikoBOX shipping cost is calculated.

add_action( 'wcsp_before_calculate_shipping_bbox', function( $package ) {
    // $package = WooCommerce package array
} );

Pickup Point Validation (Classic Checkout)

wcsp_before_validate_pickup_point_selection

Fires before server-side pickup point validation runs during classic checkout.

add_action( 'wcsp_before_validate_pickup_point_selection', function( $chosen_service ) {
    // $chosen_service = string — 'BNP' or 'BBOX'
} );

wcsp_validate_pickup_point_selection

Fires after the pickup point has passed built-in validation. Use this to add custom validation.

add_action( 'wcsp_validate_pickup_point_selection', function( $selected_pp, $chosen_service ) {
    // $selected_pp    = array — selected pickup point session data
    // $chosen_service = string — 'BNP' or 'BBOX'
    // Call wc_add_notice( 'message', 'error' ) to block the order
}, 10, 2 );

Pickup Point Validation (Block Checkout)

wcsp_before_validate_pickup_point_block_checkout

Fires before validation runs during a WooCommerce Blocks checkout submission.

add_action( 'wcsp_before_validate_pickup_point_block_checkout', function( $order, $request, $chosen_service ) {
    // $order          = WC_Order
    // $request        = WP_REST_Request
    // $chosen_service = string — 'BNP' or 'BBOX'
}, 10, 3 );

wcsp_validate_pickup_point_block_checkout

Fires after built-in block checkout validation passes. Use this to add custom validation.

add_action( 'wcsp_validate_pickup_point_block_checkout', function( $selected_pp, $order, $request ) {
    // $selected_pp = array — selected pickup point session data
    // $order       = WC_Order
    // $request     = WP_REST_Request
}, 10, 3 );

Order Processing

wcsp_apply_pickup_point_to_order

Fires after the pickup point data has been written to the order (meta saved, address overridden if configured).

add_action( 'wcsp_apply_pickup_point_to_order', function( $order, $selected_pp ) {
    // $order       = WC_Order
    // $selected_pp = array — pickup point session data
}, 10, 2 );

Order Display

wcsp_before_pickup_point_email_display / wcsp_after_pickup_point_email_display

Fire before and after the pickup point section is rendered in order emails.

add_action( 'wcsp_before_pickup_point_email_display', function( $order, $pickup_point_id, $sent_to_admin, $plain_text ) {
    // $order           = WC_Order
    // $pickup_point_id = int
    // $sent_to_admin   = bool
    // $plain_text      = bool
}, 10, 4 );

wcsp_before_pickup_point_admin_display / wcsp_after_pickup_point_admin_display

Fire before and after the pickup point section is rendered in the WP-Admin order edit page.

add_action( 'wcsp_before_pickup_point_admin_display', function( $order, $pickup_point_id ) {
    // $order           = WC_Order
    // $pickup_point_id = int
}, 10, 2 );

wcsp_before_pickup_point_order_details_display / wcsp_after_pickup_point_order_details_display

Fire before and after the pickup point section is rendered on the Thank You page and My Account order view.

add_action( 'wcsp_before_pickup_point_order_details_display', function( $order, $pickup_point_id ) {
    // $order           = WC_Order
    // $pickup_point_id = int
}, 10, 2 );

Database Import

wcsp_before_import_from_xml / wcsp_after_import_from_xml

Fire before and after a pickup point XML import runs.

add_action( 'wcsp_before_import_from_xml', function( $local_file ) {
    // $local_file = string — absolute path to the XML file being imported
} );

add_action( 'wcsp_after_import_from_xml', function( $local_file, $parsed_data ) {
    // $local_file  = string — absolute path to the XML file
    // $parsed_data = array — all parsed pickup point rows
}, 10, 2 );

AJAX

wcsp_before_save_selected_pickup_point

Fires before a pickup point selection is saved to the WooCommerce session.

add_action( 'wcsp_before_save_selected_pickup_point', function( $pp_id, $pp_details ) {
    // $pp_id     = int   — pickup point database ID
    // $pp_details = object — full pickup point record from the database
}, 10, 2 );

wcsp_before_save_widget_pickup_point

Fires before a pickup point selected from the frontend widget is saved to the WooCommerce session.

add_action( 'wcsp_before_save_widget_pickup_point', function( $widget_id, $label, $chosen_service ) {
    // $widget_id      = string
    // $label          = string — widget label shown to the customer
    // $chosen_service = string — 'BNP' or 'BBOX'
}, 10, 3 );

ePH Admin UI

wcsp_before_eph_metabox_fields / wcsp_after_eph_metabox_fields

Fire before and after the ePodaci Harok fields are rendered in the admin order metabox.

wcsp_before_eph_metabox_fields receives $order, $eph_values, and $pickup_point.

wcsp_after_eph_metabox_fields receives the same values plus a $state array with sheet_id, parcel_id, parcel_number, label_url, registered, and is_configured.

add_action( 'wcsp_after_eph_metabox_fields', function( $order, $eph_values, $pickup_point, $state ) {
    // $order        = WC_Order
    // $eph_values   = array — current ePH values for the order
    // $pickup_point = array — pickup point summary, or an empty array
    // $state        = array — current shipment state
}, 10, 4 );

wcsp_eph_admin_assets_enqueued

Fires after the ePH admin assets and localized script data have been enqueued.

add_action( 'wcsp_eph_admin_assets_enqueued', function( $hook, $script_data ) {
    // $hook        = string — current WP-Admin screen hook
    // $script_data = array  — localized data passed to wcsp-eph-admin.js
}, 10, 2 );

wcsp_before_save_eph_order_values / wcsp_after_save_eph_order_values

Fire before and after the order-level ePH values are saved from the admin metabox.

add_action( 'wcsp_before_save_eph_order_values', function( $order, $values, $data, $defaults ) {
    // $order    = WC_Order
    // $values   = array — sanitized values about to be saved
    // $data     = array — raw request data
    // $defaults = array — default values for the order
}, 10, 4 );

ePH Shipment Lifecycle

wcsp_eph_before_create_shipment / wcsp_eph_after_create_shipment

Fire immediately before the plugin creates an ePH shipment and after the sheet and parcel have been created.

add_action( 'wcsp_eph_after_create_shipment', function( $order, $sheet_id, $parcel_id, $parcel_number, $parcel_data, $sheet_result, $parcel_result ) {
    // $order         = WC_Order
    // $sheet_id      = string
    // $parcel_id     = string
    // $parcel_number = string
    // $parcel_data   = array — payload sent to the add parcel endpoint
}, 10, 7 );

wcsp_eph_before_finalize_shipment / wcsp_eph_after_finalize_shipment

Fire before shipment registration starts and after the full finalize workflow has completed.

add_action( 'wcsp_eph_after_finalize_shipment', function( $order, $result, $args ) {
    // $order  = WC_Order
    // $result = array — result payload returned by finalize_order_shipment()
    // $args   = array — normalized finalize arguments
}, 10, 3 );

wcsp_eph_after_register_sheet

Fires after the sheet has been successfully registered with the ePH API.

add_action( 'wcsp_eph_after_register_sheet', function( $order, $sheet_id, $register_result, $args ) {
    // $order           = WC_Order
    // $sheet_id        = string
    // $register_result = array — decoded ePH API response
    // $args            = array — finalize arguments
}, 10, 4 );

wcsp_eph_tracking_number_synced

Fires after a newly created ePH parcel number has been copied into the tracking meta fields on the order.

add_action( 'wcsp_eph_tracking_number_synced', function( $order, $parcel_number, $old_tracking ) {
    // $order         = WC_Order
    // $parcel_number = string
    // $old_tracking  = string — previous tracking number, if any
}, 10, 3 );

wcsp_eph_before_label_download / wcsp_eph_after_store_label

Fire before the generated label PDF is downloaded and after it has been stored locally.

add_action( 'wcsp_eph_after_store_label', function( $order, $local_url, $remote_url, $filepath, $data ) {
    // $order      = WC_Order
    // $local_url  = string — public uploads URL for the stored label
    // $remote_url = string — remote label URL returned by the API
    // $filepath   = string — absolute local file path
    // $data       = array  — decoded label response data
}, 10, 5 );

ePH Bulk Processing

wcsp_before_apply_bulk_eph_values / wcsp_after_apply_bulk_eph_values

Fire before and after the shared bulk-dialog values are applied to an individual order.

add_action( 'wcsp_after_apply_bulk_eph_values', function( $order, $bulk_values, $data, $values ) {
    // $order       = WC_Order
    // $bulk_values = array — normalized values from the bulk dialog
    // $data        = array — raw request data
    // $values      = array — existing order ePH values
}, 10, 4 );

wcsp_eph_before_bulk_finalize_order / wcsp_eph_bulk_finalize_order_error / wcsp_eph_after_bulk_finalize_order

Fire around the bulk "Generate ePH Labels" workflow for each order.

add_action( 'wcsp_eph_bulk_finalize_order_error', function( $order, $result, $bulk_data, $existing_mode, $has_existing_eph ) {
    // $order            = WC_Order
    // $result           = WP_Error
    // $bulk_data        = array
    // $existing_mode    = string — 'skip' or 'recreate'
    // $has_existing_eph = bool
}, 10, 5 );

wcsp_before_clear_eph_state / wcsp_after_clear_eph_state

Fire before and after stored ePH shipment state is cleared from an order.

add_action( 'wcsp_before_clear_eph_state', function( $order ) {
    // $order = WC_Order
} );

ePH API Requests

wcsp_eph_before_api_request

Fires immediately before the low-level ePH REST client sends an authenticated request.

add_action( 'wcsp_eph_before_api_request', function( $method, $path, $body, $context, $url, $args ) {
    // $method  = string — GET, PUT, POST, DELETE
    // $path    = string — API path, for example /sheets
    // $body    = array
    // $context = array — caller context, usually order_id and action
    // $url     = string — full request URL
    // $args    = array  — wp_remote_request() arguments
}, 10, 6 );

wcsp_eph_api_request_failed

Fires when wp_remote_request() fails before the ePH API returns an HTTP response.

add_action( 'wcsp_eph_api_request_failed', function( $response, $method, $path, $body, $context, $url, $args, $log_base ) {
    // $response = WP_Error
    // $log_base = array — normalized log payload prepared by the client
}, 10, 8 );

wcsp_eph_after_api_request

Fires after a successful ePH API response has been decoded and normalized.

add_action( 'wcsp_eph_after_api_request', function( $decoded, $method, $path, $body, $context, $url, $args, $http_code, $raw_body, $duration_ms ) {
    // $decoded     = array — decoded API response
    // $http_code   = int
    // $raw_body    = string
    // $duration_ms = int
}, 10, 10 );

Filter Hooks

Shipping Cost

wcsp_shipping_cost_bnp / wcsp_shipping_cost_bbox

Modify the final calculated shipping cost before the rate is added to WooCommerce.

add_filter( 'wcsp_shipping_cost_bnp', function( $cost, $package ) {
    // $cost    = float — calculated shipping cost
    // $package = array — WooCommerce package
    return $cost;
}, 10, 2 );

wcsp_shipping_rate_bnp / wcsp_shipping_rate_bbox

Modify the entire rate array before it is registered with WooCommerce.

add_filter( 'wcsp_shipping_rate_bnp', function( $rate, $package ) {
    // $rate = array — with keys: id, label, cost, taxes, meta_data, etc.
    return $rate;
}, 10, 2 );

Weight Calculation

wcsp_item_weight_for_cost

Modify the weight of a single cart item before it is added to the total weight for cost calculation.

add_filter( 'wcsp_item_weight_for_cost', function( $weight, $product, $item, $package ) {
    // $weight  = float      — raw product weight (before quantity multiplication)
    // $product = WC_Product
    // $item    = array      — WooCommerce cart item
    // $package = array      — WooCommerce package
    return $weight;
}, 10, 4 );

wcsp_total_weight_for_cost_bnp / wcsp_total_weight_for_cost_bbox

Modify the total cart weight used in the shipping cost calculation, after all items and instance packing weight have been summed.

add_filter( 'wcsp_total_weight_for_cost_bnp', function( $total_weight, $cart_weight, $packing_weight, $package ) {
    // $total_weight   = float — cart_weight + packing_weight
    // $cart_weight    = float — sum of all item weights
    // $packing_weight = float — instance-level packing material weight
    // $package        = array — WooCommerce package
    return $total_weight;
}, 10, 4 );

Dimension Validation

wcsp_bnp_valid_dimensions / wcsp_bbox_valid_dimensions

Override whether a product passes dimension validation.

add_filter( 'wcsp_bnp_valid_dimensions', function( $is_valid, $product, $validation, $package ) {
    // $is_valid   = bool       — current validation result
    // $product    = WC_Product
    // $validation = array      — full validation result array
    // $package    = array      — WooCommerce package
    return $is_valid;
}, 10, 4 );

wcsp_bnp_box_packing_result / wcsp_bbox_box_packing_result

Override the result of the bin-packing check.

add_filter( 'wcsp_bnp_box_packing_result', function( $fits, $pack_result, $package ) {
    // $fits        = bool  — whether items fit in the box
    // $pack_result = array — full packing result from WCSP_Box_Packer
    // $package     = array — WooCommerce package
    return $fits;
}, 10, 3 );

AJAX Response Filters

wcsp_ajax_pickup_point_details

Modify the pickup point details array returned by the wcsp_pp_get_pp_details AJAX action.

add_filter( 'wcsp_ajax_pickup_point_details', function( $response, $pp_id ) {
    // $response = array — full details array (id, name, address, opening_hours, etc.)
    // $pp_id    = int
    return $response;
}, 10, 2 );

wcsp_ajax_search_pickup_points

Modify the search results array returned by the wcsp_pp_search_pp AJAX action.

add_filter( 'wcsp_ajax_search_pickup_points', function( $results, $search ) {
    // $results = array  — array of pickup point result arrays
    // $search  = string — the search term used
    return $results;
}, 10, 2 );

wcsp_ajax_closeby_pickup_points

Modify the nearby results array returned by the wcsp_pp_get_closeby_pp AJAX action.

add_filter( 'wcsp_ajax_closeby_pickup_points', function( $results, $lat, $lng ) {
    // $results = array — array of nearby pickup point result arrays (with distance field)
    // $lat     = float
    // $lng     = float
    return $results;
}, 10, 3 );

wcsp_selected_pickup_point_session_data

Modify the data stored in the WooCommerce session when a pickup point is confirmed.

add_filter( 'wcsp_selected_pickup_point_session_data', function( $session_data ) {
    // $session_data = array — data to be stored in WC session
    return $session_data;
} );

wcsp_selected_widget_pickup_point_session_data

Modify the data stored in the WooCommerce session when a widget-selected pickup point is confirmed.

add_filter( 'wcsp_selected_widget_pickup_point_session_data', function( $session_data ) {
    // $session_data = array - data to be stored in WC session
    return $session_data;
} );

Checkout Address Overrides

wcsp_should_override_shipping_address / wcsp_replace_shipping_address_on_order

Control whether the order shipping address should be replaced with the selected pickup point address.

add_filter( 'wcsp_should_override_shipping_address', function( $should_override, $order, $data ) {
    // $should_override = bool
    // $order           = WC_Order
    // $data            = array - checkout order data
    return $should_override;
}, 10, 3 );

Pickup Point Data Access

wcsp_all_map_markers / wcsp_pickup_points_search_results / wcsp_pickup_points_closeby_results

Modify the raw pickup point result sets returned by the internal data layer for map markers, search, and nearby queries.

add_filter( 'wcsp_pickup_points_search_results', function( $results, $search, $service_code, $exclude_bbox ) {
    // $results      = array
    // $search       = string
    // $service_code = string
    // $exclude_bbox = bool
    return $results;
}, 10, 4 );

wcsp_pickup_point_details / wcsp_can_accept_weight / wcsp_parsed_posta_row

Customize single pickup point records, weight-acceptance checks, and normalized XML import rows before they are used internally.

add_filter( 'wcsp_parsed_posta_row', function( $row, $posta ) {
    // $row   = array - normalized row prepared for insertion
    // $posta = array|SimpleXMLElement - raw source node for the point
    return $row;
}, 10, 2 );

Box Packing & Package Validation

wcsp_box_packer_items / wcsp_bnp_box_dimensions

Customize the normalized item list passed into the internal box-packing algorithm and the virtual Balik na Postu box dimensions used for that validation.

add_filter( 'wcsp_box_packer_items', function( $items, $service ) {
    // $items   = array - normalized box packer items
    // $service = string - 'balikobox' or 'bnp'
    return $items;
}, 10, 2 );

wcsp_meets_minimum_face / wcsp_within_max_balik / wcsp_within_max_expres / wcsp_within_max_lp

Override the low-level dimensional rule checks used by WCSP_Package_Validator.

add_filter( 'wcsp_within_max_lp', function( $within_limit, $length_plus_perimeter ) {
    // $within_limit          = bool
    // $length_plus_perimeter = float
    return $within_limit;
}, 10, 2 );

wcsp_is_skladne / wcsp_is_neskladne / wcsp_product_dimensions / wcsp_validate_product_dimensions_result

Override parcel classification, normalized product dimensions, and the final validation result returned by WCSP_Package_Validator.

add_filter( 'wcsp_validate_product_dimensions_result', function( $result, $length, $width, $height, $is_irregular ) {
    // $result       = array - full validation result
    // $length       = float
    // $width        = float
    // $height       = float
    // $is_irregular = bool
    return $result;
}, 10, 5 );

Admin Settings Defaults

wcsp_bbox_default_length / wcsp_bbox_default_width / wcsp_bbox_default_height

Override the default BalikoBOX maximum dimensions shown in plugin settings before the merchant saves custom values.

add_filter( 'wcsp_bbox_default_length', function( $default_length ) {
    // $default_length = int|float
    return $default_length;
} );

ePH Configuration

wcsp_eph_allowed_parcel_categories / wcsp_eph_parcel_category_labels / wcsp_eph_allowed_payment_types / wcsp_eph_payment_type_labels / wcsp_eph_allowed_parcel_classes / wcsp_eph_parcel_class_labels / wcsp_eph_allowed_service_codes / wcsp_eph_service_labels

Control which ePH parcel categories, payment types, parcel classes, and service codes are available in the admin UI and how they are labeled.

add_filter( 'wcsp_eph_service_labels', function( $labels ) {
    // $labels = array - service code => label
    return $labels;
} );

wcsp_eph_is_configured / wcsp_eph_admin_script_data / wcsp_eph_bulk_actions

Override the plugin’s ePH readiness check, the localized admin JavaScript data, and the registered WooCommerce bulk actions.

add_filter( 'wcsp_eph_admin_script_data', function( $script_data, $hook ) {
    // $script_data = array
    // $hook        = string - current WP-Admin screen hook
    return $script_data;
}, 10, 2 );

ePH Order & Shipment Data

wcsp_eph_order_weight / wcsp_eph_detect_cod / wcsp_eph_order_defaults / wcsp_eph_order_values / wcsp_eph_sanitized_order_values

Control how default ePH values are calculated for an order, how COD is detected, and how metabox values are normalized before they are stored.

add_filter( 'wcsp_eph_sanitized_order_values', function( $values, $order, $data, $defaults ) {
    // $values   = array - sanitized values about to be saved
    // $order    = WC_Order
    // $data     = array - raw request data
    // $defaults = array
    return $values;
}, 10, 4 );

wcsp_eph_metabox_html / wcsp_eph_order_list_summary_data / wcsp_eph_bulk_dialog_defaults / wcsp_eph_bulk_order_values / wcsp_eph_bulk_results

Customize the rendered metabox HTML, order-list summary data, bulk-dialog defaults, per-order bulk values, and aggregated bulk results.

add_filter( 'wcsp_eph_bulk_results', function( $results, $order_ids, $bulk_data, $existing_mode ) {
    // $results       = array
    // $order_ids     = int[]
    // $bulk_data     = array
    // $existing_mode = string - 'skip' or 'recreate'
    return $results;
}, 10, 4 );

wcsp_eph_sender_data / wcsp_eph_recipient_data / wcsp_eph_reception_method / wcsp_eph_parcel_data / wcsp_eph_finalize_shipment_args / wcsp_eph_finalize_shipment_result / wcsp_eph_services_before_enforcement / wcsp_eph_services

Modify the sender, recipient, service codes, and final request payloads used during shipment creation and registration.

add_filter( 'wcsp_eph_parcel_data', function( $parcel_data, $order, $values, $sheet_id, $sender ) {
    // $parcel_data = array
    // $order       = WC_Order
    // $values      = array
    // $sheet_id    = string
    // $sender      = array
    return $parcel_data;
}, 10, 5 );

ePH Label & API Filters

wcsp_eph_label_remote_url / wcsp_eph_label_download_args / wcsp_eph_label_subdir / wcsp_eph_label_filename

Modify the remote label PDF URL, the download arguments, and the local storage path and filename used for saved labels.

add_filter( 'wcsp_eph_label_filename', function( $filename, $order, $data, $parcel_number ) {
    // $filename      = string
    // $order         = WC_Order
    // $data          = array
    // $parcel_number = string
    return $filename;
}, 10, 4 );

wcsp_eph_api_base_url / wcsp_eph_api_request_url / wcsp_eph_api_request_args / wcsp_eph_api_invalid_response_message / wcsp_eph_api_error_message / wcsp_eph_api_response_data / wcsp_eph_api_validation_reason_labels

Modify low-level ePH API request URLs, request arguments, error messages, decoded response data, and the labels used for validation reason codes.

add_filter( 'wcsp_eph_api_response_data', function( $decoded, $method, $path, $body, $context, $http_code, $raw_body ) {
    // $decoded   = array
    // $method    = string
    // $path      = string
    // $body      = array
    // $context   = array
    // $http_code = int
    // $raw_body  = string
    return $decoded;
}, 10, 7 );

Tracking

Tracking Actions

wcsp_tracking_synced

Fires after a successful background sync for an order.

add_action( 'wcsp_tracking_synced', function( $order, $events ) {
    // $order  = WC_Order
    // $events = array — normalized events array (newest first)
}, 10, 2 );

wcsp_before_tracking_email / wcsp_after_tracking_email

Fire before and after the tracking section is rendered in an order email.

add_action( 'wcsp_before_tracking_email', function( $order, $tracking_number, $plain_text ) {
    // $order           = WC_Order
    // $tracking_number = string
    // $plain_text      = bool
}, 10, 3 );

Tracking Filters

wcsp_tracking_api_endpoint

Override the API endpoint URL used to fetch tracking events.

add_filter( 'wcsp_tracking_api_endpoint', function( $url ) {
    // $url = string — default: https://api.posta.sk/tracking?q=...&l=...&p=1
    return $url;
} );

wcsp_tracking_status_map

Customize the mapping of raw Slovenská Pošta API status codes to generic categories.

add_filter( 'wcsp_tracking_status_map', function( $map ) {
    // $map = array — status_code => category string
    // Built-in categories: registered, accepted, in_transit, out_for_delivery,
    //                      stored_at_post, delivered, failed, returned
    $map['MY_CUSTOM_CODE'] = 'in_transit';
    return $map;
} );

wcsp_tracking_category_labels

Customize the display labels for each tracking category.

add_filter( 'wcsp_tracking_category_labels', function( $labels ) {
    // $labels = array — category => translated label string
    $labels['stored_at_post'] = 'Ready at your post office';
    return $labels;
} );

wcsp_tracking_normalized_events

Filter the parsed events array after it has been normalized from the raw API response, before it is cached on the order.

add_filter( 'wcsp_tracking_normalized_events', function( $events, $raw ) {
    // $events = array — normalized events (newest first)
    // $raw    = array — raw decoded API response
    return $events;
}, 10, 2 );

wcsp_tracking_progress_steps

Customize the steps shown in the 5-step progress bar on customer-facing order pages.

add_filter( 'wcsp_tracking_progress_steps', function( $steps, $events, $order ) {
    // $steps  = array — ordered steps, each: ['id', 'label', 'active', 'date']
    // $events = array — cached events
    // $order  = WC_Order
    return $steps;
}, 10, 3 );

wcsp_tracking_email_ids

Control which WooCommerce email IDs receive the tracking section.

add_filter( 'wcsp_tracking_email_ids', function( $ids ) {
    // Default: ['customer_processing_order', 'customer_completed_order', 'customer_on_hold_order']
    $ids[] = 'customer_invoice';
    return $ids;
} );

Template Reference

The plugin provides two PHP templates that can be overridden in your theme. Template overriding follows the same convention as WooCommerce templates: copy the file to your theme’s directory and modify it there.


Template Override Path

Copy templates to your theme directory using this structure:

your-theme/
└── woocommerce-slovenska-posta/
    ├── checkout-pickup-point-select.php
    └── checkout-pickup-point-select-dialog.php

The plugin checks for theme overrides using locate_template() before loading from its own templates/ directory.


Templates

checkout-pickup-point-select.php

Plugin path: templates/checkout-pickup-point-select.php Theme override path: your-theme/woocommerce-slovenska-posta/checkout-pickup-point-select.php

Purpose: Renders the inline pickup point selector shown below the shipping method at checkout. In the default implementation, this contains the "Select Pickup Point" / "Change" button and the display of the currently selected pickup point name.

Available variables:

VariableTypeDescription
$selected_pickup_pointarraynullCurrently selected pickup point data from the WC session, or null if none selected
$shipping_methodWC_Shipping_RateThe current shipping rate object

Default output:

<div class="wcsp-pickup-point-selector">
    <button id="wcsp-pp-toggle" type="button" class="button">
        Select Pickup Point
    </button>
</div>

When a pickup point is selected, the button text changes to the pickup point name with a "Change" link.


checkout-pickup-point-select-dialog.php

Plugin path: templates/checkout-pickup-point-select-dialog.php Theme override path: your-theme/woocommerce-slovenska-posta/checkout-pickup-point-select-dialog.php

Purpose: Renders the HTML structure of the pickup point picker modal dialog. The JavaScript initializes the map, search, and interaction within this HTML structure.

Important: The element IDs and class names in this template are referenced by the JavaScript. If you rename them in your override, you must also update assets/js/wcsp-pp-checkout.js accordingly.

Key element IDs used by JavaScript:

Element IDPurpose
#wcsp-pp-dialogThe root dialog container (jQuery UI Dialog target)
#wcsp-pp-searchSearch text input
#wcsp-pp-search-btnSearch button
#wcsp-pp-geolocation-btn"My Location" geolocation button
#wcsp-pp-resultsResults list container
#wcsp-pp-mapOpenLayers map container
#wcsp-pp-detailsSelected pickup point details panel
#wcsp-pp-confirm-btnConfirm selection button
#wcsp-pp-dialog-closeClose dialog button

Default structure:

<div id="wcsp-pp-dialog" style="display:none;">
    <div class="wcsp-dialog-header">
        <button id="wcsp-pp-dialog-close">×</button>
    </div>
    <div class="wcsp-dialog-body">
        <div class="wcsp-dialog-left">
            <div class="wcsp-search-bar">
                <input id="wcsp-pp-search" type="text" placeholder="Search..." />
                <button id="wcsp-pp-search-btn">Search</button>
                <button id="wcsp-pp-geolocation-btn">My Location</button>
            </div>
            <div id="wcsp-pp-results"></div>
        </div>
        <div class="wcsp-dialog-right">
            <div id="wcsp-pp-map"></div>
            <div id="wcsp-pp-details"></div>
        </div>
    </div>
</div>

Stylesheets

The plugin’s frontend styles are loaded from assets/css/wcsp-pp-checkout.css. This file is enqueued on checkout pages and cannot be overridden via the template system. To customize styles:

  1. Add CSS rules in your theme that override the plugin’s classes.
  2. Use specificity or !important if needed to override the plugin’s defaults.

Key CSS classes:

ClassPurpose
.wcsp-pickup-point-selectorWrapper around the inline selector button
.wcsp-dialog-leftLeft panel of the dialog (search + results)
.wcsp-dialog-rightRight panel (map + details)
.wcsp-result-itemIndividual result in the search list
.wcsp-result-item.selectedCurrently selected result item
.wcsp-weight-warningWeight warning badge on a result item
.wcsp-result-item.weight-exceededGrayed-out item when weight limit exceeded
.wcsp-shipping-fields-hiddenApplied to hide shipping address fields