WC_Report_Sales_By_Category::get_chart_legend()
Get the legend for the main chart sidebar.
Description Description
Return Return
(array)
Source Source
File: includes/admin/reports/class-wc-report-sales-by-category.php
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | public function get_chart_legend() { if ( empty ( $this ->show_categories ) ) { return array (); } $legend = array (); $index = 0; foreach ( $this ->show_categories as $category ) { $category = get_term( $category , 'product_cat' ); $total = 0; $product_ids = $this ->get_products_in_category( $category ->term_id ); foreach ( $product_ids as $id ) { if ( isset( $this ->item_sales[ $id ] ) ) { $total += $this ->item_sales[ $id ]; } } $legend [] = array ( /* translators: 1: total items sold 2: category name */ 'title' => sprintf( __( '%1$s sales in %2$s' , 'woocommerce' ), '<strong>' . wc_price( $total ) . '</strong>' , $category ->name ), 'color' => isset( $this ->chart_colours[ $index ] ) ? $this ->chart_colours[ $index ] : $this ->chart_colours[0], 'highlight_series' => $index , ); $index ++; } return $legend ; } |