Conditional checkout panes?

Created on 24 February 2023, over 1 year ago

In a pre-existing commerce setup (Drupal 9, Commerce 2), I have a need to show a login/register pane only under certain conditions.

In case A: if the user isn't logged in, the use case wants anonymous users to check out as guest by default, absent a small link asking them to log in if they choose.

In case B: if a user clicks that login link, they are directed to a step in the form (checkout/[id]/login) that shows a specific custom checkout pane that prompts them to register, login, or continue checking out as guest. The user can't, for example, go to /user/login?destination=checkout/[id], as that specific checkout pane has important branding/auxiliary elements that are not present on the user login/register form. It has to be that custom pane.

This thus presents two options: either find a way to conditionally toggle the visibility of a checkout pane form (this login pane extends BaseLogin), or have a separate, nearly identical checkout flow that can be toggled based on a conditional that can be satisfied by clicking a link.

I've seen resources for how to do this in D7, but nothing for D9 under commerce 2.

Any insight would be helpful.

πŸ“Œ Task
Status

Active

Version

2.33

Component

Checkout

Created by

πŸ‡ΊπŸ‡ΈUnited States tripodcreative

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024