-
@forelse($checkout->line_items ?? [] as $item)
@php
$itemVid = trim(preg_replace('#^gid://shopify/ProductVariant/#', '', trim((string) ($item['variant_id'] ?? ''))));
$itemPid = trim(preg_replace('#^gid://shopify/Product/#', '', trim((string) ($item['product_id'] ?? ''))));
$itemKey = $itemVid !== '' ? $itemVid : ($itemPid !== '' ? 'p-' . $itemPid : '');
$itemPurchased = $itemKey !== '' && array_key_exists($itemKey, $productPurchasedByCheckoutId[$checkout->id] ?? []);
$itemPrice = (float) ($item['price'] ?? 0);
$itemCost = (float) ($item['cost'] ?? 0);
$itemQty = (int) ($item['quantity'] ?? 1);
$itemSaleTotal = $itemPrice * $itemQty;
$itemCostTotal = $itemCost * $itemQty;
$itemProfitDisplay = null;
$itemProfitAfterFees = null;
if ($latestDiscount && $latestDiscount->status === 'active' && $itemSaleTotal > 0) {
$cartSaleTotal = 0;
foreach ($checkout->line_items ?? [] as $i) {
$cartSaleTotal += ((float) ($i['price'] ?? 0)) * ((int) ($i['quantity'] ?? 1));
}
if ($cartSaleTotal > 0) {
$dType = $latestDiscount->discount_type ?? 'percentage';
$dVal = (float) ($latestDiscount->discount_value ?? 0);
$discountAmount = $dType === 'percentage' ? $cartSaleTotal * $dVal / 100 : min($dVal, $cartSaleTotal);
$itemFinal = $itemSaleTotal - ($discountAmount * ($itemSaleTotal / $cartSaleTotal));
$itemProfitDisplay = $itemFinal - $itemCostTotal;
$totalFinal = $cartSaleTotal - $discountAmount;
if ($totalFinal > 0) {
$itemShare = $itemFinal / $totalFinal;
$feeGw = $feeDefaultGateway ? $itemFinal * $feeGatewayPct / 100 : 0;
$feeComm = $feeDefaultCommission ? $feeCommission * $itemShare : 0;
$feeShip = $feeDefaultShipping ? $feeShipping * $itemShare : 0;
$feeExt = $feeDefaultExtra ? $feeExtra * $itemShare : 0;
$itemProfitAfterFees = $itemProfitDisplay - $feeGw - $feeComm - $feeShip - $feeExt;
}
}
}
@endphp
-
@if(!empty($item['image']))
@endif{{ $item['title'] ?? 'Product' }} × {{ $itemQty }} @if($itemPurchased) Order completed @endifCost: @if($itemCost > 0)${{ number_format($itemCost, 1) }}@else—@endif Sale: @if($itemPrice > 0)${{ number_format($itemPrice, 2) }}@else—@endif @if($itemProfitDisplay !== null) Profit: ${{ number_format($itemProfitDisplay, 2) }} @if($itemProfitAfterFees !== null) Profit (after fees): ${{ number_format($itemProfitAfterFees, 2) }} @if($loop->first) @endif @endif @endif
@empty
- — @endforelse
@if($codeAppliesToProducts) This code applies to the product(s) shown above. @else This discount is not assigned to the product(s) in this checkout. @endif
@if($discount->discount_email_sent_at)Notify blocked — Instagram Story Purchase.
@elseif($discountBlockedByOpenOffer)Notify blocked — open offer on this product.
@elseif(($checkout->email || $checkout->phone) && $discount->status !== 'paused_deal') @endifNo email on file — notification will be sent by SMS only.
@endif @elseif(!$blockStampReason && $checkout->checkoutDiscounts->whereIn('status', ['active', 'paused_deal'])->isEmpty()){{ $checkout->create_discount_reason ?? 'This customer already has an active discount for these products.' }}
@endif