@php $summaryOrders = isset($orders) ? collect($orders) : collect([$order]); $summarySubTotal = (float) $summaryOrders->sum(function ($summaryOrder): float { return (float) $summaryOrder->products ->reject(fn ($orderProduct) => (bool) Arr::get($orderProduct->options, 'is_free_gift', false)) ->sum(function ($orderProduct): float { $unitPrice = (float) $orderProduct->price; $originalPrice = (float) $orderProduct->original_price; $hasOrderPromotion = (bool) $orderProduct->offer_rule_id || filled($orderProduct->offer_reason); if ($hasOrderPromotion && $originalPrice > $unitPrice) { $unitPrice = $originalPrice; } return $unitPrice * (int) $orderProduct->qty; }); }); $summaryShippingAmount = (float) $summaryOrders->sum('shipping_amount'); $summaryDiscountAmount = (float) $summaryOrders->sum('discount_amount'); $summaryTaxAmount = (float) $summaryOrders->sum('tax_amount'); $summaryPaymentFee = (float) $summaryOrders->sum('payment_fee'); $summaryTotalAmount = max($summarySubTotal - $summaryDiscountAmount + $summaryShippingAmount + $summaryTaxAmount + $summaryPaymentFee, 0); @endphp @if ( $summarySubTotal != $summaryTotalAmount || $summaryShippingAmount > 0 || (EcommerceHelper::isTaxEnabled() && $summaryTaxAmount > 0) || $summaryDiscountAmount > 0 )
@endif @if ($summarySubTotal != $summaryTotalAmount) @include('plugins/ecommerce::orders.thank-you.total-row', [ 'label' => __('Subtotal'), 'value' => format_price($summarySubTotal), ]) @endif @if (EcommerceHelper::isTaxEnabled() && $summaryTaxAmount > 0) @include('plugins/ecommerce::orders.thank-you.total-row', [ 'label' => __('Tax'), 'value' => format_price($summaryTaxAmount), ]) @endif @if ($summaryDiscountAmount > 0) @include('plugins/ecommerce::orders.thank-you.total-row', [ 'label' => __('Promotion discount'), 'value' => '-' . format_price($summaryDiscountAmount), ]) @endif @if ($summaryShippingAmount > 0) @include('plugins/ecommerce::orders.thank-you.total-row', [ 'label' => __('Shipping fee'), 'value' => format_price($summaryShippingAmount), ]) @endif @if ($summaryPaymentFee > 0) @include('plugins/ecommerce::orders.thank-you.total-row', [ 'label' => __('plugins/payment::payment.payment_fee'), 'value' => format_price($summaryPaymentFee), ]) @endif @if (! isset($orders)) {!! apply_filters('ecommerce_thank_you_total_info', null, $order) !!} @endif

{{ __('Total') }}:

{{ format_price($summaryTotalAmount) }}