Alter summary report
1 2 3 4 5 6 7 8 9 10 11 12 |
//sort by sku add_action('woe_summary_before_output' , function() { uasort($_SESSION['woe_summary_products'], function($a,$b) { if( empty($a['sku']) AND empty($b['sku']) ) return 0; if( empty($a['sku']) ) return 1; if( empty($b['sku']) ) return -1; return strcmp($a['sku'],$b['sku']); }); }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
//add Total row at bottom add_action('woe_summary_before_output' , function() { $row1 = reset($_SESSION['woe_summary_products']); $keys = array_keys($row1); $key1 = reset($keys); //init $total = array(); foreach($row1 as $k=>$v) $total[$k] = strpos($k,"summary_report_total")!==false ? 0 : ""; $total[$key1] = "Total"; //sum foreach($_SESSION['woe_summary_products'] as $k=>$data) { foreach($data as $k=>$v) if(strpos($k,"summary_report_total")!==false) $total[$k] +=$v; } //done $_SESSION['woe_summary_products'][] = array(""); //empty $_SESSION['woe_summary_products'][] = $total; }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Add column "Total Orders" to "Summary by products" class WOE_Total_Orders_Summary{ function __construct() { add_filter('woe_summary_headers',function ($headers) { $headers[] = "Total Orders"; // just text return $headers; }); add_filter('woe_summary_column_keys',function ($cols) { $cols['count'] = 0; // new key with default value return $cols; }); add_action('woe_summary_products_add_item',function ($key, $item, $order) { $_SESSION['woe_summary_products'][$key]['count'] ++; // add 1 for each order },10,3); } } new WOE_Total_Orders_Summary(); |