@if ($item->transaksiItemSpecifications && count($item->transaksiItemSpecifications) > 0)
@foreach ($item->transaksiItemSpecifications as $spec)
@if ($spec->spesifikasiProduk && $spec->spesifikasiProduk->spesifikasi)
{{ $spec->spesifikasiProduk->spesifikasi->nama_spesifikasi }}
@php
$hargaSatuan = 0;
$totalHarga = $spec->price ?? 0;
$nilai = $spec->nilai_spesifikasi ?? null;
// If nilai_spesifikasi is empty, check value field
if (empty($nilai) && isset($spec->value)) {
$nilai = $spec->value;
}
if ($spec->input_type == 'select' && $spec->bahan) {
// For select type (material selection)
echo $spec->bahan->nama_bahan .
': ' .
$item->kuantitas .
' x Rp ' .
number_format($totalHarga / $item->kuantitas, 0, ',', '.') .
' = Rp ' .
number_format($totalHarga, 0, ',', '.');
} elseif ($nilai && $spec->spesifikasiProduk->spesifikasi) {
// For numeric type (size, etc)
if ($totalHarga > 0 && $nilai > 0) {
$hargaSatuan = $totalHarga / $nilai;
}
echo number_format($nilai, 2, ',', '.') .
' ' .
($spec->spesifikasiProduk->spesifikasi->satuan ?? '') .
' x Rp ' .
number_format($hargaSatuan, 0, ',', '.') .
' = Rp ' .
number_format($totalHarga, 0, ',', '.');
} else {
echo 'Rp ' . number_format($totalHarga, 0, ',', '.');
}
@endphp
@endif
@endforeach
@if (!$loop->last)