LLMS_Analytics::get_total_sold_by_day( [array] $orders, [string] $start_date, [string] $end_date )

Get array of date / total $ made on site Uses start and end date for timeline


Description Description


Parameters Parameters

$orders

([array]) (Required) [array of order objects]

$start_date

([string]) (Required) [date yyyy-mm-dd]

$end_date

([string]) (Required) [date yyyy-mm-dd]


Top ↑

Return Return

([array]) [array of date / daily total]


Top ↑

Source Source

File: includes/class.llms.analytics.php

	public static function get_total_sold_by_day( $orders, $start_date, $end_date ) {

		$total_by_day = array();

		$date = $start_date;

		while ( $date <= $end_date ) {

			//set daily total to 0;
			$daily_total = 0;

			//loop through all objects and add values to total
			foreach ( $orders as $key => $value ) {
				if ( $value->order_date == $date ) {
					$daily_total += $value->order_total;
				}
			}
			$results = array( $date, $daily_total );

			$total_by_day[] = $results;

			//add one day to date
			$date = LLMS_Date::db_date( $date . '+ 1 day' );

		}

		return $total_by_day;

	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.