TWO-24892: buyer surcharge rounding (basis + brand-driven step)#328
Closed
dgjlindsay wants to merge 1 commit into
Closed
TWO-24892: buyer surcharge rounding (basis + brand-driven step)#328dgjlindsay wants to merge 1 commit into
dgjlindsay wants to merge 1 commit into
Conversation
Port the Magento buyer-surcharge-rounding feature to WooCommerce. The
merchant picks a rounding basis (None / Up / Down / Standard) and a
rounding step from a brand-driven dropdown; the plugin relays
buyer_fee_share.rounding = {step, basis} to POST /v1/pricing/order/fee.
The backend does the arithmetic — the plugin only relays the contract,
mirroring Magento's Service/Order/SurchargeCalculator.
- brands/two.php: available_rounding_steps brand key (default
0.10/0.50/1.00/5.00/10.00), the only source for the step dropdown.
An overlay narrows the set (cf. available_terms).
- WC_Twoinc::get_rounding_step_options(): canonical 2dp option list so
the stored value round-trips, mirroring the Magento RoundingStep
source model. Two new select fields in the offset-pricing section.
- WC_Twoinc_Payment_Terms: read the options in get_offset_settings();
build_rounding() emits the block, omitting it for a None/unmapped
basis or a non-positive step (the API requires both keys and rejects
step <= 0).
- tests/unit: build_buyer_fee_share rounding cases (basis->API map,
None/zero-step omission, rides alongside reference terms, ignored
when offset disabled).
Stacked on doug/TWO-24751-terms-chips (carries the buyer_fee_share
builder + brand-config layer). Rebases onto staging once TWO-24751
merges. i18n .pot regeneration deferred to the Lokalise flow.
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 |
Contributor
Author
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.
What
Ports the Magento buyer-surcharge-rounding feature to WooCommerce (TWO-24892, child of TWO-24739 plugin parity).
The merchant picks a rounding basis (None / Up / Down / Standard) and a rounding step from a brand-driven dropdown. The plugin relays
buyer_fee_share.rounding = {step: <float>, basis: "UP"|"DOWN"|"STANDARD"}toPOST /v1/pricing/order/fee. All arithmetic stays server-side — the plugin only relays the contract, mirroring Magento'sService/Order/SurchargeCalculator.How (mirrors magento-plugin 1:1)
brands/two.php— newavailable_rounding_stepsbrand key (default0.10 / 0.50 / 1.00 / 5.00 / 10.00), the only source for the step dropdown. An overlay narrows the set (cf.available_terms).WC_Twoinc::get_rounding_step_options()— canonical two-decimal option list (number_format(…,2)) so the stored value round-trips, ascending (ksort SORT_NUMERIC); mirrors the MagentoRoundingStepsource model +Loadersort. Two newselectfields in the offset-pricing section.WC_Twoinc_Payment_Terms— reads the options inget_offset_settings();build_rounding()emits the block, omitting it for a None/unmapped basis or a non-positive step (the API requires both keys and rejectsstep <= 0).build_buyer_fee_sharerounding cases (basis→API map, None/zero/negative/unmapped omission, rides alongside reference terms, ignored when offset disabled) + a Reflection test pinning the step-option producer (canonical format, sort, overlay narrowing, skip-invalid).Semantics
roundingblock sent (standard 2dp).Stacking
Stacked on
doug/TWO-24751-terms-chips(the only branch carrying both thebuyer_fee_sharebuilder and the brand-config layer). Rebases onto staging once TWO-24751 merges.Out of scope (blocked, separate tickets)
Test / lint
php tests/unit/run.phpgreen on PHP 7.4 + 8.2 (32/32);php -lclean. i18n.potregeneration deferred to the Lokalise flow (no CI gate). Two adversarial review rounds → clean.🤖 Generated with Claude Code
PR opened by Claude on Doug's behalf.