0, 'lowstock' => 0, 'outofstock' => 0 );
$table_data = $data['stock']['table'] ?? array();
$publishers_summary = $data['stock']['publishers'] ?? array();
// Group products count by stock status
$grouped_counts = array(
'instock' => 0,
'lowstock' => 0,
'outofstock' => 0,
);
foreach ( $table_data as $row ) {
$status = $row['status'];
if ( isset( $grouped_counts[ $status ] ) ) {
$grouped_counts[ $status ]++;
} else {
$grouped_counts[ $status ] = 1;
}
}
$total_products = $summary['instock'] + $summary['lowstock'] + $summary['outofstock'];
?>
array(
'label' => __( 'In Stock', '360-analytics-for-woocommerce' ),
'count' => $summary['instock'],
'color' => '#10b981',
),
'lowstock' => array(
'label' => __( 'Low Stock', '360-analytics-for-woocommerce' ),
'count' => $summary['lowstock'],
'color' => '#f59e0b',
),
'outofstock' => array(
'label' => __( 'Out of Stock', '360-analytics-for-woocommerce' ),
'count' => $summary['outofstock'],
'color' => '#ef4444',
),
);
foreach ( $statuses_meta as $key => $meta ) {
$percentage = $total_products > 0 ? round( ( $meta['count'] / $total_products ) * 100, 1 ) : 0;
?>
-