@if (empty($hideOrderNumber))
{{ __('Order number') }}: {{ $order->code }}
@endif
@foreach ($order->products as $orderProduct) @php $isFreeGift = (bool) Arr::get($orderProduct->options, 'is_free_gift', false); $origPrice = (float) ($orderProduct->original_price ?: $orderProduct->price); $salePrice = (float) $orderProduct->price; $offerReason = (string) $orderProduct->offer_reason; $discountPct = 0; if (preg_match('/get\s+([0-9]+(?:\.[0-9]+)?)%\s+off/i', $offerReason, $matches)) { $discountPct = (float) $matches[1]; } elseif (! $isFreeGift && $origPrice > 0 && $salePrice > 0 && $salePrice < $origPrice) { $discountPct = round((($origPrice - $salePrice) / $origPrice) * 100, 2); } if (! $isFreeGift && $discountPct > 0 && $origPrice > 0 && $salePrice >= $origPrice) { $salePrice = max($origPrice - ($origPrice * ($discountPct / 100)), 0); } $hasDiscount = ! $isFreeGift && $discountPct > 0 && $origPrice > $salePrice; $originalLineTotal = $origPrice * (int) $orderProduct->qty; $saleLineTotal = $salePrice * (int) $orderProduct->qty; $productUrl = $orderProduct->product && $orderProduct->product->id ? $orderProduct->product->original_product->url : null; $offerDiscountQty = (int) Arr::get($orderProduct->options, 'offer_discount_qty', 0); $offerRegularQty = max((int) $orderProduct->qty - $offerDiscountQty, 0); $offerOriginalUnitPrice = (float) Arr::get($orderProduct->options, 'offer_original_unit_price', $origPrice); $offerDiscountedUnitPrice = (float) Arr::get($orderProduct->options, 'offer_discounted_unit_price', $salePrice); $shouldRenderSplitSuccessRows = $hasDiscount && Arr::get($orderProduct->options, 'offer_type') === 'buy_x_get_y_percent' && $offerDiscountQty > 0 && $offerRegularQty > 0; @endphp @if ($shouldRenderSplitSuccessRows)
{{ $orderProduct->product_name }} {{ $offerDiscountQty }}

@if ($productUrl) {!! BaseHelper::clean($orderProduct->product_name) !!} @else {!! BaseHelper::clean($orderProduct->product_name) !!} @endif

{{ Arr::get($orderProduct->options, 'attributes', '') }}

@include(EcommerceHelper::viewPath('includes.cart-item-options-extras'), [ 'options' => $orderProduct->options, ]) {{ format_price($offerOriginalUnitPrice) }} {{ format_price($offerDiscountedUnitPrice) }} {{ (float) $discountPct }}% {{ __('off') }}

{{ format_price($offerOriginalUnitPrice * $offerDiscountQty) }} {{ format_price($offerDiscountedUnitPrice * $offerDiscountQty) }}

{{ $orderProduct->product_name }} {{ $offerRegularQty }}

@if ($productUrl) {!! BaseHelper::clean($orderProduct->product_name) !!} @else {!! BaseHelper::clean($orderProduct->product_name) !!} @endif

{{ Arr::get($orderProduct->options, 'attributes', '') }}

@include(EcommerceHelper::viewPath('includes.cart-item-options-extras'), [ 'options' => $orderProduct->options, ]) {{ format_price($offerOriginalUnitPrice) }}

{{ format_price($offerOriginalUnitPrice * $offerRegularQty) }}

@continue @endif
{{ $orderProduct->product_name }} {{ $orderProduct->qty }}

@if ($productUrl) {!! BaseHelper::clean($orderProduct->product_name) !!} @else {!! BaseHelper::clean($orderProduct->product_name) !!} @endif @if ($isFreeGift) 🎁 {{ __('Free Gift') }} @endif

{{ Arr::get($orderProduct->options, 'attributes', '') }}

@if (!empty($orderProduct->product_options) && is_array($orderProduct->product_options)) {!! render_product_options_html($orderProduct->product_options, $orderProduct->price) !!} @endif @include(EcommerceHelper::viewPath('includes.cart-item-options-extras'), [ 'options' => $orderProduct->options, ]) @if ($isFreeGift) {{ __('Free') }} @if ($origPrice > 0) {{ format_price($origPrice) }} @endif @elseif ($hasDiscount) {{ format_price($origPrice) }} {{ format_price($salePrice) }} {{ (float) $discountPct }}% {{ __('off') }} @else {{ format_price($salePrice) }} @endif
@if ($isFreeGift)

{{ __('FREE') }} @if ($origPrice > 0) {{ format_price($origPrice) }} @endif

@elseif ($hasDiscount)

{{ format_price($originalLineTotal) }} {{ format_price($saleLineTotal) }}

@else

{{ format_price($saleLineTotal) }}

@endif
@endforeach @if (!empty($isShowTotalInfo)) @include('plugins/ecommerce::orders.thank-you.total-info', compact('order')) @endif