Snippets

Visser Labs Show a unique Order Item row matching the Quantity value for each Order Item

Created by Michael Visser

File functions.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+function custom_woo_ce_order_items_individual_output( $output, $order, $order_item ) {
+
+	if( !empty( $order->order_items ) ) {
+		// Check the Order Item has a Product ID
+		if( !empty( $order_item->product_id ) ) {
+			// Multiply the Order Item by the Quantity value
+			if( !empty( $order_item->quantity ) ) {
+				$size = $order_item->quantity;
+				for( $i = 1; $i < $size; $i++ ) {
+					$order_temp = (object)(array)$order;
+					$output[] = apply_filters( 'woo_ce_order_items_individual', $order_temp, $order_item );
+					unset( $order_temp );
+				}
+			}
+		}
+	}
+	return $output;
+
+}
+add_filter( 'woo_ce_order_items_individual_output', 'custom_woo_ce_order_items_individual_output', 10, 3 );
+?>
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.