@php
$discountedPrice = 0;
if (isset($disocuntonproduct)) {
$currentDate = time();
$fromDate = strtotime($disocuntonproduct->from_date);
$toDate = strtotime($disocuntonproduct->end_date);
if ($disocuntonproduct->active == 1) {
if ($disocuntonproduct->limited == 1) {
if ($currentDate >= $fromDate && $currentDate <= $toDate) {
$discountValue = $disocuntonproduct->discount_value;
$actualPrice = ProductClass::getOptionValue('_price', $product->productMeta);
if ($disocuntonproduct->discount_type == 1) {
$discountedPrice = $actualPrice - $discountValue;
} else {
$discountAmount = ($discountValue / 100) * $actualPrice;
$discountedPrice = $actualPrice - $discountAmount;
}
} else {
$discountedPrice = ProductClass::getOptionValue('_price', $product->productMeta);
}
} else {
$discountValue = $disocuntonproduct->discount_value;
$actualPrice = ProductClass::getOptionValue('_price', $product->productMeta);
if ($disocuntonproduct->discount_type == 1) {
$discountedPrice = $actualPrice - $discountValue;
} else {
$discountAmount = ($discountValue / 100) * $actualPrice;
$discountedPrice = $actualPrice - $discountAmount;
}
}
} else {
$discountedPrice = ProductClass::getOptionValue('_price', $product->productMeta);
}
} elseif ($collectionDiscount) {
$currentDate = time();
$fromDate = strtotime($collectionDiscount->from_date);
$toDate = strtotime($collectionDiscount->end_date);
if ($collectionDiscount->active == 1) {
if ($collectionDiscount->limited == 1) {
if ($currentDate >= $fromDate && $currentDate <= $toDate) {
$discountValue = $collectionDiscount->discount_value;
$actualPrice = ProductClass::getOptionValue('_price', $product->productMeta);
if ($collectionDiscount->discount_type == 1) {
$discountedPrice = $actualPrice - $discountValue;
} else {
$discountAmount = ($discountValue / 100) * $actualPrice;
$discountedPrice = $actualPrice - $discountAmount;
}
} else {
$discountedPrice = ProductClass::getOptionValue('_price', $product->productMeta);
}
} else {
$discountValue = $collectionDiscount->discount_value;
$actualPrice = ProductClass::getOptionValue('_price', $product->productMeta);
if ($collectionDiscount->discount_type == 1) {
$discountedPrice = $actualPrice - $discountValue;
} else {
$discountAmount = ($discountValue / 100) * $actualPrice;
$discountedPrice = $actualPrice - $discountAmount;
}
}
} else {
$discountedPrice = ProductClass::getOptionValue('_price', $product->productMeta);
}
} else {
$discountedPrice = ProductClass::getOptionValue('_price', $product->productMeta);
}
@endphp
@if (isset($disocuntonproduct) ||
(isset($collectionDiscount) &&
$discountedPrice !== ProductClass::getOptionValue('_price', $product->productMeta)))
@if (
($disocuntonproduct && $disocuntonproduct->limited == 1) ||
($collectionDiscount && $collectionDiscount->limited == 1))
@if ($currentDate >= $fromDate && $currentDate <= $toDate)
@if ($disocuntonproduct && $disocuntonproduct->active == 1)
{{ $disocuntonproduct->title ?? $collectionDiscount->title }}
${{ ProductClass::getOptionValue('_price', $product->productMeta) }}
@elseif ($collectionDiscount && $collectionDiscount->active == 1)
{{ $disocuntonproduct->title ?? $collectionDiscount->title }}
${{ ProductClass::getOptionValue('_price', $product->productMeta) }}
@else
@if ($product->productMeta->where('option', '_gst')->first()->value ?? 0)
GST Included
@endif
@if (isset($discountedPrice))
${{ $discountedPrice }}
@else
${{ ProductClass::getOptionValue('_price', $product->productMeta) }}
@endif
@endif
@endif
@else
@if ($disocuntonproduct && $disocuntonproduct->active == 1)
{{ $disocuntonproduct->title ?? $collectionDiscount->title }}
${{ ProductClass::getOptionValue('_price', $product->productMeta) }}
@elseif ($collectionDiscount && $collectionDiscount->active == 1)
{{ $disocuntonproduct->title ?? $collectionDiscount->title }}
${{ ProductClass::getOptionValue('_price', $product->productMeta) }}
@else
@if ($product->productMeta->where('option', '_gst')->first()->value ?? 0)
GST Included
@endif
@if (isset($discountedPrice))
${{ $discountedPrice }}
@else
${{ ProductClass::getOptionValue('_price', $product->productMeta) }}
@endif
@endif
@endif
@endif
@if ($product->productMeta->where('option', '_gst')->first()->value ?? 0)
GST Included
@endif
@if (isset($discountedPrice))
${{ $discountedPrice }}
@else
${{ ProductClass::getOptionValue('_price', $product->productMeta) }}
@endif