LemonStand Documentation

Payment Receipt page

The Payment Receipt page is displayed after a successful payment. For each payment method you select choose a Receipt page in the payment method configuration form. You can create a single page and use it for all payment methods, or create separate pages for each payment method.

The Payment Receipt page displays the order details and confirms a successful payment. Also, LemonStand outputs on this page the Google Analytics e-commerce tracking code, if Google Analytics is enabled.

To create the Payment Receipt page, create a new page and assign it a name, for example “Thank you!” and URL, for example /thankyou. The page name and URL can be anything. Go to the Action tab and select the shop:payment_receipt action in the drop-down menu. The shop:payment_receipt action loads an order object into the $order variable and order items into the $items variable which contains a list of order items (objects of the Shop_OrderItem class).

A value of the $order variable can be NULL in case if the requested order was not found. Always check a value of the variable before displaying the receipt page content. Also, the shop:payment_receipt action creates the $payment_processed variable which value if TRUE if the order was paid. You need to check a value of this variable before displaying the receipt page.

The following code snippet outputs the typical content of the Receipt page.

<? if (!$order): ?>
  <h2>Order not found.</h2>
<? elseif (!$payment_processed): ?>
  <h2>This order is not paid.</h2>
<? else: ?>
  <h2>Thank you!</h2>
  <p>Order # <?= $order->id ?><br/>Order Date: <?= h($order->order_datetime->format('%x')) ?></p>
  <table>
    <tr>
      <th>Items</th>
      <th>Price</th>
      <th>Discount</th>
      <th>Quantity</th>
      <th>Total</th>
    </tr>
    <? foreach ($items as $item): ?>
      <tr>
        <td><?= $item->output_product_name() ?></td>
        <td><?= format_currency($item->single_price) ?></td>
        <td><?= format_currency($item->discount) ?></td>
        <td><?= $item->quantity ?></td>
        <th><?= format_currency($item->subtotal) ?></th>
      </tr>
    <? endforeach ?>
  </table>
  <p>Subtotal: <?= format_currency($order->subtotal) ?><br/>
    Discount: <?= format_currency($order->discount) ?><br/>
  
    <? foreach ($order->list_item_taxes() as $tax): ?>
        <?= ($tax->name) ?>: <?= format_currency($tax->total) ?><br/>
    <? endforeach ?>
  
    Shipping: <?= format_currency($order->shipping_quote) ?><br/>
  
    <? foreach ($order->list_shipping_taxes() as $tax): ?>
       Shipping tax (<?= ($tax->name) ?>): <?= format_currency($tax->total) ?><br/>
    <? endforeach ?>  
  </p>
  <p>Total: <?= format_currency($order->total) ?></p>
<? endif ?>

The code outputs the order number and order create date. Then the code iterates over the list of product items, fetching them from the $items variable. For each order item the table row with item detail is displayed. Finally, the code outputs the order subtotal, tax information, shipping quota and order total.

See also

Next: Payment receipt for inclusive tax environments
Previous: Pay page
Return to Building your online store

Comments

No comments posted so far.

Add your comment

Loading form...