=== Lagersystem.dk: Parcelpickup locator for Woocommerce ===
Contributors: lagersystem
Version: 2.0.12
Donate link: https://lagersystem.dk
Tags: shipping, parcel pickup
Requires at least: 6.5
Requires PHP: 7.4
Requires Plugins: woocommerce
Tested up to: 7.1.2
Stable tag: 2.0.12
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Let customers choose a parcel pickup point on a map during WooCommerce checkout. Supports PostNord, GLS, Bring, DHL, UPS and DAO.

== Description ==

Enables customer to choose pickup point in woocommerce checkout flow with google maps interface. Shows points name, address and opening hours. Saves the points data to order and sets pickup point ID as extra field in woocommerce order.
Plugin supports carriers: PostNord, GLS, Bring, DHL, UPS and DAO. Is compatable with default woocommerce shipping and flexible shipping plugin.

== Installation ==

1. Install plugin from Wordpress repos.
2. Go to the Settings menu in your WordPress admin and select LS Parcelpickup.
3. Insert the API key for Lagersystem (there is a link to get an API key at the top of the page).
4. Insert your Google Maps API key.
5. (Optional) If you use DHL, DAO, UPS or Bring you should input the necessary data as well. For GLS or PostNord, no additional data is needed.
6. Go to your WooCommerce settings and go to the Shipping tab.
7. Edit your pickup-enabled shipping methods and make sure you add the correct carrier in the Transportør til udleveringssted dropdown. Do this for all relevant shipping metods.
8. Use the WooCommerce Checkout block or the classic checkout shortcode [woocommerce_checkout]. The pickup chooser appears automatically for configured shipping methods.
9. Test a pickup order on your webshop before enabling it for customers.


== Compatibility ==

Validated with WordPress 7.1.2 and WooCommerce 11.1.2 on PHP 8.3.
Supports both High-Performance Order Storage (HPOS) and legacy order storage.
Supports classic checkout ([woocommerce_checkout]) and WooCommerce Checkout Blocks.
Blocks suggest nearby pickup points using the shipping address and preserve the shipping recipient.
Customers can change the suggestion using the existing map/list chooser. Selection occurs at checkout, not in the Cart block.
The pickup address is saved on the order; the customer’s cart address and billing address stay intact.
One pickup point is stored per order using the existing Pakkeshop metadata. Blocks reject pickup
when the order has multiple shipping packages; ordinary home delivery still works. Classic checkout
continues to handle the first shipping package and uses the billing address.
Live carrier responses and Google Maps require valid API credentials and a staging checkout test.

== Development tests ==

JavaScript regressions (Node.js 22): npm ci --prefix tests && npm test --prefix tests
PHP integration (disposable WordPress installation with WooCommerce and this plugin active):
wp eval-file wp-content/plugins/lagersystem-parcelpickup-woocommerce/tests/integration.php
wp eval-file wp-content/plugins/lagersystem-parcelpickup-woocommerce/tests/blocks-api.php
Run with woocommerce_custom_orders_table_enabled set to both no and yes, and
woocommerce_custom_orders_table_data_sync_enabled set to no, using a fresh process each time.
wp eval-file wp-content/plugins/lagersystem-parcelpickup-woocommerce/tests/ajax.php
The AJAX test mocks the carrier HTTP response; it does not need API credentials.
GitLab CI runs PHP lint, checkout regressions, and classic/Store API integration tests on
WordPress 6.5 / WooCommerce 8.2.0 and WordPress 7.1.2 / WooCommerce 11.1.2, with HPOS off and on.
The test scripts change options and create/delete test orders. Use a disposable database only.

Browser tests (disposable site only):
1. Run wp eval-file wp-content/plugins/lagersystem-parcelpickup-woocommerce/tests/fixtures/blocks-setup.php.
2. From the site's root, run mkdir -p wp-content/mu-plugins/, then copy this plugin's tests/fixtures/blocks-service.php into that directory.
3. Run npm ci --prefix tests and npx --prefix tests playwright install chromium.
4. Run PICKUP_TEST_URL=http://your-test-site PICKUP_TEST_PRODUCT=<fixture-product-id> PICKUP_TEST_CHECKOUT=<checkout-page-id> npm run test:browser --prefix tests.
   PICKUP_CHROME_CHANNEL=chrome uses an installed Chrome instead of Playwright Chromium.
The browser tests use fixture carrier responses and a Google Maps stub, plus a Maps-unavailable scenario.
Remove the fixture plugin with the disposable site. Production release archives exclude all tests.

== Frequently Asked Questions ==

= What carriers are supported? =

Currently PostNord, GLS, Bring, DHL and DAO.

= Can i use Flexible Shipping? =

Yes, parcel pickup settings are added directly to flexible shipping.

= Is it completly free to use? =

Yes, does require a free API Key from lagersystem.dk to use their service. You will also need an Google Maps API key.

= What countries are supported? =

Currently only Danish is supported.

== Screenshots ==

1. Shows automatic selection from customer address. Automaticly chooses closest to address.
2. Shows customer ui for changing point from maps interface.

== Changelog ==

= Unreleased =
* Add automatic pickup suggestions and the map/list chooser to WooCommerce Checkout Blocks.
* Verify Store API pickup selections and save the shipping recipient, pickup address and Pakkeshop ID.
* Preserve customer addresses during payment retries and reject ambiguous split-package pickup orders.
* Add frontend, Store API and browser coverage for Blocks and classic checkout.


= Unreleased =
* Added Danish setup guidance and round help icons in admin settings and checkout.
* Updated compatibility for WordPress 7.1.2 and WooCommerce 11.1.2.
* Use WooCommerce order APIs for HPOS-compatible pickup metadata and admin display.
* Validate pickup IDs against server-held carrier results and use the API address.
* Check the resolved shipping method even when it is omitted from the submitted form.
* Clear old pickup metadata when a pending order is retried with home delivery.
* Ignore delayed popup responses after changing shipping method or address.
* Stop release publishing when an SVN or file-copy operation fails.
* Preserve manually selected pickup points across checkout fragment refreshes.
* Fix missing-session handling, full shipping-rate IDs, and map initialization after refreshes.
* Protect lookup requests with a nonce and handle carrier failures without caching errors.
* Declare classic checkout requirements and add automated compatibility tests.


= 2.0.10 =
* Fixed PHP warning on checkout page when ordering non-shipment products

= 2.0 =
* Support for UPS
* Enter in checkout form will now submit form, and not open location picker
* Now works with only one shipment method
* Validation added to prevent submission without location selected.
* Close button added on mobile/tablet devices

= 1.0 =
* Initial release
