WC_Report_Sales_By_Category::get_chart_legend() public WC 1.0
Get the legend for the main chart sidebar.
{} Это метод класса: WC_Report_Sales_By_Category{}
Хуков нет.
Возвращает
Массив.
Использование
$WC_Report_Sales_By_Category = new WC_Report_Sales_By_Category(); $WC_Report_Sales_By_Category->get_chart_legend();
Код WC_Report_Sales_By_Category::get_chart_legend() WC Report Sales By Category::get chart legend WC 5.0.0
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;
}