<div id="module_<?php echo($module_instance_id); ?>" class="module shop-account-module <?php echo($module_class); ?>">
	<h2>Order History</h2>

	<table class="shop_order_history table">
		<thead>
			<tr>
				<th>Date</th>
				<th>Order Number</th>
				<th>Status</th>
				<th>Summary</th>
				<th>Order Total</th>
				<th>Info</th>
			</tr>
		</thead>
		<?php
		$count = 0;

		foreach($orders as $order)
		{
			$o = new Shop_Order();
			$o->load($order->order_id);
			$tracking_urls = $o->get_tracking_urls();

			$products = unserialize($order->products);
		// 	$product_text = array();
		// 	$count = 0;

		// 	foreach($products as $item)
		// 	{
		// 		$options = unserialize($item->product_options);
		// 		$deposit = ($item->deposit_price > 0);

		// 		$product_text[$count] = $item->quantity . " @ $" . number_format($item->price, 2) . ($deposit ? " (Deposit)" : "") . "<br />" . $item->product_name;

		// 		if(is_array($options) && count($options) > 0)
		// 		{
		// 			foreach($options as $option)
		// 			{
		// 				if($deposit)
		// 				{
		// 					$option->price_change = 0;
		// 				}

		// 				if($option->option_type == "checkbox")
		// 				{
		// 					$option_label = "* " . $option->option_label;
		// 				}
		// 				else
		// 				{
		// 					$option_label = "* " . $option->option_label . ": " . $option->option_value;
		// 				}

		// 				$product_text[$count] .= $option_label;
		// 			}
		// 		}
		// 		$count++;
		// 	}
			?>
			<tbody>
				<tr class="<?php echo($count % 2 != 0 ? "table-odd" : ""); ?>">
					<td><?php echo(date("M jS, Y", strtotime($order->order_date))); ?></td>
					<td><?php echo($order->order_id); ?></td>
					<td><?php echo($order->order_status_name); ?></td>
					<td><?php echo(count($products)); ?> <?php echo(count($products) == 1 ? "Item" : "Items"); ?></td>
					<?php
					/*<td>
						<ul>
							<?php
							foreach($product_text as $product)
							{
								?><li><?php echo($product); ?></li><?php
							}
							?>
						</ul>
					</td>
					*/
					?>
					<td>$<?php echo(number_format($order->order_total, 2)); ?></td>
					<td>
						<a href="<?php echo($page); ?>?task=order&order_id=<?php echo($order->order_id); ?>" title="View Details For Order <?php echo($order->order_id); ?>"><em class="far fa-file-alt" aria-hidden="true"></em></a>
						<?php
						if(count($tracking_urls) > 0)
						{
							foreach($tracking_urls as $tracking_url)
							{
								?><a href="<?php echo($tracking_url); ?>" target="_blank" title="View Tracking Information For Order <?php echo($order->order_id); ?>"><em class="fas fa-truck" aria-hidden="true"></em></a><?php
							}
						}
						?>
					</td>
				</tr>
			</tbody>
			<?php
			$count++;
		}
		?>
	</table>
</div>
