Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing fatal error if $primary_sale_chart_data is null #169

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions classes/class-swsales-reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,6 @@ public static function show_report( $sitewide_sales ) {
}
}

// Get the best day for primary sale to highlight in the chart.
$highest_daily_revenue = max( $primary_sale_chart_data );
if ( $highest_daily_revenue > 0 ) {
$highest_daily_revenue_key = array_search( $highest_daily_revenue, $primary_sale_chart_data );
}

// Display the chart.
if ( is_array( $primary_sale_chart_data ) ) { ?>
<div id="swsales_sale_revenue_by_day" class="swsales_reports-box swsales_chart_area">
Expand Down Expand Up @@ -364,6 +358,11 @@ function drawVisualization() {
}
?>,
<?php
// Get the best day for primary sale to highlight in the chart.
$highest_daily_revenue = max( $primary_sale_chart_data );
if ( $highest_daily_revenue > 0 ) {
$highest_daily_revenue_key = array_search( $highest_daily_revenue, $primary_sale_chart_data );
}
if ( ! empty( $highest_daily_revenue_key ) && $date === $highest_daily_revenue_key ) {
echo wp_json_encode( esc_html__( 'Best Day', 'sitewide-sales' ) );
} elseif ( date( 'd.m.Y' ) === date( 'd.m.Y', strtotime( $date ) ) ) {
Expand Down