context['product-table-columns'])) { $line_items = collect($this->entity->line_items); $tax1 = $line_items->where('tax_name1', '<>', '')->where('type_id', 1)->count(); $tax2 = $line_items->where('tax_name2', '<>', '')->where('type_id', 1)->count(); $tax3 = $line_items->where('tax_name3', '<>', '')->where('type_id', 1)->count(); $taxes = []; if ($tax1 > 0) { array_push($taxes, '$product.tax_rate1'); } if ($tax2 > 0) { array_push($taxes, '$product.tax_rate2'); } if ($tax3 > 0) { array_push($taxes, '$product.tax_rate3'); } $key = array_search('$product.tax', $this->context['product-table-columns'], true); if ($key) { array_splice($this->context['product-table-columns'], $key, 1, $taxes); } } } /** * Calculates the remaining colspans. * * @param int $taken * @return int */ public function calculateColspan(int $taken): int { $total = (int) count($this->context['product-table-columns']); return (int)$total - $taken; } /** * Return "true" or "false" based on null or empty check. * We need to return false as string because of HTML parsing. * * @param mixed $property * @return string */ public function toggleHiddenProperty($property): string { if (is_null($property)) { return 'false'; } if (empty($property)) { return 'false'; } return 'true'; } }