| @@ -7,8 +7,9 @@ | ||
| 7 | 7 | use FluentCart\App\Helpers\Helper; |
| 8 | 8 | use FluentCart\App\Http\Routes\WebRoutes; |
| 9 | 9 | use FluentCart\App\Modules\Templating\AssetLoader; |
| 10 | 10 | use FluentCart\Framework\Pagination\CursorPaginator; |
| 11 | +use FluentCart\Framework\Pagination\LengthAwarePaginator; | |
| 11 | 12 | use FluentCart\Framework\Support\Arr; |
| 12 | 13 | |
| 13 | 14 | class ShopAppRenderer |
| 14 | 15 | { |
| @@ -90,8 +91,15 @@ | ||
| 90 | 91 | if($this->products instanceof CursorPaginator){ |
| 91 | 92 | $this->total = 0; |
| 92 | 93 | }else{ |
| 93 | 94 | $this->total = Arr::get($products, 'total', 0); |
| 95 | + if (!$this->total && $this->products instanceof LengthAwarePaginator) { | |
| 96 | + // A raw LengthAwarePaginator's ArrayAccess proxies to its item | |
| 97 | + // collection, not its own properties, so Arr::get($products, 'total') | |
| 98 | + // above always misses when the caller passes the paginator directly | |
| 99 | + // instead of the normalized ['products' => ..., 'total' => ...] shape. | |
| 100 | + $this->total = $this->products->total(); | |
| 101 | + } | |
| 94 | 102 | } |
| 95 | 103 | //$this->total = $products['total']; |
| 96 | 104 | |
| 97 | 105 | |