Template Example: Order Reports

Though CartThrob isn’t a solution like OSCommerce where templates can be simply swapped out, it’s helpful to have somewhere to start. The template example below is meant to be a guide, and will give you somewhere to start building an order reports page.

This template code is also included with CartThrob as one of the auto-install templates. This and other example templates can be automatically installed, along with sample weblogs and settings by going to the CartThrob extnsions settings page: Global Settings > Auto-Install Templates. This specific example is contained in the “reports” template group of the auto-install templates.

{examples_channel_configuration}

{/examples_channel_configuration}
{assign_variable:template="cart_single_page_checkout"}
{embed=includes/.header title="Reports" }
<style type="text/css">
	.store_block table td{
		padding: 6px;
	}
</style>
</head>
<body>
	<p>NOTE: All orders and purchased items are stored with the customer’s member_id set as the author of the entry. To display only information for the currently logged in member you can do something like this </p>
	<h3>{exp:weblog:entries weblog="orders" author_id="CURRENT_USER"}</h3>



	<h1>Reports</h1>
	<p>You can create reports in any way you'd like with CartThrob using standard EE templates.</p>
	<p>Note: CartThrob currently uses standard templates to output report information. Some business owners may want to see these reports within the context of their backend. Take a look at the following article: <a href="http://cartthrob.com/docs/tags_detail/order_items/">Site Owner’s Completed Order Report</a></p>


	{!-- ORDERS REPORT --}
    <div class="store_block">
	<h2>Sales Report</h2>
	{!-- outputting products stored in orders weblog. Like typical weblogs, 
		the name of the weblog may vary based on your system configuration --}
		{exp:weblog:entries weblog="orders"}
			<h3>{title}  Purchased: {entry_date format="%m/%d/%Y"}</h3>
			{!-- The "order_items" is a custom field within the weblog. 
				The order_items is a very powerful field type. It can dynamically 
				 add and store configured product information. Each new configuration 
				option will be stored in this field, regardless of the name or 
				number of configuration options. This means that you can store 
				sizes, colors, finishes, or other option data without pre-configuring 
				the field. See the article entry here on setting this up: 
				http://cartthrob.com/docs/sub_pages/orders_overview/
				and the article about outputting this data here: 
				http://cartthrob.com/docs/tags_detail/order_items/
			  --}
			{!-- :table is a pseudo tag available for the order_items custom field. it
				outputs a table of the content stored in the order_items field. You can 
				also use the {order_items}{/order_items} variable pair for more flexibility --}
			{order_items:table}<br />
		
			{!-- The variables below all reference standard EE weblog custom field variables --}
<pre>
Subtotal: 			{order_subtotal}
Tax: 				{order_tax}
Shipping:			{order_shipping}
-------------------------------------------------------------
Total:				{order_total}
</pre>


			<br />
			Transaction ID: {order_transaction_id}<br /><br />

			Customer Info: <br />
			{order_billing_first_name} {order_billing_last_name}<br />
			{order_customer_email}<br />

			<hr>
		{/exp:weblog:entries}
	</div>
	
	{!-- PURCHASED ITEMS --}
    <div class="store_block">
	<h2>PURCHASED ITEMS</h2>
	{!-- Purchased items is a standard EE weblog. There are no advanced custom fields associated
		with the Purchased items weblog --}
		{exp:weblog:entries weblog="purchased_items" limit="20"}
			<h3>{title}</h3>
			Customer Info: {author}
			Item ID: {purchased_id}
			Quantity Purchased: {purchased_quantity}
			Order ID: {purchased_order_id}
			<hr>
		{/exp:weblog:entries}
	</div>
	<div class="store_block">
		<h2>Tags used in this template</h2>
		<ul>
			<li><a href="http://cartthrob.com/docs/tags_detail/order_items/">CartThrob Order Items Custom Field Type</a></li>
			<li><a href="http://cartthrob.com/docs/tags_detail/order_items/#var_item:table">CartThrob Order Items:Table</a></li>

		</ul>
	</div>
	<div class="store_block">
		<h2>Concepts used in this template</h2>
		<ul>
			<li><a href="http://cartthrob.com/docs/sub_pages/orders_overview/">Orders Weblog</a></li>
			<li><a href="http://cartthrob.com/docs/sub_pages/purchased_items_overview">Purchased Items Weblog</a></li>
		</ul>
	</div>
	<div class="store_block">
		{embed=includes/.footer}
	</div>
</body>
</html>

The easiest method for using this template is as part of CartThrob’s built-in auto-install templates system, but is included here as an overall sample of what some of the tags can do when put together.

Top of Page