I have the following code so far for my receipt:
<?php foreach ($order->get_items() as $item) {
/* @var $item \WC_Order_item */
$meta = $item['item_meta'];
$meta = array_filter($meta, function ($key) {
return !in_array($key, Order::getHiddenKeys());
}, ARRAY_FILTER_USE_KEY);
?>
<tbody>
<tr>
<td colspan="2"><?= $item['qty']; ?>x <?= $item['name']; ?></td>
<td
rowspan="<?= count($meta) + 1; ?>"><?= wc_price($item->get_data()['total'], array('currency' => $order->get_currency())); ?></td>
</tr>
<?php $meta = array_map(function ($meta, $key) {
$result = '<tr>';
$result .= '<td>' . $key . '</td>';
$result .= '<td>' . $meta . '</td>';
$result .= '</tr>';
return $result;
}, $meta, array_keys($meta));
echo implode(PHP_EOL, $meta);
?>
</tbody>
I am looking to add categories to help our chef. At minimum, we would like to add the category after the item name in brackets. But ideally, we would like to split all the items by category along with a category heading, and we would like the categories to display in ascending order to their given tag_id if possible. Confident in editing the HTML just not the PHP.
Any help would be appreciated! Here is what are receipt looks like so far: