all product code
{{-- @if (isset($value['child_items']) && count($value['child_items']) > 0)
@php
$variantTypes =
[];
foreach
($value['child_items'] as $childItem) {
foreach (
$childItem['variant_id'] ?? []
as
$variant
) {
$variantData =
$variant[
'child_product_item_variant'
] ?
? null;
if
($variantData) {
$id
=
$variantData[
'product_variation_id'
] ?? null;
$type = strtolower(
$variantData[
'product_variation_type'
] ?? '',
);
if
(
$id &&
$type &&
!isset($variantTypes[$id])
) {
$variantTypes[$id] = $type;
}
}
}
}
@endphp
<div
class="variant-selectors mt-3"
data-product-
id="{{ $value['id'] }}"
data-child-
items='@json($value[' child_items'] ?? [])'>
@foreach
($variantTypes as $variationTypeId => $type)
@php
$values
= [];
foreach
(
$value['child_items']
as
$childItem
) {
foreach (
$childItem['variant_id'] ?? []
as $variant
) {
$variantData =
$variant[
'child_product_item_variant'
] ?? null;
$attrData =
$variant[
'child_product_item_variant_attribute'
] ?? null;
if (
$variantData &&
strtolower(
$variantData[
'product_variation_type'
] ?? '',
) === strtolower($type)
) {
$id =
$attrData[
'product_variation_id'
] ?? null;
$unit =
$attrData[
'product_variation_units'
] ?? null;
if (
$id &&
$unit &&
!isset($values[$id])
) {
$values[$id] = $unit;
}
}
}
@endphp
<div
class="mb-2">
<label
class="fw-medium d-block mb-1 text-capitalize text-dark">
{{ ucfirst($type) }}:
</label>
<div
class="d-flex flex-wrap gap-2 variant-group"
data-variant-attribute-type="{{ $type }}">
@foreach ($values as $id => $val)
<label
class="variant-option-label">
<input type="radio"
class="variant-option-input d-none"
name="variant_{{ $type }}"
value="{{ $id }}"
data-unit="{{ $val }}"
data-type="{{ $type }}"
data-variation-type-id="{{ $variationTypeId }}"
@if ($loop->first) checked @endif>
<div class="variant-option rounded-pill px-3 py-1 small fw-semibold border @if
($loop->first) bg-success text-success @else bg-secondary text-info @endif"
style="cursor: pointer;">
{{ $val }}
</div>
</label>
@endforeach
</div>
</div>
@endforeach
</div>
@endif --}}
{{-- <div class="d-flex flex-wrap gap-2 variant-group" data-variant-attribute-
type="{{ $type }}">
@foreach ($values as $id => $val)
<label class="variant-option-label">
<input type="radio"
class="variant-option-input d-none"
name="variant_{{ $type }}"
value="{{ $id }}"
data-unit="{{ $val }}"
data-type="{{ $type }}"
data-variation-type-id="{{ $variationTypeId }}"
@if ($loop->first) checked @endif>
<div class="variant-option rounded-pill px-3 py-1 small fw-semibold border @if
($loop->first) bg-success text-success @else bg-secondary text-info @endif"
style="cursor: pointer;">
{{ $val }}
</div>
</label>
@endforeach
</div>
--}}