PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
← All changes | app/Services/Renderer/ShopAppRenderer.php +31 -3 1.5.3 → 1.6.5 View file →
@@ -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
@@ -122,8 +130,17 @@
122 130 if (Arr::get($config, 'allow_out_of_stock')) {
123 131 $this->defaultFilters['allow_out_of_stock'] = true;
124 132 }
125 133
134 + // Merge wildcard search preset into defaultFilters so it persists in AJAX re-fetches
135 + $wildcard = Arr::get($defaultFilters, 'wildcard', '');
136 + if ($wildcard !== '') {
137 + $this->defaultFilters['wildcard'] = $wildcard;
138 + if (empty($this->defaultFilters['enabled'])) {
139 + $this->defaultFilters['enabled'] = true;
140 + }
141 + }
142 +
126 143 // Merge sort_by from config filters into defaultFilters for AJAX persistence
127 144 $configFilters = Arr::get($config, 'filters', []);
128 145 if (is_string($configFilters)) {
129 146 $configFilters = json_decode($configFilters, true) ?: [];
@@ -135,13 +152,19 @@
135 152 $this->defaultFilters['enabled'] = true;
136 153 }
137 154 }
138 155
139 - if (Arr::get($this->customFilters, 'price_range', false)) {
156 + $priceRange = Arr::get($this->customFilters, 'price_range', false);
157 + if ($priceRange) {
158 + // Accepts true (default "Price" label) or ['label' => '...'] so
159 + // integrations can name the price filter the same way the
160 + // taxonomies config names taxonomy filters.
140 161 $this->filters['price_range'] = [
141 162 "filter_type" => "range",
142 163 "is_meta" => false,
143 - "label" => "Price",
164 + "label" => is_array($priceRange) && !empty($priceRange['label'])
165 + ? $priceRange['label']
166 + : "Price",
144 167 "enabled" => true,
145 168 ];
146 169 }
147 170
@@ -240,8 +263,13 @@
240 263 }
241 264 if ($onSale) {
242 265 $wrapperAttributes['data-on-sale'] = '1';
243 266 }
267 + // Persist hide_excerpt so AJAX pagination/filtering renders cards the
268 + // same way as the initial response (Paginator.js round-trips it).
269 + if (Arr::get($this->config, 'hide_excerpt', false)) {
270 + $wrapperAttributes['data-hide-excerpt'] = '1';
271 + }
244 272 ?>
245 273 <div class="fct-products-wrapper" data-fluent-cart-shop-app data-fluent-cart-product-wrapper role="main" aria-label="<?php esc_attr_e('Products', 'fluent-cart'); ?>">
246 274 <?php $this->renderViewSwitcher(); ?>
247 275 <div <?php RenderHelper::renderAtts($wrapperAttributes); ?>>
@@ -523,9 +551,9 @@
523 551 if ($index === 0) {
524 552 $cursorAttr = Arr::get($cursor, 'cursor', '');
525 553 }
526 554
527 - (new \FluentCart\App\Services\Renderer\ProductCardRender($product, ['cursor' => $cursorAttr]))->render();
555 + (new \FluentCart\App\Services\Renderer\ProductCardRender($product, ['cursor' => $cursorAttr, 'hide_excerpt' => Arr::get($this->config, 'hide_excerpt', false)]))->render();
528 556 ?>
529 557 <?php } ?>
530 558 <?php
531 559 }