Skip to content
Learnomy

Checkout and Purchase Flow

The Learnomy checkout and purchase flow

Learnomy gives buyers one on-page checkout that works with whichever gateway you have enabled. The buyer sees an order summary, enters a coupon if they have one, and pays without leaving the page for Stripe and the test gateway. After payment they land on a thank-you page; if they back out at the gateway they land on a cancelled page.

What you can do

  • Sell a course or a membership plan through one unified checkout at /enroll/?course_id=N or /enroll/?plan_id=N.
  • Take card payments on-page with Stripe (the card form renders inside the checkout, no redirect), or send buyers to PayPal or WooCommerce.
  • Show a clear order summary with the price, any sale discount, a coupon line, the tax line, and the total.
  • Let buyers apply a coupon code and see the total recalculate before they pay.
  • Skip the payment provider entirely when a coupon (or a fully discounted price) zeroes the total -- the buyer is enrolled directly.
  • Hide the payment-method selector when only one gateway is enabled, so a single method reads as a clean form instead of a one-option radio.
  • Land every buyer on a thank-you page that confirms the order, or a cancelled page if they abandon the gateway.

How to use it

Step 1 -- reach the checkout

A buyer reaches checkout by clicking Buy or Enroll on a course page or a membership plan card. That links to /enroll/?course_id=N (course) or /enroll/?plan_id=N (plan). Checkout requires the buyer to be logged in.

Step 2 -- review the order summary

The left side shows the item (thumbnail, title, instructor, and a Membership badge for plans) and, for paid items, a price breakdown: Price, any Sale discount, a Coupon line, the Tax line when tax is on, and the Total.

Step 3 -- apply a coupon (optional)

The buyer enters a code and clicks Apply. A valid code adds a coupon line and updates the total; feedback reads immediately. If a coupon or a fully discounted price brings the total to zero, no gateway is used -- Learnomy enrolls or subscribes the buyer directly, because payment providers reject a zero charge.

Step 4 -- fill in billing details

Above the payment method, the buyer supplies a billing address: first and last name, company, country, two address lines, city, state, postcode, email, phone, and a tax registration number (GSTIN in India, VAT ID in the EU -- one field covers both).

Six of those are required before a purchase can go through: first name, last name, country, address line 1, city, and postcode. The rest are optional.

The address belongs to the buyer, not to the order. It is stored on their user account, so the fields come back pre-filled on their next purchase and they never retype it. Each order also keeps its own frozen copy taken at the moment of purchase, so editing the address later never rewrites an old receipt.

The same details are collected whichever gateway the buyer uses. Before this, the address came from Stripe's own address widget, which meant a PayPal or WooCommerce buyer supplied no address at all, a company name and tax number could not be captured, and nothing was kept afterwards.

Site owners running WooCommerce get this for free in both directions: the fields use WooCommerce's own billing_* user-meta keys, so an address Woo already collected pre-fills a Learnomy checkout and vice versa. WooCommerce is not required -- without it these are ordinary user meta.

Step 5 -- pay

The right side shows the payment method:

  • Stripe -- the card fields render on the page, themed to your site. The buyer enters their details and clicks Complete Purchase without leaving the page.
  • PayPal -- the PayPal button renders in place; the buyer completes payment through PayPal.
  • WooCommerce -- the buyer is sent to the WooCommerce cart to finish.
  • Test -- a test-mode button simulates a successful payment with no real charge.

When only one gateway is enabled, the method selector is hidden and the single method is shown directly.

Step 6 -- land on the result page

  • Thank-you (enroll-thank-you route) -- confirms the purchase with an order summary and next-step buttons. If the webhook has not confirmed the payment yet, the page shows a "Setting up your enrollment" pending state that refreshes itself until the payment clears, then a failed state if it does not go through.
  • Cancelled (enroll-cancelled route) -- shown when the buyer abandons the gateway. No charge is made and nothing is recorded; the page offers to try payment again or browse other courses or plans.

Settings and options

The checkout adapts to what you have configured; there is no separate "checkout" settings page.

  • Which gateways appear comes from the Payments settings -- Stripe, PayPal, WooCommerce, and the Test gateway each have their own enable toggle. The checkout shows only the enabled ones.
  • The tax line appears when tax is enabled. See Tax (Flat Rate).
  • Coupons are validated against your coupon rules. See Coupons.
  • Free items show a "Free Enrollment" panel with an Enroll for Free button instead of a payment form.
  • Already enrolled buyers see an "Already Enrolled" message with a link to the course instead of a second checkout, and a repeated paid checkout for a course the buyer already owns is blocked.

For developers

Routes (built through the Route Registry, never hardcoded):

  • enroll -- the checkout page (templates/checkout.php).
  • enroll-thank-you -- post-purchase landing (templates/checkout-thank-you.php).
  • enroll-cancelled -- gateway-abandon landing (templates/checkout-cancelled.php).

REST (Learnomy\API\Checkout_Controller, namespace learnomy/v1):

  • POST /checkout -- unified checkout; resolves the gateway from the request and returns a client_secret (Stripe on-page) or a redirect_url (PayPal / WooCommerce). Free / zeroed orders enroll directly.
  • POST /checkout/subscribe -- create a recurring subscription for a membership plan.
  • POST /webhooks/{gateway} -- public, signature-verified webhook ingestion (with a back-compat /checkout/webhooks/{gateway} alias).
  • Checkout_Controller::thank_you_url( $gateway_id, $context ) / ::cancelled_url( $context ) -- the canonical return-URL builders. Pro reuses these rather than building return URLs itself.

Return-page actions:

  • learnomy_thank_you_rendered -- fires after the thank-you page renders (transaction row, user id). Pro analytics use it for conversion pixels and drip triggers.
  • learnomy_cancelled_rendered -- fires after the cancelled page renders (course id, plan id). Used for abandoned-cart follow-up.

Related