DEV Community

Justas Arbatauskis
Justas Arbatauskis

Posted on

What breaks when you add Baltic parcel lockers to WooCommerce

In Lithuania, Latvia and Estonia, "shipping" usually means a parcel locker. Omniva, DPD and LP Express (Unisend) terminals sit outside every supermarket, and most shoppers pick one by habit — courier delivery is the exception, not the default.

So every WooCommerce store here needs a locker picker at checkout. It sounds like a solved problem: install the carrier plugin, tick a box, done. In practice the same handful of things break every time. This is the list I now check before I promise a client a date.

1. A terminal list is not a shipping method

The carrier gives you a list of terminals — in Lithuania alone that is well over a thousand entries, and across the three Baltic countries several thousand. Two mistakes follow from treating that list casually:

  • Rendering it as a plain <select>. A few thousand <option> elements land in the checkout HTML on every page load. Checkout gets heavier for every customer, including the ones paying by courier.
  • Fetching it live from the carrier API on checkout render. Now your checkout depends on someone else's uptime.

Cache the list and render a searchable field:

function shop_terminals( $country = 'LT' ) {
    $key  = 'shop_terminals_' . $country;
    $data = get_transient( $key );
    if ( false !== $data ) {
        return $data;
    }
    $res = wp_remote_get( TERMINALS_URL, array( 'timeout' => 15 ) );
    if ( is_wp_error( $res ) ) {
        // Stale data beats an empty checkout field.
        return get_option( $key . '_fallback', array() );
    }
    $data = json_decode( wp_remote_retrieve_body( $res ), true );
    set_transient( $key, $data, DAY_IN_SECONDS );
    update_option( $key . '_fallback', $data, false );
    return $data;
}
Enter fullscreen mode Exit fullscreen mode

The _fallback option is the part people skip. Transients expire; carrier APIs have bad mornings. Without a fallback the customer sees an empty dropdown and leaves.

2. Block checkout silently drops the field

This is the one that costs the most time. Many carrier plugins were written for the classic shortcode checkout and hook into woocommerce_review_order_after_shipping or similar. Switch the store to the block-based checkout and the terminal picker is simply not there — no error, no notice, just a missing field and orders arriving without a terminal ID.

Check which checkout the store actually uses before estimating the work. If it is the block checkout, you need a plugin that registers a proper block integration, or you write one. There is no CSS-level workaround.

3. The terminal ID has to survive to the label

The picker sets a value. That value has to travel: session → order meta → admin screen → label API. It breaks at the last two steps most often.

add_action( 'woocommerce_checkout_create_order', function ( $order, $data ) {
    $terminal = isset( $_POST['shop_terminal'] ) ? sanitize_text_field( wp_unslash( $_POST['shop_terminal'] ) ) : '';
    if ( '' !== $terminal ) {
        $order->update_meta_data( '_shop_terminal', $terminal );
    }
}, 10, 2 );
Enter fullscreen mode Exit fullscreen mode

Then put it somewhere a human can see it. The warehouse person packing the order works from the admin order list, not from the API:

add_filter( 'manage_edit-shop_order_columns', function ( $cols ) {
    $cols['shop_terminal'] = 'Terminal';
    return $cols;
} );
Enter fullscreen mode Exit fullscreen mode

(On stores running HPOS the hook names differ — manage_woocommerce_page_wc-orders_columns. Support both if you do not control when the client flips that switch.)

4. Conditional required fields

When a locker is selected, street and house number are meaningless — but WooCommerce still validates them as required for most countries. Customers type "-" into the street field, and that garbage ends up on the shipping label.

Make the address fields conditional on the chosen method, and validate the opposite way: if the method is a locker, a terminal ID is required; if it is courier, the address is. Half-done validation here produces orders you cannot ship without phoning the customer.

5. Free shipping over X, but only for lockers

The business rule is almost always "free to a locker over €50, courier always paid". That is two shipping rates with different free-shipping logic, not one. Also check the tax class on each rate — in the Baltics shipping is taxed, and a rate created by hand often ends up with "standard" when the shop uses a reduced class for some products.

6. Tracking links in the right email

Each carrier has its own tracking URL pattern and its own idea of when a number becomes valid. Put the link into the completed order email, not processing — the number frequently does not resolve yet when the order is marked processing, and a dead tracking link generates support mail.

7. What I test before handing over

  • Order to a locker in each supported country
  • Order by courier, address validated
  • Terminal API unreachable (block it in hosts) — checkout must still work
  • Free shipping threshold at €49.99 and €50.01
  • Label generated from the admin order screen, terminal correct
  • Tracking link opens the carrier page with the real parcel
  • Checkout tested on the block checkout if the store uses it

None of this is hard. It is just longer than the "install plugin, tick box" estimate everyone starts with, and every skipped item turns into a support ticket after launch.


I build and maintain WooCommerce stores in Lithuania at kokybiskasvetaine.lt. There is a Lithuanian version of this topic with local carrier specifics here.

Top comments (0)