Problem/Motivation

Commerce checkout always redirects customers to `/checkout/{order_id}/complete` when checkout reaches the `complete` step.

For many sites, the desired behavior is redirecting to a custom URL (for example, a CMS-managed thank-you page like `/memberships`) while still keeping checkout-flow-level configurability.

There is currently no per-checkout-flow setting to control this final redirect destination.

Proposed resolution

A merge request adds a new checkout pane plugin, **Completion page**, similar in spirit to Completion message, that allows admins to configure a destination URL per checkout flow.

MR behavior:

1. Adds a new checkout pane plugin:
- ID: `completion_page`
- Label: `Completion page`
- Default step: `complete`
- Config field: `url` (supports internal paths, absolute URLs, token replacement)

2. Extends checkout flow redirect handling:
- Introduces `CheckoutFlowBase::getRedirectUrl($step_id)` (default behavior unchanged)
- Uses `getRedirectUrl()` in both:
- `CheckoutFlowBase::submitForm()`
- `CheckoutFlowBase::redirectToStep()`

3. Adds override in `CheckoutFlowWithPanesBase::getRedirectUrl($step_id)`:
- If step is `complete` and pane `completion_page` has a valid URL, use it
- Otherwise fallback to default `/checkout/{order}/complete` flow

4. Adds schema entry for pane config:
- `commerce_checkout.commerce_checkout_pane.completion_page`
- `url: string`

Token example

The URL field supports tokens, so for example:

`/thank-you?query_param_for_view=[commerce_order:order_items:0:entity:purchased_entity:entity:product_id:target_id]`

This can redirect to a Canvas page, where a view can display product-specific thank you page.

UX notes

- If URL is empty/undefined, behavior remains exactly as today.
- Configuration is per checkout flow.
- Token support allows dynamic destinations per order.

API changes

- New protected method on `CheckoutFlowBase`:
- `protected function getRedirectUrl($step_id): Url`

Backward compatibility

- Existing behavior preserved when `Completion page` pane is not configured.
- Existing checkout flows continue to redirect to `commerce_checkout.form` by default.

Remaining tasks

- Community review / RTBC
- Optional tests for:
- configured URL redirect
- empty URL fallback
- complete-step-only override

Issue fork commerce-3589331

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

elaman created an issue. See original summary.

elaman’s picture

Issue summary: View changes
Status: Active » Needs review