Shopping Cart Checkout
These are some notes on the checkout process in zen-cart, based on a walkthrough of the v1.2.6d code. Hopefully they will evolve into full-fledged documentation.
Checkout is a 4 page process:
- Page 1 is checkout_shipping (see includes/modules/pages/checkout_shipping/header_php.php)
First the code verifies that the shopping cart is not empty, the user is logged in, the contents of the cart pass a validation check (see shopping_cart->get_products in includes/classes/shopping_cart.php), and the products are in stock (if enabled). A default shipping address is set if none is selected.
The code then loads the order module (includes/classes/order.php) and creates an order object. Creating the order object executes the order->cart() method which populates the order object from information in the session and in the shopping cart.
If the order contains all 'virtual' products, the code goes directly to the checkout_payment page.
Next the shipping module is loaded (includes/classes/shipping.php) and a shipping object is created. Then the code figures out whether the order is eligible for free shipping. Finally, it gets a shipping quote for each shipping module.
Then the page is rendered using the tpl_checkout_shipping_default.php template. The page contains a form that posts back to the checking_shipping page (ie this page).
When the form is submitted, the code generates a shipping quote for the selected shipping method and stored it in the session. Then it redirects to the checkout_payment page (page 2).
- Page 2 is checkout_payment
- Page 3 is checkout_confirmation
- Page 4 is checkout_process
-Chris Maeda (http://cmaeda.com) 17 Jan 2006