feat(checkout): show the right delivery options for business and consumer orders - #1675
Conversation
❌ 1 Tests Failed:
View the full list of 1 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
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
CapabilitiesValidationServicetest stub to accept the new?bool $isBusinessparameter ingetPackageTypeWeights(). - Added a unit test asserting that cart company input results in
isBusiness=trueand thatcompanyis 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.
a128f48 to
379bc46
Compare
…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>
8b47421 to
c34c81c
Compare
|
✅ Build successful! You can find a link to the downloadable artifact below.
|
There was a problem hiding this comment.
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],
]);
|
🎉 This PR is included in version 6.8.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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