{{-- Shared cart widget for the new-design (static) store pages. Displays a cart icon with a live count badge plus a mini dropdown showing the cart contents, remove buttons and totals. Also exposes shared cart helpers used by every add-to-cart form: window.submitCartForm(form, { redirectToCheckout }): Promise window.refreshCartWidget(): Promise window.showStaticConflictModal(message): Promise --}} @php $widgetLocale = app()->getLocale(); $widgetIsRtl = $widgetLocale === 'ar'; $widgetCart = auth()->check() ? \App\Domain\Ecommerce\Models\WebCart::query() ->with('cartItems.item') ->where('user_id', auth()->id()) ->first() : null; $widgetItems = $widgetCart?->cartItems ?? collect(); $widgetCount = (int) ($widgetItems->sum('qty') ?? 0); $widgetTotal = number_format((float) ($widgetCart?->total ?? 0), 2); $widgetTitleOf = static function ($value) use ($widgetLocale) { $fallback = __('ecommerce::ecommerce.product_label'); $value = $value ?? $fallback; if (is_array($value)) { return $value[$widgetLocale] ?? $value['en'] ?? reset($value) ?? $fallback; } if (is_object($value)) { return $fallback; } return $value; }; $widgetDefaultImg = asset('assets/ecommerce/images/Product/1.jpg'); @endphp
0 ? '' : 'style="display:none"' }}>{{ $widgetCount }}