WC_Admin_Report::sales_sparkline
Prepares the markup for a sparkline to show sales in the last X days.
Метод класса: WC_Admin_Report{}
Хуков нет.
Возвращает
Строку.
Использование
$WC_Admin_Report = new WC_Admin_Report(); $WC_Admin_Report->sales_sparkline( $id, $days, $type );
- $id(int)
- ID of the product to show. Blank to get all orders.
По умолчанию: '' - $days(int)
- Days of stats to get.
По умолчанию: 7 days - $type(строка)
- Type of sparkline to get.
По умолчанию: 'sales'
Код WC_Admin_Report::sales_sparkline() WC Admin Report::sales sparkline WC 10.3.4
public function sales_sparkline( $id = '', $days = 7, $type = 'sales' ) {
$sparkline = $this->get_sales_sparkline( $id, $days, $type );
$total = $sparkline['total'];
if ( 'sales' === $type ) {
/* translators: 1: total income 2: days */
$tooltip = sprintf( __( 'Sold %1$s worth in the last %2$d days', 'woocommerce' ), wp_strip_all_tags( wc_price( $total ) ), $days );
} else {
/* translators: 1: total items sold 2: days */
$tooltip = sprintf( _n( 'Sold %1$d item in the last %2$d days', 'Sold %1$d items in the last %2$d days', $total, 'woocommerce' ), $total, $days );
}
$sparkline_data = $sparkline['data'];
return '<span class="wc_sparkline ' . ( ( 'sales' === $type ) ? 'lines' : 'bars' ) . ' tips" data-color="#777" data-tip="' . esc_attr( $tooltip ) . '" data-barwidth="' . 60 * 60 * 16 * 1000 . '" data-sparkline="' . wc_esc_json( wp_json_encode( $sparkline_data ) ) . '"></span>';
}