I set up a Virtuemart installation (V.3.4.2). By default, Virtuemart lists all orders a user made in the user account of a registered user. This is rendered in com_virtuemart/views/orders/list.php
Sorrily, Virtuemart also lists orders with the status "pending" and "cancelled" in this list.
<?php
$k = 0;
foreach ($this->orderlist as $row) {
$editlink = JRoute::_('index.php?option=com_virtuemart&view=orders&layout=details&order_number=' . $row->order_number, FALSE);
?>
<tr class="<?php echo "row$k"; ?> orderslist">
<td class="orderslist">
<a class="spin" href="<?php echo $editlink; ?>" rel="nofollow" <?php echo $ajaxUpdate?> ><?php echo $row->order_number; ?></a>
<?php echo shopFunctionsF::getInvoiceDownloadButton($row) ?>
</td>
<td class="orderslist" style="text-align: center;">
<?php echo vmJsApi::date($row->created_on,'LC4',true); ?>
</td>
<!--td align="left">
<?php //echo vmJsApi::date($row->modified_on,'LC3',true); ?>
</td -->
<td class="orderslist">
<?php echo shopFunctionsF::getOrderStatusName($row->order_status); ?>
</td>
<td class="orderslist" style="text-align: center;">
<?php echo $this->currency->priceDisplay($row->order_total, $row->currency); ?>
</td>
</tr>
<?php
$k = 1 - $k;
}
?>
Is there any elegant way to filter out unwanted order states like "cancelled or pending", so that the user only sees certain order states like confirmed orders, refunded and finished orders?
Thank you very much in advance!
You can filter your list by filtering via $row->order_status.
Change:
$editlink = JRoute::_('index.php?option=com_virtuemart&view=orders&layout=details&order_number=' . $row->order_number, FALSE);
?>
to:
$editlink = JRoute::_('index.php?option=com_virtuemart&view=orders&layout=details&order_number=' . $row->order_number, FALSE);
if ($row->order_status == 'P' OR $row->order_status == 'X') {
// do nothing
} else { ?>
and:
<?php
$k = 1 - $k;
}
?>
to:
<?php
$k = 1 - $k;
}
}
?>
If you need to filter any other statuses, you can find the corresponding short codes like P and X via VirtueMart Menu -> Configuration -> Order Statuses.