TWO-24739: Full Magento surcharge parity (per-term grid) + end-of-month terms → staging#330
Merged
Merged
Conversation
…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>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
🖌 Pre-commit success 🏆DetailsExit code: 0 Author ✍️@dgjlindsay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.two_surcharge_gridsettings field): fixed / percentage / cap per offered term.build_buyer_fee_shareper-term, mirroring Magento'sbuyer_fee_sharecontract (percentage 0.0 when fixed-only,surcharge_basis,surcharge,cap,roundingonly with a percentage component,reference_termsin differential mode).surcharge_differentialtoggle;payment_terms_typestandard/end_of_month (duration_days_calculated_from); optionalsurcharge_line_description.Flagged framework-mismatch decisions (WC ≠ Magento):
add_feetaxable); nosurcharge_tax_ratefield.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)