Skip to content

feat(checkout): show the right delivery options for business and consumer orders - #1675

Merged
FreekVR merged 2 commits into
mainfrom
feat/capabilities-isbusiness-flag
Aug 5, 2026
Merged

feat(checkout): show the right delivery options for business and consumer orders#1675
FreekVR merged 2 commits into
mainfrom
feat/capabilities-isbusiness-flag

Conversation

@FreekVR

@FreekVR FreekVR commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Business (B2B) and consumer (B2C) orders now get the delivery options that actually apply to them.

Carriers don't offer the same options to businesses as to consumers, but the shop didn't work this out from the order, so the checkout could show options the carrier would refuse later on. It now derives that from the delivery address: a filled-in company name means business, an empty one means consumer. Only the true/false flag goes to MyParcel — never the company name itself, so no extra personal data leaves the shop.

WooCommerce needed no change of its own — its address adapter already sends the company. The behaviour arrives with PDK 4.5.0 and pdk-admin 2.1.0, which turn that company into the flag and carry it through to the carrier capabilities call. A test guards the boundary so the company keeps reaching the PDK as the flag, and keeps not being stored on the cart.

Fixes INT-1690

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
214 1 213 0
View the full list of 1 ❄️ flaky test(s)
src/components/pdk/components.spec.ts::src/components/pdk/components.spec.ts

Flake rate in main: 100.00% (Passed 0 times, Failed 145 times)

Stack Traces | 0s run time
Error: [🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
This will fail in production.
 ❯ Module.useStore ../../../node_modules/@.../pinia/dist/pinia.mjs:1741:19
 ❯ runModalTest ../../../node_modules/@.../src/components/runModalTest.ts:7:44
 ❯ ../../../node_modules/@.../src/tests/executeAdminComponentTest.ts:29:7

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens the WooCommerce→PDK boundary by adding a unit test that proves a cart’s shipping_company influences the derived isBusiness flag in the PDK ShippingAddress, while ensuring the company name itself is not serialized onto the cart-facing address payload. It also updates an existing capabilities stub to match a new PDK method signature.

Changes:

  • Updated the CapabilitiesValidationService test stub to accept the new ?bool $isBusiness parameter in getPackageTypeWeights().
  • Added a unit test asserting that cart company input results in isBusiness=true and that company is not present in the serialized PDK shipping address array.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/Unit/Pdk/Context/Service/WcContextServiceTest.php Updates the capabilities validation stub signature to stay compatible with the updated PDK API.
tests/Unit/Adapter/WcAddressAdapterTest.php Adds coverage for “company → isBusiness” propagation and verifies company is not serialized onto the PDK address.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Unit/Pdk/Context/Service/WcContextServiceTest.php
Comment thread tests/Unit/Adapter/WcAddressAdapterTest.php
@FreekVR
FreekVR marked this pull request as ready for review July 23, 2026 08:18
@FreekVR
FreekVR requested a review from a team as a code owner July 23, 2026 08:18
@myparcel-bot
myparcel-bot Bot force-pushed the feat/capabilities-isbusiness-flag branch from a128f48 to 379bc46 Compare August 5, 2026 09:53
@FreekVR FreekVR changed the title test: cover the business/consumer flag reaching the PDK from a WooCommerce cart feat(checkout): show the right delivery options for business and consumer orders Aug 5, 2026
FreekVR and others added 2 commits August 5, 2026 12:20
…merce cart

adds a test proving a cart's company name reaches the PDK as the isBusiness flag — and that the company itself is not stored on the cart — plus a mock update to match the PDK's new getPackageTypeWeights signature.

WooCommerce needs no production change: its address adapter already sends the company, and the PDK turns it into the flag. The test guards that boundary so it can't silently break.

Depends on myparcelnl/pdk#504 — the assertions rely on the PDK isBusiness flag, so this can merge once a PDK release ships it.

Fixes INT-1690

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Points the plugin at the releases that carry the business/consumer flag.

The PHP tests assert an isBusiness flag on order addresses, which ships in
PDK 4.5.0. The admin needs pdk-admin 2.1.0 so it actually sends that flag
when it loads shipment options. Deduped the myparcel packages afterwards so
pdk-common stays a single copy instead of ending up at both 2.0.0 and 2.1.0.

Fixes INT-1690

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@FreekVR
FreekVR force-pushed the feat/capabilities-isbusiness-flag branch from 8b47421 to c34c81c Compare August 5, 2026 10:26
@FreekVR
FreekVR requested a lite review from Copilot August 5, 2026 10:29
@myparcel-bot

myparcel-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

✅ Build successful!

You can find a link to the downloadable artifact below.

Name Link
Commit c34c81c
Logs https://github.com/myparcelnl/woocommerce/actions/runs/30997449214
Download https://github.com/myparcelnl/woocommerce/suites/84067226086/artifacts/8926939171

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

tests/Unit/Adapter/WcAddressAdapterTest.php:350

  • The new test only covers “no company” by omitting shipping_company (null). The PR description states an empty company means consumer, and in real checkout flows the company field is often present but empty (''). Adding an explicit empty-string case will better guard the business/consumer boundary and the guarantee that the company name itself is not stored on the cart.
})->with([
    'business (company entered)' => ['Acme B.V.', true],
    'consumer (no company)'      => [null, false],
]);

@myparcel-bot myparcel-bot Bot added the approved (Auto) label Aug 5, 2026
@FreekVR
FreekVR enabled auto-merge August 5, 2026 11:46
@FreekVR
FreekVR disabled auto-merge August 5, 2026 11:49
@FreekVR
FreekVR merged commit d813e6d into main Aug 5, 2026
7 checks passed
@FreekVR
FreekVR deleted the feat/capabilities-isbusiness-flag branch August 5, 2026 11:49
myparcel-bot Bot added a commit that referenced this pull request Aug 6, 2026
## [6.8.0](v6.7.3...v6.8.0) (2026-08-06)

### ✨ New Features

* **checkout:** show the right delivery options for business and consumer orders ([#1675](#1675)) ([d813e6d](d813e6d))
* send width, height and length during export ([#1770](#1770)) ([082d90c](082d90c))
@myparcel-bot

myparcel-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@myparcel-bot myparcel-bot Bot added the released label Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants