LemonStand Documentation

Creating the Order Review partial

The Order Review step finalizes the checkout process. On this step a visitor can see all the information about the order. The Order Review step doesn't have any input elements.

Start with creating a new partial. According to the code example in the Checkout Page partial, the name of the Order Review partial should be shop:checkout_review. You could use any other names for partials in your store.

The following code demonstrates the Order Review partial code example.

<h3>Order Review</h3>
<?
  $bill_to_str = $billing_info->as_string();
  $ship_to_str = $shipping_info->as_string();
  $items = Shop_Cart::list_active_items();
?>

<p>Bill to: <?= h($bill_to_str) ?></p>
<p>Ship to: <?= h($ship_to_str) ?></p>

<table>
  <tr>
    <th>Cart Items</th>
    <th>Quantity</th>
    <th>Price</th>
    <th>Discount</th>
    <th>Total</th>
  </tr>
  <?
    foreach ($items as $item):
      $options_str = $item->options_str();
  ?>
    <tr>
      <td>
        <strong><?= h($item->product->name) ?></strong>
        <? if (strlen($options_str)): ?>
          <br/><?= h($options_str) ?>.
        <? endif ?>
        <? if ($item->extra_options): ?>
          <? foreach ($item->extra_options as $option): ?>
            <br/>+ <?= h($option->description) ?>: <?= format_currency($option->get_price($item->product)) ?>
          <? endforeach ?>
        <? endif ?>
      </td>
      <td><?= $item->quantity ?></td>
      <td><?= format_currency($item->single_price()) ?></td>
      <td><?= format_currency($item->total_discount()) ?></td>
      <th><?= format_currency($item->total_price()) ?></th>
    </tr>
  <? endforeach ?>
</table>

<p>
  Subtotal: <?= format_currency($subtotal) ?><br/>
  Discount: <?= format_currency($discount) ?><br/>
    
  <? foreach ($product_taxes as $tax): ?>
    <?= ($tax->name) ?>:<?= format_currency($tax->total) ?><br/>
  <? endforeach ?>
    
  Shipping: <?= format_currency($shipping_quote) ?>
    
  <? foreach ($shipping_taxes as $tax): ?>
    Shipping tax (<?= ($tax->name) ?>): <?= format_currency($tax->rate) ?><br/>
  <? endforeach ?>
</p>

<p>Total: <strong><?= format_currency($total) ?></strong></p>
<input type="hidden" name="checkout_step" value="<?= $checkout_step ?>"/>
<input type="button" value="Place Order and Pay" onclick="return $(this).getForm().sendRequest(
  'on_action', 
  {update:{'checkout_page': 'checkout_partial'}}
)"/> 

The code outputs the billing and shipping information, the cart item list, order subtotals, tax values, shipping cost and total value. The code for displaying a shopping carts content repeats the code described in the Cart page article. 

The as_string method of $billing_info and $shipping_info objects are used for obtaining a formatted string, containing a customer's billing and shipping information. The $billing_info and $shipping_info objects are instances of Shop_CheckoutAddressInfo class.

The checkout_step hidden field should be used in all checkout partials.

See also:

Next: Skipping the Shipping Method step for downloadable products or services
Previous: Creating the Payment Method partial
Return to AJAX-driven single-page checkout

Comments

No comments posted so far.

Add your comment

Loading form...