# orders/index.php

## Listado de pedidos

Este template permite mostrar todos los pedidos realizados por un cliente.&#x20;

| Objetos disponibles | Descripción          |
| ------------------- | -------------------- |
| $\_order            | Pedidos.             |
| $\_total            | Cantidad de pedidos. |

{% hint style="info" %}
Para visualizar este template el usuario debe estar autenticado en su cuenta
{% endhint %}

#### Código de ejemplo de un listado simple con seguimiento de envíos

```php
<div class="container">
	<div id="global" class="micuenta-detalle">
		<h1>Mis pedidos</h1>
				
		<table class="account">
			<tr>
				<th>N. de pedido</th>
				<th>Fecha</th>
				<th>Enviado a</th>
				<th>Total</th>
				<th>Estado de su pedido</th>
				<th></th>
			</tr>
			<?php while($_order->getNext()): ?>
			<tr onclick="location.href='<?=$_order->getURL()?>'">
				<td><?=$_order->getId()?></td>
				<td><?=$_front->date($_order->get('created'))?></td>
				<td><?=$_order->get('name').' '.$_order->get('surname')?></td>
				<td><?=$_front->price($_order->get('total'))?></td>
				<td>
					<?=$_order->get('status')->get('name')?>
					<small>Última actualización: <?=$_front->date(current($_order->get('history'))->get('created'))?></small>
					<?php if($_order->get('tracking')->get('code')): ?>
					<small>Seguimiento: <?=$_order->get('tracking')->get('code')?></small>
					<?php endif; ?>
				</td>
				<td class="action">
					<?php if(!$_order->get('orders_status.approved')): ?>
					<a href="<?=HOST?>pedidos/<?=$_order->get('id')?>/reintentar" class="button">Reintentar compra</a>
					<?php elseif($_order->couponsOnly()): ?>
					<a href="<?=HOST?>pedidos/<?=$_order->get('id')?>/pdf" class="button">Descargar cupón</a>
					<?php endif; ?>
				</td>
			</tr>
			<?php endwhile; ?>
		</table>
	</div>
</div>
```

#### Código de ejemplo de un listado con cupones/promo codes aplicados

```
<h1>Mis pedidos</h1>
		
<?php if(Configuration::value('COUPONS')): ?>
<table class="account">
	<tr>
		<th>N. de pedido</th>
		<th>Fecha</th>
		<th>Oferta</th>
		<th>Estado de su pedido</th>
		<th>Total</th>
		<th></th>
	</tr>
	<?php 
		while($_order->getNext()):
			foreach($_order->get('products') as $product):
	?>
	<tr onclick="location.href='<?=$_order->getURL()?>'">
		<td class="full"><?=$_order->getId()?></td>
		<td class="full"><?=$_front->date($_order->get('created'))?></td>
		<td>
			<?=$product->get('product')->get('name')?>
			<?php foreach($product->get('coupons') as $coupon): ?>
				<?php if($coupon->get('redeemed')): ?>
				<br /><small><strong>Fecha de redención: <?=$_front->date($coupon->get('redeemedDate'))?></strong></small>			
				<?php elseif($product->get('product')->get('couponValidTo') != null): ?>
				<br /><small><strong>Fecha de vencimiento: <?=$_front->date($product->get('product')->get('couponValidTo'))?></strong></small>
				<?php endif; ?>
			<?php endforeach; ?>
		</td>
		<td><?=$_order->get('status')->get('name')?></td>
		<td class="full"><?=$_front->price($_order->get('total'))?></td>
		<td class="action">
			<?php if($_order->get('status')->get('approved')): ?>
				<?php foreach($product->get('coupons') as $coupon): ?>
					<?php if($coupon->get('redeemed')): ?>
					<span class="button disabled">Cupón redimido</span>
					<?php elseif($product->get('product')->get('couponValid')): ?>
					<a href="<?=HOST?>pedidos/<?=$_order->get('id')?>/pdf/<?=$coupon->get('id')?>" class="button">Descargar cupón</a>
					<?php else: ?>
					<span class="button disabled">Cupón vencido</span>
					<?php endif; ?>
				<?php endforeach; ?>
			<?php endif; ?>
		</td>
	</tr>
	<?php endforeach; endwhile; ?>
</table>
<?php else: ?>
<table class="account">
	<tr>
		<th>N. de pedido</th>
		<th>Fecha</th>
		<th>Estado de su pedido</th>
		<th>Total</th>
		<th></th>
	</tr>
	<?php while($_order->getNext()): ?>
	<tr onclick="location.href='<?=$_order->getURL()?>'">
		<td><?=$_order->getId()?></td>
		<td><?=$_front->date($_order->get('created'))?></td>
		<td><?=$_order->get('status')->get('name')?></td>
		<td><?=$_front->price($_order->get('total'))?></td>
		<td class="action">
			<?php if(!$_order->get('orders_status.approved')): ?>
			<a href="<?=HOST?>pedidos/<?=$_order->get('id')?>/reintentar" class="button">Reintentar compra</a>
			<?php elseif($_order->couponsOnly()): ?>
			<a href="<?=HOST?>pedidos/<?=$_order->get('id')?>/pdf" class="button">Descargar cupón</a>
			<?php endif; ?>
		</td>
	</tr>
	<?php endwhile; ?>
</table>
<?php endif; ?>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ventaspop.gitbook.io/docs/pedidos/orders-index.php.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
