[`Cohorts`]
{if $all_zeroes}
{* Too easy to shoot yourself in the foot *}
[`Not enough sales data to build cohort chart for the selected period.`]
{/if}
[`Group by`]:
{$group_by_options = [
'weeks' => "[`week`]",
'months' => "[`month`]",
'quarters' => "[`quarters`]"
]}
-
{$cohort_types = [
'sales' => "[`Sales`]",
'profit' => "[`Profit`]",
'order_count' => "[`Number of orders`]",
'clv' => "[`LTV`]",
'roi' => "[`ROI`]"
]}
{foreach $cohort_types as $type_id => $type_name}
{/foreach}
| {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} | {sprintf($header_str, $row@index + 1)} | {/foreach}[`Total`] | {/strip}|
|---|---|---|---|
| {$table_headers[$reg_date]} | {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 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} | {/if} {/strip}{/foreach}{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} |