Checkout operations step by step
This page is for developers who need to know exactly what happens at each step of the checkout, for example to place
a workflow event correctly or to understand an order that looks wrong. It follows a customer from the product page to
the placed order and names the operation, the trigger points and the methods that run, from
kernel/shop/operation_definition.php and the shop views.
Contents
- Step 1 Add to basket
- Step 2 Update the basket
- Step 3 The checkout button
- Step 4 Confirm the order
- Step 5 Check out and pay
- Step 6 Back from the provider
- The whole sequence
Step 1 Add to basket
Operation addtobasket (parameters object_id, option_list, quantity, basket_id):
- Trigger
pre_addtobasket(the before trigger ofshop_addtobasket). - Method
add-to-basket: the item and its options are stored in the basket's product collection. - Method
update-shipping-info: the shipping handler, if one is configured, is told the basket changed. - Trigger
post_addtobasket.
Then the customer is sent to the basket or back, as site.ini [ShopSettings] RedirectAfterAddToBasket says.
Step 2 Update the basket
Operation updatebasket (parameters item_count_list, item_id_list): trigger pre_updatebasket, method
update-basket, trigger post_updatebasket. A quantity of zero or less, or one that is not a number, sends the
customer back to the basket with an error ((error)/invaliditemcount).
Step 3 The checkout button
On Checkout in the basket (kernel/private/classes/views/shop/basket.php):
- Posted quantities are saved.
- The shop account handler is asked whether it has the customer's data (
verifyAccountInformation()). If not, it sends the customer to its form (shop/userregister,shop/register) or to sign in (shopaccount.ini walkthrough). That form creates the order when it is submitted. - Prices are updated and the basket is verified: each item's product must still be published, and its price,
VAT inclusion and VAT percentage must match what the basket holds. Items that fail are removed from the basket and
listed on the basket page (
removed_itemsinshop/basket.tpl). - A temporary order is created from the basket and its id is kept in the session (Temporary orders and activation).
- The customer is sent to
shop/confirmorder.
Step 4 Confirm the order
Operation confirmorder (parameter order_id), run when the confirmation page is prepared:
- Trigger
pre_confirmorder: the triggerbefore_shop_confirmorderinworkflow.ini. Shipping events run here (Simple shipping event). - Method
handle-user-country: the customer's country is settled for VAT. - Method
handle-shipping: shipping information from a shipping handler is applied. - Method
fetch-order.
There is no after trigger on confirmorder. The page shows the order with shipping and VAT. Confirm goes on to
shop/checkout (and empties the basket now if ClearBasketOnCheckout=enabled); Cancel returns to the basket with
its items. An order that is no longer temporary (Back button, a second tab) is not confirmed again: the customer is
sent to its receipt or order view (Permanent order receipts).
Step 5 Check out and pay
shop/checkout runs operation checkout (parameter order_id):
- Method
check-currency. - Trigger
pre_checkout: the before trigger ofshop_checkout. The payment gateway event runs here (Payment gateway event). - Method
activate-order: the order stops being temporary and gets its order number (Temporary orders and activation). - Method
send-order-email: the confirm order handler sends the order mail. - Trigger
post_checkout: the after trigger ofshop_checkout; events that need a placed order run here.
If an event on pre_checkout redirects (a redirect gateway) or shows a page (gateway selection, a card form), the
operation stops there and continues when the workflow is resumed. If it is cancelled, the customer sees
shop/cancelcheckout.tpl.
Step 6 Back from the provider
When the customer returns to shop/checkout after a redirect gateway, the view waits up to 25 seconds, checking every
2 seconds, for the provider's callback to activate the order. If the order is activated, the customer is sent to the
order view or receipt. If not, shop/checkoutagain.tpl lets the customer try again, up to three attempts; after that
shop/cancelcheckout.tpl is shown with the error code NO_CALLBACK
(kernel/private/classes/views/shop/checkout.php). This is the most common symptom of a callback that cannot reach
the site (Troubleshooting checkout).
The whole sequence
shop/add addtobasket: pre_addtobasket > add-to-basket > update-shipping-info > post_addtobasket
shop/basket updatebasket: pre_updatebasket > update-basket > post_updatebasket
Checkout button account handler > verify basket > temporary order > shop/confirmorder
shop/confirmorder confirmorder: pre_confirmorder > handle-user-country > handle-shipping > fetch-order
Confirm shop/checkout
shop/checkout checkout: check-currency > pre_checkout > activate-order > send-order-email > post_checkoutRelated pages
- Checkout and workflows
- Workflows on shop triggers
- Basket and checkout flow
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.