Skip to content

TWO-24739: Full Magento surcharge parity (per-term grid) + end-of-month terms → staging#330

Merged
dgjlindsay merged 1 commit into
stagingfrom
doug/TWO-24739-phase-b-surcharge-parity
Jun 23, 2026
Merged

TWO-24739: Full Magento surcharge parity (per-term grid) + end-of-month terms → staging#330
dgjlindsay merged 1 commit into
stagingfrom
doug/TWO-24739-phase-b-surcharge-parity

Conversation

@dgjlindsay

Copy link
Copy Markdown

Phase B of the WooCommerce↔Magento parity work, onto staging (Phase A is already on staging via #329).

Brings WC surcharge/offset pricing to the Magento model:

  • surcharge_type (none/percentage/fixed/fixed_and_percentage) — supersedes the simple offset model.
  • Per-term surcharge grid (custom two_surcharge_grid settings field): fixed / percentage / cap per offered term.
  • build_buyer_fee_share per-term, mirroring Magento's buyer_fee_share contract (percentage 0.0 when fixed-only, surcharge_basis, surcharge, cap, rounding only with a percentage component, reference_terms in differential mode).
  • surcharge_differential toggle; payment_terms_type standard/end_of_month (duration_days_calculated_from); optional surcharge_line_description.

Flagged framework-mismatch decisions (WC ≠ Magento):

  • FX: WC has no rate provider and no reliable store-vs-order currency signal at quote time → fixed/cap sent as configured in store currency, no conversion (single-currency assumption; documented parity gap). Percentage surcharge is currency-agnostic.
  • Tax: WC fees use tax classes, not arbitrary rates → surcharge line keeps WC store tax (add_fee taxable); no surcharge_tax_rate field.

Deferred follow-ups (kept this PR focused): PO-number-in-payload; verify address-lookup (already wired here).

Tests rewritten for the grid model + grid-validator + end-of-month; green on PHP 7.4 + 8.2. Two adversarial review rounds → clean (first round caught a no-op FX guard / cap-stripping bug, now removed).

(opened by Claude)

…f-month terms

Brings WooCommerce offset pricing up to the Magento surcharge model:

- surcharge_type selector (none/percentage/fixed/fixed_and_percentage) replaces
  the simple enable_offset_pricing + single-percentage model. None disables.
- Per-term surcharge GRID (custom WC settings field two_surcharge_grid): a row
  per offered term with fixed / percentage / cap columns, stored as one option
  array keyed by term days. Render + validate (non-negative, percentage 0-100,
  comma-decimal normalised, empty cells/rows dropped).
- build_buyer_fee_share is now per-term and mirrors Magento's contract:
  percentage (0.0 when fixed-only so the API default 100% is never silently
  applied), surcharge_basis "buyer_pays", surcharge (fixed/both), cap (when a
  percentage component has a limit), rounding (only with a percentage
  component), and reference_terms in differential mode (the default term).
- surcharge_differential toggle (full vs differential-vs-default-term).
- payment_terms_type = standard | end_of_month → emits
  duration_days_calculated_from=END_OF_MONTH on every NET_TERMS block (fee
  quote, reference terms, order payload) via a shared build_terms_block.
- surcharge_line_description: optional buyer-facing label with %s for term days.

Framework-mismatch decisions (vs Magento), flagged for review:
- FX: WooCommerce has no currency-rate provider, and there is no reliable
  store-vs-order currency signal at fee-quote time (get_woocommerce_currency is
  a filtered wrapper over the same option). So fixed amounts and caps are sent
  as configured, in the store currency, with NO conversion — fixed surcharge is
  for single-currency stores; multi-currency conversion is a documented parity
  gap vs Magento (which converts via Magento's rates). Percentage surcharge is
  currency-agnostic and unaffected.
- Tax: WooCommerce fees use tax CLASSES, not arbitrary rates, so an explicit
  surcharge_tax_rate override has no clean analogue — the surcharge line keeps
  WooCommerce's store tax handling (add_fee taxable). No surcharge_tax_rate field.

Deferred to a follow-up (kept this PR focused on the surcharge centrepiece):
PO-number-in-payload (threads through the shared order-compose signature) and a
review of address-lookup (already wired on this branch — verify in Chrome).

Tests rewritten for the grid model + grid-validator and end-of-month cases;
green on PHP 7.4 and 8.2.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions

Copy link
Copy Markdown

🖌 Pre-commit success 🏆

Details
Downloading virtualenv (4.3MiB)
 Downloaded virtualenv
Installed 11 packages in 14ms
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier:prettier@3.1.0.
[INFO] Initializing environment for https://github.com/two-inc/git-hooks.
[INFO] Installing environment for https://github.com/pre-commit/mirrors-prettier.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
prettier.................................................................Passed

Exit code: 0

Author ✍️@dgjlindsay

@dgjlindsay dgjlindsay merged commit 8552652 into staging Jun 23, 2026
4 checks passed
@dgjlindsay dgjlindsay deleted the doug/TWO-24739-phase-b-surcharge-parity branch June 23, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant