Let’s do a one page checkout. On the checkout page there will be a table of the items currently in the cart. The customer will be able to to change quantities and remove items from the cart. Below the table of items, there will be a checkout form, where the customer can enter their billing/shipping and payment info. We’re going to assume here that you already have a products weblog and you have set up a way for customers to add items to their carts.
Template: cart/checkout
<h1>One Page Checkout</h1>
{embed=cart/.nav}
<br />
{!-- One Page Checkout
This template adds a one page checkout
http://cartthrob.com/docs/plugins/cartthrob/checkout_form/
The checkout form gathers values for payment processing and initiates processing & payments.
There are lots of parameters available. A few of the key parameters are
cart_empty_redirect - If the cart is empty, this is where the user will be redirected
return - This is where the user will be redirected after the form submits.
allow_user_price - if you want to hard code items & their prices in their form, you will need to set this to "yes" as a security measures.
Example uses.
1. You can hard code products on this page, or put in a weblog:entries tag to output entries to this page to make a single page checkout form.
2. Add products to the customers cart elsewhere, and use this template to solely take information and process orders
--}
<h2>Your Shopping Cart</h2>
{exp:cartthrob:view_cart}
{if no_results}
There is nothing in your cart
{/if}
{if first_row}
<form action="{path=cart/change_quantity}" method="post">
<table>
<thead>
<tr>
<td>Item</td>
<td colspan="2">Quantity</td>
</tr>
</thead>
<tbody>
{/if}
<tr>
<td>{title}</td>
<td>
<input type="text" name="entry_ids[{entry_id}]" size="2" value="{quantity}" />
</td>
<td>
<a href="{path=cart/delete_from_cart/{entry_id}}">Delete</a>
</td>
</tr>
{if last_row}
<tr>
<td colspan="2"> </td>
<td>
Subtotal: {cart_subtotal}<br />
Shipping: {cart_shipping}<br />
Tax: {cart_tax}<br />
<strong>Total: {cart_total}</strong>
</td>
</tr>
</tbody>
</table>
<input type="submit" value="Update Quantities" />
</form>
{/if}
{/exp:cartthrob:view_cart}
{exp:cartthrob:checkout_form return="cart/order_complete"}
{!-- Use the gateway fields template variable to output fields required by your
currently selected gateway. If no fields are showing, select a gateway in the extension settings. --}
{gateway_fields}
<p>If no fields are showing, the testing gateway is probably selected. Submitting with the testing gateway selected will save your order.</p>
<input type="submit" value="Checkout" />
{/exp:cartthrob:checkout_form}
You’ll also need to create a new template to change the quantities:
Template: cart/change_quantity
{exp:cartthrob:change_quantity redirect="cart/one_page_checkout"}
You probably also want an order confirmation page:
Template: cart/order_complete
<h1>Your Order is complete</h1>
{embed=cart/.nav}
{exp:cartthrob:order_info}
{if authorized}
Your payment is a success!
Transaction ID: {transaction_id}
Your total: {cart_total}
Your order ID: {order_id}
{if:elseif declined}
Your credit card was declined: {error_message}
{if:elseif failed}
Your payment failed: {error_message}
{/if}
{/exp:cartthrob:order_info}
