{include "./sales_sidebar.html" inline}

[`Cohorts`]

{if $all_zeroes}
[`Not enough sales data to build cohort chart for the selected period.`]
{/if}
{* Too easy to shoot yourself in the foot *}
    {$cohort_types = [ 'sales' => "[`Sales`]", 'profit' => "[`Profit`]", 'order_count' => "[`Number of orders`]", 'clv' => "[`LTV`]", 'roi' => "[`ROI`]" ]} {foreach $cohort_types as $type_id => $type_name}
  • {$type_name|escape}
  • {/foreach}
{if $table_data}
{strip} {if $group_by == 'quarters'} {$header_str = "[`Quarter %s`]"} {elseif $group_by == 'months'} {$header_str = "[`Month %s`]"} {elseif $group_by == 'weeks'} {$header_str = "[`Week %s`]"} {else} {$header_str = "[`Day %s`]"} {/if} {foreach $table_data as $row} {/foreach} {/strip} {$index = 0} {foreach $table_data as $reg_date => $row} {$index = $index + 1} {foreach array_keys($table_data) as $col_date}{strip} {if empty($row[$col_date@index])} {else} {$stats = $row[$col_date@index]} {$percent = 100-$stats.percent_of_max} {$_bg_style = "linear-gradient(to bottom, transparent 0%, transparent {number_format($percent,2)}%, {$stats.color} {number_format($percent,2)}%, {$stats.color} 100%)"} {if !empty($request_options.type) && $request_options.type == "roi" && (round($stats.metric) <= 100)} {$_image_url = "{$wa_url}wa-apps/shop/img/patterns/white-pattern.png"} {$_bg_style = "background: repeating-linear-gradient(-45deg, var(--background-color-blank), var(--background-color-blank) 12px, var(--border-color-input-outlined) 12px, var(--border-color-input-outlined) 15px);"} {else} {$_bg_style = "background: {$_bg_style};"} {/if} {/if} {/strip}{/foreach} {/foreach}
{sprintf($header_str, $row@index + 1)}[`Total`]
{$table_headers[$reg_date]} {if in_array(ifset($request_options.type), ['sales', 'profit', 'clv'])} {wa_currency_html($stats.metric, $def_cur)} {elseif ifset($request_options.type) == 'roi'} {round($stats.metric)}% {else} {round($stats.metric, 2)} {/if} {strip} {if in_array(ifset($request_options.type), ['sales', 'profit', 'clv'])} {wa_currency_html($table_totals[$reg_date], $def_cur)} {elseif ifset($request_options.type) == 'roi'} {round($table_totals[$reg_date])}% {else} {round($table_totals[$reg_date], 2)} {/if} {/strip}
{/if}