Skip to content

feat(checkout): share contextual validation across order flows - #32

Merged
Seiger merged 3 commits into
Seiger:1.xfrom
MiddleSokilAI:sokil/checkout-validation-context
Oct 27, 2026
Merged

Seiger merged 3 commits into
Seiger:1.xfrom
MiddleSokilAI:sokil/checkout-validation-context

Conversation

@MiddleSokilAI

@MiddleSokilAI MiddleSokilAI commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Direct order creation could bypass the rules used when saving the checkout form, and quick orders did not expose their prepared product lines to those rules. This PR makes getValidationRules(array $data, string $context = 'default') the shared source of Commerce, delivery and plugin validation for both order flows.

The branch extends the existing sCommerce.CheckoutValidationRules contract on current 1.x, so store-specific quantity policies remain in consumer plugins.

Changes

  • Select the standard or quick base rule set through a switch and pass context with the existing data and by-reference rules event payload.
  • Validate standard order data before persistence and payment, including direct processOrder() calls; retain partial field validation in setOrderData().
  • Validate quick-order input and prepared server lines once. Preserve raw quantities until validation succeeds, then convert them and calculate totals/deposits. Ignore request-supplied product snapshots.
  • Keep cart output to configured product fields and displayed attributes instead of injecting every physical measurement (separate commit). Quick orders retain the current upstream physical payload format.
  • Update English, Ukrainian and Russian event documentation, physical-payload guidance and standalone regression coverage.

Validation

The regressions use synthetic data or isolated SQLite; no site database was changed.

  • Checkout validation: 40 checks, including one event invocation, raw invalid quantities, forged product input, default quantity and cart quick orders.
  • All 30 runtime/standalone scripts passed in GitHub Actions on PHP 8.4 and PHP 8.5, covering payments, schedules, order events, stock, shipments, physical attributes and documentation examples.
  • PHP lint, Composer validation and git diff --check passed.

Live browser checkout verification remains part of consumer deployment; these checks cover the package's server-side behavior.

@Seiger
Seiger merged commit a351812 into Seiger:1.x Oct 27, 2026
2 checks passed
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.

2 participants