Total items in Admin new Order E-Mail
-
can someone tell me which snippet I can use to display the total number of products in the emails?
I have a snippet that only shows me in the overview and I would like to see this in the e-mails as wellfunction get_total_number_of_items_in_order( $order_id ) {
$order = wc_get_order( $order_id );
$total_quantity = 0;
foreach ( $order->get_items() as $item_id => $item ) {
$quantity = $item->get_quantity();
$total_quantity += $quantity;
}
return $total_quantity;
}function display_total_quantity_in_order_details( $order_id ) {
$total_quantity = get_total_number_of_items_in_order( $order_id );
?><tr>
<td class=”label”><?php esc_html_e( ‘Total Quantity:’, ‘woocommerce’ ); ?></td>
<td width=”1%”></td>
<td class=”total”>
<?php echo $total_quantity; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr><?php
}add_action( ‘woocommerce_admin_order_totals_after_discount’, ‘display_total_quantity_in_order_details’, 10 );
The topic ‘Total items in Admin new Order E-Mail’ is closed to new replies.