• Resolved mmc501

    (@mmc501)


    I’m exporting a product sales report.
    So for Product A there are 2 Orders
    Order 1 bought Qty 1
    Order 2 bought Qty 2
    Total Sales of Product A = 3

    When i export currently there are 2 rows. and Order 2 displays Qty 2

    Is it possibly to have an export where it would display Order 2 on 2 lines as the item has Qty 2?

    So 3 sales of Product A so on 3 lines on the export?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mmc501

    (@mmc501)

    Actually – just found the solution in your code samples.

    https://algolplus.com/plugins/code-samples/

    // duplicate each item "qty" times! and set qty=1 for the item
    add_filter( "woe_fetch_order_products", function ($products, $order, $labels, $format, $static_vals) {
    	$new_products = array();
    	//need to know counters, as field "qty" can be omitted in output!
    	foreach($order->get_items('line_item') as $pos=>$item) {
    				if( !isset($products[$pos]) )
    						continue;
    				if( isset($products[$pos]['qty']) )
    						$products[$pos]['qty'] =1;
    				for($i=0;$i< $item['qty'];$i++) 
    						$new_products[] = $products[$pos];
    	} 
    	return $new_products;
    } , 10, 5);
    Plugin Author algol.plus

    (@algolplus)

    Good news!

    I’m sorry for late reply.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Export Product Items on Single line’ is closed to new replies.