PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.0
1.7.0 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 All 50 releases
← All changes | app/Services/Renderer/ProductRenderer.php +485 -134 1.4.1 → 1.7.0 View file →
@@ -3,9 +3,8 @@
3 3 namespace FluentCart\App\Services\Renderer;
4 4
5 5 use FluentCart\App\App;
6 6 use FluentCart\App\Services\FrontendView;
7 -use FluentCart\App\Vite;
8 7 use FluentCart\Api\StoreSettings;
9 8 use FluentCart\Api\ModuleSettings;
10 9 use FluentCart\App\Helpers\Helper;
11 10 use FluentCart\App\Models\Product;
@@ -13,8 +12,9 @@
13 12 use FluentCart\App\Http\Routes\WebRoutes;
14 13 use FluentCart\App\Models\ProductVariation;
15 14 use FluentCart\Framework\Support\Collection;
16 15 use FluentCart\App\Modules\Templating\AssetLoader;
16 +use FluentCart\App\Modules\FluentPlayer\ProductVideoRenderer;
17 17
18 18 class ProductRenderer
19 19 {
20 20 protected $product;
@@ -38,8 +38,10 @@
38 38 protected $defaultGalleryImageId = 0;
39 39
40 40 protected $galleryActiveSet = false;
41 41
42 + protected $productVideoRenderer = null;
43 +
42 44 protected $paymentTypes = [];
43 45
44 46 protected $variantsByPaymentTypes = [];
45 47
@@ -46,8 +48,10 @@
46 48 protected $activeTab = 'onetime';
47 49
48 50 protected $images = [];
49 51
52 + protected $variantTermMap = [];
53 +
50 54 protected $defaultImageUrl = null;
51 55
52 56 protected $defaultImageAlt = null;
53 57
@@ -83,10 +87,41 @@
83 87 if (!$defaultVariationId) {
84 88 $variationIds = $product->variants->pluck('id')->toArray();
85 89 $defaultVariationId = $product->detail->default_variation_id;
86 90
87 - if (!$defaultVariationId || !in_array($defaultVariationId, $variationIds)) {
88 - $defaultVariationId = Arr::get($variationIds, '0');
91 + // For advanced variations the storefront selector only exposes ACTIVE
92 + // variants (AdvancedVariationRenderer skips item_status != active), so
93 + // resolve the default against the same set. default_variation_id is
94 + // maintained stock/status-agnostically, so it can legitimately point
95 + // at an inactive variant — accepting it here would render the inactive
96 + // default's price/stock/button while the selector omits that id and
97 + // falls back to a different active variant. Scoped to advanced so
98 + // simple / simple_variations keep their existing default handling.
99 + $isAdvanced = $product->detail
100 + && $product->detail->variation_type === Helper::PRODUCT_TYPE_ADVANCE_VARIATION;
101 + $eligibleVariants = $isAdvanced
102 + ? $product->variants->where('item_status', 'active')
103 + : $product->variants;
104 + $eligibleIds = $eligibleVariants->pluck('id')->toArray();
105 +
106 + if (!$defaultVariationId || !in_array($defaultVariationId, $eligibleIds)) {
107 + // No valid stored default — fall back to the FIRST eligible
108 + // combination by serial_index (active-only for advanced), not the
109 + // first by DB/id order, so the server-rendered price/stock/button
110 + // match what the storefront selector highlights. Stock is ignored
111 + // — first by order wins. A NULL serial_index (legacy/malformed row
112 + // the merchant never ordered) is pushed AFTER numbered variants so
113 + // it can't become the default ahead of an explicitly ordered one —
114 + // PHP's default null-first sort would otherwise promote it, and the
115 + // frontend mirrors this by treating null serial as last too.
116 + $firstBySerial = $eligibleVariants
117 + ->sortBy(function ($variant) {
118 + return is_null($variant->serial_index)
119 + ? PHP_INT_MAX
120 + : (int) $variant->serial_index;
121 + })
122 + ->first();
123 + $defaultVariationId = $firstBySerial ? (int) $firstBySerial->id : Arr::get($variationIds, '0');
89 124 $hasExplicitDefault = false;
90 125 }
91 126 }
92 127
@@ -104,13 +139,17 @@
104 139 foreach ($this->product->variants as $variant) {
105 140 if ($variant->id == $this->defaultVariationId) {
106 141 $this->defaultVariant = $variant;
107 142 }
108 - $paymentType = Arr::get($variant->other_info, 'payment_type');
109 - if ($paymentType === 'onetime') {
143 + // Read the authoritative payment_type column, not other_info. The
144 + // ProductVariation accessor only injects payment_type into other_info
145 + // for subscriptions, so one-time variants (notably advanced-variation
146 + // combinations generated by Pro) leave other_info['payment_type']
147 + // unset. Anything that is not a subscription is a one-time path.
148 + if ($variant->payment_type === 'subscription') {
149 + $this->hasSubscription = true;
150 + } else {
110 151 $this->hasOnetime = true;
111 - } else if ($paymentType === 'subscription') {
112 - $this->hasSubscription = true;
113 152 }
114 153 }
115 154
116 155 $this->buildProductGroups();
@@ -257,8 +296,33 @@
257 296 }
258 297
259 298 public function renderBuySection($atts = [])
260 299 {
300 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
301 +
302 + // The buy section is the root the variation-selector JS binds to
303 + // (data-fluent-cart-product-pricing-section). Gating it removes the
304 + // variation picker along with the buttons, which is what a full catalog
305 + // mode wants; to keep shoppers able to browse options while hiding only
306 + // the purchase affordances, gate 'actions' instead.
307 + if (!RenderGate::shouldRender('buy_section', $gateContext)) {
308 + return;
309 + }
310 +
311 + // Render no buy section when there is nothing purchasable — avoids a
312 + // broken quantity + "Not Available" block. Two cases:
313 + // - no variants at all (any product type), or
314 + // - an advanced-variation product with no attribute_config yet (e.g.
315 + // switched on before options were configured). Its variants are kept
316 + // until generation, so we key on the config, not the variant count,
317 + // to hide it until real combinations exist.
318 + $isUnconfiguredAdvanced = $this->product->detail->variation_type === Helper::PRODUCT_TYPE_ADVANCE_VARIATION
319 + && empty(Arr::get((array) $this->product->detail->other_info, 'attribute_config'));
320 +
321 + if ($this->product->variants->isEmpty() || $isUnconfiguredAdvanced) {
322 + return;
323 + }
324 +
261 325 $otherInfo = (array)Arr::get($this->product->detail, 'other_info');
262 326 $groupBy = Arr::get($otherInfo, 'group_pricing_by', 'repeat_interval'); //repeat_interval,payment_type,none
263 327
264 328 $this->renderBuySectionWrapperStart();
@@ -277,8 +341,25 @@
277 341 }
278 342
279 343 public function renderVariationDisplay($atts = [])
280 344 {
345 + // Hand off rendering to the advanced-variation selector when the
346 + // product is configured for advanced variations. The handler returns
347 + // the filtered array with rendered=true after emitting its markup; if
348 + // no listener handles it (e.g. an unconfigured advanced product), the
349 + // filter is a no-op and we fall through to the simple-variation
350 + // rendering below.
351 + if ($this->product->detail->variation_type === Helper::PRODUCT_TYPE_ADVANCE_VARIATION) {
352 + $result = apply_filters('fluent_cart/product/render_advanced_variation', [
353 + 'product' => $this->product,
354 + 'selector_style' => Arr::get($atts, 'selector_style', 'auto'),
355 + 'rendered' => false,
356 + ]);
357 + if (!empty($result['rendered'])) {
358 + return;
359 + }
360 + }
361 +
281 362 $otherInfo = (array)Arr::get($this->product->detail, 'other_info');
282 363 $groupBy = Arr::get($otherInfo, 'group_pricing_by', 'repeat_interval'); //repeat_interval,payment_type,none
283 364
284 365 if (count($this->paymentTypes) === 1 || $groupBy === 'none') {
@@ -291,12 +372,15 @@
291 372 public function renderGalleryThumb()
292 373 {
293 374 $thumbnails = [];
294 375
295 - $featuredMedia = $this->product->thumbnail ?? Vite::getAssetUrl('images/placeholder.svg');
376 + $featuredMedia = $this->product->thumbnail ?? Helper::getProductPlaceholderUrl();
296 377
297 - if (!$featuredMedia) {
298 - $featuredMedia = [];
378 + // thumbnail can be an empty string (not null), so ?? above doesn't catch
379 + // it — fall back to the placeholder so $featuredMedia is always a usable
380 + // image URL for both the main <img> and data-default-image-url.
381 + if (!$featuredMedia || !\is_string($featuredMedia)) {
382 + $featuredMedia = Helper::getProductPlaceholderUrl();
299 383 }
300 384
301 385 $galleryImage = get_post_meta($this->product->ID, 'fluent-products-gallery-image', true);
302 386
@@ -329,14 +413,37 @@
329 413 if (isset($images[$imageId])) {
330 414 $imageMetaValue = $images[$imageId];
331 415 $this->defaultImageUrl = Arr::get($imageMetaValue, 'media.0.url', '');
332 416 $this->defaultImageAlt = Arr::get($imageMetaValue, 'media.0.title', '');
417 + } else {
418 + // Fallback to the first available thumbnail. Advanced-variation
419 + // products often have per-variant images but no explicit
420 + // default_variation_id — the thumbnails are keyed by real
421 + // variant IDs while defaultGalleryImageId is 0, so the lookup
422 + // above misses and the main image area renders blank with a
423 + // broken-image icon.
424 + $firstImage = reset($images);
425 + $fallbackUrl = Arr::get($firstImage, 'media.0.url', '');
426 + $this->defaultImageUrl = $fallbackUrl ?: ($featuredMedia ?: '');
427 + $this->defaultImageAlt = $this->defaultImageAlt ?: Arr::get($firstImage, 'media.0.title', '');
333 428 }
334 429 }
335 430
431 + // Nothing set a main image — e.g. a product with no variants, or no
432 + // variant/gallery media. Fall back to the featured/placeholder image so
433 + // the main area shows the placeholder instead of a broken <img src="">.
434 + if (empty($this->defaultImageUrl)) {
435 + $this->defaultImageUrl = $featuredMedia;
436 + }
437 +
438 + $videoRenderer = $this->getProductVideoRenderer();
439 + $videoRenderer->showFirstByDefault(!$this->hasGalleryImages());
440 + $defaultVideoId = $videoRenderer->getDefaultMediaId();
441 +
336 442 ?>
337 - <div class="fct-product-gallery-thumb" role="region"
338 - aria-label="<?php echo esc_attr($this->product->post_title . ' gallery'); ?>">
443 + <div class="fct-product-gallery-thumb<?php echo $defaultVideoId ? ' is-video-active' : ''; ?>" role="region"
444 + aria-label="<?php echo esc_attr($this->product->post_title . ' gallery'); ?>"
445 + <?php echo $defaultVideoId ? 'data-fct-video-default="' . esc_attr((string) $defaultVideoId) . '"' : ''; ?>>
339 446 <img
340 447 src="<?php echo esc_url($this->defaultImageUrl ?? '') ?>"
341 448 alt="<?php echo esc_attr($this->defaultImageAlt) ?>"
342 449 data-fluent-cart-single-product-page-product-thumbnail
@@ -341,36 +448,117 @@
341 448 alt="<?php echo esc_attr($this->defaultImageAlt) ?>"
342 449 data-fluent-cart-single-product-page-product-thumbnail
343 450 data-default-image-url="<?php echo esc_url($featuredMedia) ?>"
344 451 />
452 + <?php $this->getProductVideoRenderer()->renderInlinePlayers(); ?>
345 453 </div>
346 454 <?php
347 455 }
348 456
457 + /**
458 + * Whether any gallery / variant image exists to show in the main area.
459 + * Only meaningful after renderGalleryThumb() has built $this->images.
460 + */
461 + protected function hasGalleryImages(): bool
462 + {
463 + foreach ($this->images as $image) {
464 + foreach ((array) Arr::get($image, 'media', []) as $item) {
465 + if (!empty(Arr::get($item, 'url'))) {
466 + return true;
467 + }
468 + }
469 + }
470 +
471 + return false;
472 + }
473 +
474 + public function getProductVideoRenderer(): ProductVideoRenderer
475 + {
476 + if ($this->productVideoRenderer === null) {
477 + $this->productVideoRenderer = new ProductVideoRenderer($this->product);
478 + }
479 +
480 + return $this->productVideoRenderer;
481 + }
482 +
349 483 public function renderGalleryThumbControls($maxThumbnails = null)
350 484 {
351 485 $totalThumbImages = Arr::pluck($this->images, 'media.*.url');
352 486
353 - if(count($totalThumbImages) == 1 && is_countable($totalThumbImages[0]) && count($totalThumbImages[0]) == 1){
487 + // A lone image needs no strip, but a video thumb still has to be reachable.
488 + if(count($totalThumbImages) == 1 && is_countable($totalThumbImages[0]) && count($totalThumbImages[0]) == 1 && !$this->getProductVideoRenderer()->isAvailable()){
354 489
355 490 return '';
356 491 }
357 492
358 - // Collect ALL gallery images as JSON for lightbox (even when max thumbnails limits visible thumbs)
493 + // A lone video without images is already showing in the main area.
494 + if (!$this->hasGalleryImages() && count($this->getProductVideoRenderer()->getVideos()) === 1) {
495 + return '';
496 + }
497 +
498 + // Build variantTermMap and variantFirstMediaMap.
499 + // For advanced variations, Pro builds both maps via the gallery_variation_data
500 + // filter — it has access to AttributeGroup types (color/image) that free cannot
501 + // query directly. For all other product types, free builds variantFirstMediaMap
502 + // from the already-loaded $this->images; variantTermMap stays empty.
503 + $this->variantTermMap = [];
504 + $variantFirstMediaMap = [];
505 +
506 + if ($this->product->detail->variation_type === Helper::PRODUCT_TYPE_ADVANCE_VARIATION) {
507 + $galleryVariationData = apply_filters('fluent_cart/product/gallery_variation_data', [
508 + 'variant_term_map' => [],
509 + 'variant_first_media_map' => [],
510 + ], $this->product);
511 + $this->variantTermMap = (array) Arr::get($galleryVariationData, 'variant_term_map', []);
512 + $variantFirstMediaMap = (array) Arr::get($galleryVariationData, 'variant_first_media_map', []);
513 + } else {
514 + foreach ($this->images as $imageId => $image) {
515 + if (empty($image['media']) || !is_array($image['media'])) {
516 + continue;
517 + }
518 + $firstItem = $image['media'][0] ?? null;
519 + if (!$firstItem) {
520 + continue;
521 + }
522 + $firstUrl = Arr::get($firstItem, 'url', '');
523 + $firstMediaId = (int) Arr::get($firstItem, 'id', 0);
524 + if ($firstUrl) {
525 + $variantFirstMediaMap[(int) $imageId] = [
526 + 'id' => $firstMediaId,
527 + 'url' => $firstUrl,
528 + ];
529 + }
530 + }
531 + }
532 +
533 + // Collect ALL gallery images as JSON for lightbox (even when max thumbnails limits visible thumbs).
534 + // For advanced variations, deduplicate by media ID (when > 0) or by URL (for imported images).
359 535 $allGalleryImages = [];
536 + $addedMediaKeys = [];
537 + $isAdvVariation = !empty($this->variantTermMap);
360 538 foreach ($this->images as $imageId => $image) {
361 539 if (empty($image['media']) || !is_array($image['media'])) {
362 540 continue;
363 541 }
364 542 foreach ($image['media'] as $item) {
365 - $url = Arr::get($item, 'url', '');
543 + $url = Arr::get($item, 'url', '');
544 + $mediaId = (int) Arr::get($item, 'id', 0);
366 545 if (empty($url)) {
367 546 continue;
368 547 }
548 + if ($isAdvVariation) {
549 + $dedupeKey = $mediaId > 0 ? 'i:' . $mediaId : 'u:' . $url;
550 + if (isset($addedMediaKeys[$dedupeKey])) {
551 + continue; // skip — already added this image
552 + }
553 + $addedMediaKeys[$dedupeKey] = true;
554 + }
369 555 $allGalleryImages[] = [
370 556 'url' => $url,
371 557 'title' => Arr::get($item, 'title', ''),
372 558 'variation_id' => (string) $imageId,
559 + 'term_id' => (int) ($this->variantTermMap[(int) $imageId] ?? 0),
560 + 'media_id' => $mediaId,
373 561 ];
374 562 }
375 563 }
376 564
@@ -379,9 +567,10 @@
379 567 <div class="fct-gallery-thumb-controls"
380 568 role="toolbar"
381 569 aria-label="<?php echo esc_attr__('Product image thumbnails', 'fluent-cart'); ?>"
382 570 data-fluent-cart-single-product-page-product-thumbnail-controls
383 - data-all-gallery-images="<?php echo esc_attr(wp_json_encode($allGalleryImages) ?: '[]'); ?>">
571 + data-all-gallery-images="<?php echo esc_attr(wp_json_encode($allGalleryImages) ?: '[]'); ?>"
572 + data-variant-first-media-map="<?php echo esc_attr(wp_json_encode($variantFirstMediaMap) ?: '{}'); ?>">
384 573
385 574 <?php $this->renderGalleryThumbControl($maxThumbnails); ?>
386 575
387 576 </div>
@@ -395,45 +584,76 @@
395 584 if ($maxThumbnails !== null && $maxThumbnails <= 0) {
396 585 $maxThumbnails = null; // treat invalid value as "no limit"
397 586 }
398 587
399 - $count = 0;
400 - $totalImages = 0;
588 + $isAdvVariation = !empty($this->variantTermMap);
589 + $countedMediaKeys = [];
590 + $count = 0;
591 + $totalImages = 0;
592 + $videoRenderer = $this->getProductVideoRenderer();
401 593
402 - // First, count total renderable images
594 + // The gallery opens on a video the admin put in front of every image,
595 + // so no image thumb takes the selected slot in that case.
596 + if ($videoRenderer->getDefaultMediaId()) {
597 + $this->galleryActiveSet = true;
598 + }
599 +
600 + // Count unique images to render. For advanced variations, deduplicate by WP media ID
601 + // when available, or by URL for externally imported images (media ID = 0).
403 602 foreach ($this->images as $imageId => $image) {
404 603 if (empty($image['media']) || !is_array($image['media'])) {
405 604 continue;
406 605 }
407 606 foreach ($image['media'] as $item) {
408 - if (!empty(Arr::get($item, 'url', ''))) {
409 - $totalImages++;
607 + $url = Arr::get($item, 'url', '');
608 + $mediaId = (int) Arr::get($item, 'id', 0);
609 + if (empty($url)) {
610 + continue;
410 611 }
612 + if ($isAdvVariation) {
613 + $mediaDedupeKey = $mediaId > 0 ? 'i:' . $mediaId : 'u:' . $url;
614 + if (isset($countedMediaKeys[$mediaDedupeKey])) {
615 + continue;
616 + }
617 + $countedMediaKeys[$mediaDedupeKey] = true;
618 + }
619 + $totalImages++;
411 620 }
412 621 }
413 622
414 - // Then render up to max
623 + $renderedMediaKeys = [];
624 + // Render up to max; skip already-rendered media for advanced variation products.
415 625 foreach ($this->images as $imageId => $image) {
416 626 if (empty($image['media']) || !is_array($image['media'])) {
417 627 continue;
418 628 }
419 -
420 629 foreach ($image['media'] as $item) {
421 - if (empty(Arr::get($item, 'url', ''))) {
630 + $url = Arr::get($item, 'url', '');
631 + $mediaId = (int) Arr::get($item, 'id', 0);
632 + if (empty($url)) {
422 633 continue;
423 634 }
424 -
635 + if ($isAdvVariation) {
636 + $mediaDedupeKey = $mediaId > 0 ? 'i:' . $mediaId : 'u:' . $url;
637 + if (isset($renderedMediaKeys[$mediaDedupeKey])) {
638 + continue;
639 + }
640 + $renderedMediaKeys[$mediaDedupeKey] = true;
641 + }
425 642 if ($maxThumbnails !== null && $count >= (int) $maxThumbnails) {
643 + $videoRenderer->renderThumbControls(!$this->galleryActiveSet);
426 644 $this->renderGallerySeeMoreButton($totalImages - (int) $maxThumbnails);
427 645 return;
428 646 }
429 -
430 - $this->renderGalleryThumbControlButton($item, $imageId);
647 + // Videos the admin dragged in front of this image come first.
648 + $videoRenderer->renderThumbControlsBefore($count, !$this->galleryActiveSet);
649 + $termId = (int) ($this->variantTermMap[(int) $imageId] ?? 0);
650 + $this->renderGalleryThumbControlButton($item, $imageId, $termId, $mediaId);
431 651 $count++;
432 652 }
433 -
434 653 }
435 654
655 + $videoRenderer->renderThumbControls(!$this->galleryActiveSet);
436 656 }
437 657
438 658 public function renderGallerySeeMoreButton($remainingCount)
439 659 {
@@ -464,9 +684,9 @@
464 684 </button>
465 685 <?php
466 686 }
467 687
468 - public function renderGalleryThumbControlButton($item, $imageId)
688 + public function renderGalleryThumbControlButton($item, $imageId, $termId = 0, $mediaId = 0)
469 689 {
470 690
471 691 $isHidden = ''; //$imageId != $this->defaultVariationId ? 'is-hidden' : '';
472 692 $itemUrl = Arr::get($item, 'url', '');
@@ -482,11 +702,13 @@
482 702 class="fct-gallery-thumb-control-button <?php echo $isSelected ? 'active' : ''; ?> <?php echo esc_attr($isHidden); ?>"
483 703 data-fluent-cart-thumb-control-button
484 704 data-url="<?php echo esc_url($itemUrl); ?>"
485 705 data-variation-id="<?php echo esc_attr($imageId); ?>"
706 + data-term-id="<?php echo esc_attr((string) $termId); ?>"
707 + data-media-id="<?php echo esc_attr((string) $mediaId); ?>"
486 708 aria-label="<?php echo
487 - /* translators: %s image title */
488 - esc_attr(sprintf(__('View %s image', 'fluent-cart'), $itemTitle));
709 + /* translators: %1$s: image title */
710 + esc_attr(sprintf(__('View %1$s image', 'fluent-cart'), $itemTitle));
489 711 ?>"
490 712 aria-pressed="<?php echo $isSelected ? 'true' : 'false'; ?>"
491 713 tabindex="<?php echo $isSelected ? '0' : '-1'; ?>"
492 714 >
@@ -504,9 +726,14 @@
504 726 }
505 727
506 728 public function renderGallery($args = [])
507 729 {
730 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
508 731
732 + if (!RenderGate::shouldRender('image', $gateContext)) {
733 + return;
734 + }
735 +
509 736 $defaults = [
510 737 'thumbnail_mode' => 'all', // horizontal, vertical
511 738 'thumb_position' => 'bottom', // bottom, left, right, top
512 739 'scrollable_thumbs' => 'no', // yes / no
@@ -540,13 +767,21 @@
540 767 }
541 768
542 769 public function renderTitle()
543 770 {
771 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
772 +
773 + if (!RenderGate::shouldRender('title', $gateContext)) {
774 + return;
775 + }
776 +
777 + do_action('fluent_cart/product/single/before_title_block', $gateContext);
544 778 ?>
545 779 <div class="fct-product-title">
546 780 <h1 id="fct-product-summary-title"><?php echo esc_html($this->product->post_title); ?></h1>
547 781 </div>
548 782 <?php
783 + do_action('fluent_cart/product/single/after_title_block', $gateContext);
549 784 }
550 785
551 786 public function renderStockAvailability($wrapper_attributes = '')
552 787 {
@@ -566,15 +801,44 @@
566 801 // Check default variant stock for both simple and variable products
567 802 if ($this->defaultVariant) {
568 803 $isStock = $isStock && $this->defaultVariant->isStock();
569 804 }
805 +
570 806 $stockLabel = Arr::get($stockAvailability, 'availability');
571 - $statusClass = $isStock ? ($stockAvailability['class'] ?? '') : 'out-of-stock';
807 + $statusClass = $stockAvailability['class'] ?? '';
808 +
809 + // Optional per-status custom labels (e.g. set on the Bricks Product Stock
810 + // element via the fluent_cart/product_stock_availability filter). Emitted as
811 + // data-attributes so the frontend JS, which re-derives the badge text on load
812 + // and on variant switches, prefers them over the generic label map instead of
813 + // overwriting them. Absent for the default template, so behavior is unchanged.
814 + $inStockText = Arr::get($stockAvailability, 'in_stock_text');
815 + $outOfStockText = Arr::get($stockAvailability, 'out_of_stock_text');
816 +
817 + // The variant-level check above can override the aggregate stock_availability
818 + // used for $stockLabel/$statusClass (e.g. this specific default variant is out
819 + // of stock even though the product overall has other in-stock variants) — keep
820 + // the label and class in sync so the badge never shows mismatched text/color.
821 + // Honor the custom out-of-stock label here too so it survives this override on
822 + // first load, matching what the frontend JS shows after a variant switch.
823 + if (!$isStock) {
824 + $statusClass = 'out-of-stock';
825 + $stockLabel = !empty($outOfStockText) ? $outOfStockText : __('Out of Stock', 'fluent-cart');
826 + }
827 +
828 + $badgeAttributes = '';
829 + if (!empty($inStockText)) {
830 + $badgeAttributes .= sprintf(' data-in-stock-text="%s"', esc_attr($inStockText));
831 + }
832 + if (!empty($outOfStockText)) {
833 + $badgeAttributes .= sprintf(' data-out-of-stock-text="%s"', esc_attr($outOfStockText));
834 + }
835 +
572 836 echo sprintf(
573 837 '<div class="fct-product-stock %1$s" role="status" aria-live="polite">
574 838 <div %2$s>
575 839 <span class="fct-stock-label">%3$s</span>
576 - <span class="fct-stock-badge fct_status_badge_%1$s" data-fluent-cart-product-stock>
840 + <span class="fct-stock-badge fct_status_badge_%1$s" data-fluent-cart-product-stock%5$s>
577 841 %4$s
578 842 </span>
579 843 </div>
580 844 </div>',
@@ -580,22 +844,15 @@
580 844 </div>',
581 845 esc_attr($statusClass),
582 846 $wrapper_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
583 847 esc_html__('Availability:', 'fluent-cart'),
584 - esc_html($stockLabel)
848 + esc_html($stockLabel),
849 + $badgeAttributes // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- values passed through esc_attr() above
585 850 );
586 851 }
587 852
588 853 public function renderSku($wrapper_attributes = '', $showLabel = true, $label = '', $variant = null)
589 854 {
590 - if (!$variant) {
591 - $variant = $this->defaultVariant ?: $this->product->variants->first();
592 - }
593 -
594 - if (!$variant || empty($variant->sku)) {
595 - return;
596 - }
597 -
598 855 if (!$label) {
599 856 $label = __('SKU:', 'fluent-cart');
600 857 }
601 858
@@ -603,9 +860,13 @@
603 860 if ($showLabel && $label) {
604 861 $labelHtml = sprintf('<span class="fct-product-sku__label">%s</span> ', esc_html($label));
605 862 }
606 863
607 - echo sprintf(
864 + if ($variant) {
865 + if (empty($variant->sku)) {
866 + return;
867 + }
868 + echo sprintf(
608 869 '<div class="fct-product-sku">
609 870 <div %s>
610 871 %s<span class="fct-product-sku__value" data-fluent-cart-product-sku>%s</span>
611 872 </div>
@@ -612,15 +873,48 @@
612 873 </div>',
613 874 $wrapper_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
614 875 $labelHtml,
615 876 esc_html($variant->sku)
616 - );
877 + );
878 + return;
879 + }
880 +
881 + foreach ($this->product->variants as $v) {
882 + if (empty($v->sku)) {
883 + continue;
884 + }
885 + $isHidden = ($this->defaultVariant && $this->defaultVariant->id != $v->id) ? ' is-hidden' : '';
886 + echo sprintf(
887 + '<div class="fct-product-sku fluent-cart-product-variation-content%s" data-variation-id="%s">
888 + <div %s>
889 + %s<span class="fct-product-sku__value" data-fluent-cart-product-sku>%s</span>
890 + </div>
891 + </div>',
892 + $isHidden,
893 + esc_attr($v->id),
894 + $wrapper_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
895 + $labelHtml,
896 + esc_html($v->sku)
897 + );
898 + }
617 899 }
618 900
901 + /**
902 + * @deprecated Use PackageDescriptionRenderer::renderPackageDescription() directly.
903 + * Kept as a compatibility shim for external callers (themes, extensions) —
904 + * package-description rendering now lives in PackageDescriptionRenderer.
905 + */
619 906 public function renderPackageDescription($wrapper_attributes = '', $showName = true, $showDimensions = true, $showProductWeight = true, $showTotalWeight = true, $variant = null)
620 907 {
621 - $variant = $variant ?: ($this->defaultVariant ?: $this->product->variants->first());
622 - (new ProductCardRender($this->product))->renderPackageDescription($wrapper_attributes, $showName, $showDimensions, $showProductWeight, $showTotalWeight, $variant);
908 + (new PackageDescriptionRenderer($this->product))->renderPackageDescription(
909 + $wrapper_attributes,
910 + $showName,
911 + $showDimensions,
912 + $showProductWeight,
913 + $showTotalWeight,
914 + $variant,
915 + $this->defaultVariant
916 + );
623 917 }
624 918
625 919 /**
626 920 * Build a JSON string of package info for a variant (used as data attribute for JS switching).
@@ -689,14 +983,22 @@
689 983 $excerpt = $this->product->post_excerpt;
690 984 if (!$excerpt) {
691 985 return;
692 986 }
987 +
988 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
989 +
990 + if (!RenderGate::shouldRender('excerpt', $gateContext)) {
991 + return;
992 + }
993 +
994 + do_action('fluent_cart/product/single/before_excerpt_block', $gateContext);
693 995 ?>
694 996 <div class="fct-product-excerpt" aria-labelledby="fct-product-summary-title">
695 997 <p><?php echo wp_kses_post($excerpt); ?></p>
696 998 </div>
697 999 <?php
698 -
1000 + do_action('fluent_cart/product/single/after_excerpt_block', $gateContext);
699 1001 }
700 1002
701 1003 public function renderDescription()
702 1004 {
@@ -726,8 +1028,14 @@
726 1028 }
727 1029
728 1030 public function renderPrices()
729 1031 {
1032 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
1033 +
1034 + if (!RenderGate::shouldRender('price', $gateContext)) {
1035 + return;
1036 + }
1037 +
730 1038 if ($this->product->detail->variation_type === 'simple') {
731 1039 // we have to render for the simple product
732 1040
733 1041 $first_price = $this->product->variants()->first();
@@ -741,97 +1049,76 @@
741 1049 $comparePrice = $first_price ? (int)$first_price->compare_price : 0;
742 1050 if ($comparePrice <= $itemPrice) {
743 1051 $comparePrice = 0;
744 1052 }
745 - do_action('fluent_cart/product/single/before_price_block', [
1053 + do_action('fluent_cart/product/single/before_price_block', RenderContext::decorate([
746 1054 'product' => $this->product,
747 1055 'current_price' => $itemPrice,
748 1056 'scope' => 'price_range'
749 - ]);
1057 + ]));
750 1058 ?>
751 - <?php
1059 + <div class="fct-price-range fct-product-prices">
752 1060
753 - if ($comparePrice) {
754 - $aria_label = sprintf(
755 - /* translators: 1: Original price, 2: Current item price */
756 - __('Original Price: %1$s, Price: %2$s', 'fluent-cart'),
757 - Helper::toDecimal($comparePrice),
758 - Helper::toDecimal($itemPrice)
759 - );
760 - } else {
761 - $aria_label = sprintf(
762 - /* translators: 1: Current item price */
763 - __('Price: %1$s', 'fluent-cart'),
764 - Helper::toDecimal($itemPrice)
765 - );
766 - }
767 -
768 - ?>
769 - <div class="fct-price-range fct-product-prices" role="term"
770 - aria-label="<?php echo esc_attr($aria_label); ?>">
771 -
772 1061 <?php if ($comparePrice): ?>
773 1062 <span class="fct-compare-price">
774 - <del aria-label="<?php echo esc_attr(__('Original price', 'fluent-cart')); ?>"><?php echo esc_html(Helper::toDecimal($comparePrice)); ?></del>
1063 + <span class="fct-sr-only"><?php echo esc_html__('Original price:', 'fluent-cart'); ?></span>
1064 + <del><?php echo esc_html(Helper::toDecimal($comparePrice)); ?></del>
775 1065 </span>
776 1066 <?php endif; ?>
777 - <span class="fct-item-price" aria-label="<?php echo esc_attr(__('Current price', 'fluent-cart')); ?>">
1067 + <span class="fct-item-price">
1068 + <span class="fct-sr-only"><?php echo $comparePrice ? esc_html__('Sale price:', 'fluent-cart') : esc_html__('Price:', 'fluent-cart'); ?></span>
778 1069 <?php echo esc_html(Helper::toDecimal($itemPrice)); ?>
779 - <?php do_action('fluent_cart/product/after_price', [
1070 + <?php do_action('fluent_cart/product/after_price', RenderContext::decorate([
780 1071 'product' => $this->product,
1072 + 'variant' => $first_price,
781 1073 'current_price' => $itemPrice,
782 1074 'scope' => 'price_range'
783 - ]); ?>
1075 + ])); ?>
1076 + <?php RenderHelper::renderPriceSuffix($this->product, $first_price, 'price_range'); ?>
784 1077 </span>
785 1078 </div>
786 1079 <?php
787 - do_action('fluent_cart/product/single/after_price_block', [
1080 + do_action('fluent_cart/product/single/after_price_block', RenderContext::decorate([
788 1081 'product' => $this->product,
789 1082 'current_price' => $itemPrice,
790 1083 'scope' => 'price_range'
791 - ]);
1084 + ]));
792 1085 return;
793 1086 }
794 1087 $min_price = $this->product->detail->min_price;
795 1088 $max_price = $this->product->detail->max_price;
796 1089
797 - do_action('fluent_cart/product/single/before_price_range_block', [
1090 + do_action('fluent_cart/product/single/before_price_range_block', RenderContext::decorate([
798 1091 'product' => $this->product,
799 1092 'current_price' => $min_price,
800 1093 'scope' => 'price_range'
801 - ]);
1094 + ]));
802 1095 ?>
803 - <?php
804 - $aria_label = sprintf(
805 - /* translators: 1: Minimum price, 2: Maximum price */
806 - __('Price range: %1$s - %2$s', 'fluent-cart'),
807 - Helper::toDecimal($min_price),
808 - Helper::toDecimal($max_price)
809 - );
810 - ?>
811 - <div class="fct-product-prices fct-price-range" role="term" aria-label="<?php echo esc_attr($aria_label); ?>">
1096 + <div class="fct-product-prices fct-price-range">
812 1097
813 1098 <?php if ($max_price && $max_price != $min_price && $max_price > $min_price): ?>
1099 + <span class="fct-sr-only"><?php echo esc_html__('Price range:', 'fluent-cart'); ?></span>
814 1100 <span class="fct-min-price"><?php echo esc_html(Helper::toDecimal($min_price)); ?></span>
815 1101 <span class="fct-price-separator" aria-hidden="true">-</span>
1102 + <span class="fct-sr-only"><?php echo esc_html__('to', 'fluent-cart'); ?></span>
816 1103 <?php endif; ?>
817 1104 <span class="fct-max-price">
818 1105 <?php echo esc_html(Helper::toDecimal($max_price)); ?>
819 1106 </span>
820 1107
821 - <?php do_action('fluent_cart/product/after_price', [
1108 + <?php do_action('fluent_cart/product/after_price', RenderContext::decorate([
822 1109 'product' => $this->product,
823 1110 'current_price' => $min_price,
824 1111 'scope' => 'price_range'
825 - ]); ?>
1112 + ])); ?>
826 1113
827 1114 </div>
828 1115 <?php
829 - do_action('fluent_cart/product/single/after_price_range_block', [
1116 + do_action('fluent_cart/product/single/after_price_range_block', RenderContext::decorate([
830 1117 'product' => $this->product,
831 1118 'current_price' => $min_price,
832 1119 'scope' => 'price_range'
833 - ]);
1120 + ]));
834 1121 }
835 1122
836 1123 public function renderVariants($atts = [])
837 1124 {
@@ -856,19 +1143,19 @@
856 1143 ?>
857 1144 <div class="<?php echo esc_attr(implode(' ', $classes)); ?>" role="radiogroup"
858 1145 aria-label="<?php esc_attr_e('Product Variants', 'fluent-cart'); ?>">
859 1146 <?php foreach ($variants as $variant) {
860 - do_action('fluent_cart/product/single/before_variant_item', [
1147 + do_action('fluent_cart/product/single/before_variant_item', RenderContext::decorate([
861 1148 'product' => $this->product,
862 1149 'variant' => $variant,
863 1150 'scope' => 'product_variant_item'
864 - ]);
1151 + ]));
865 1152 $this->renderVariationItem($variant, $this->defaultVariationId);
866 - do_action('fluent_cart/product/single/after_variant_item', [
1153 + do_action('fluent_cart/product/single/after_variant_item', RenderContext::decorate([
867 1154 'product' => $this->product,
868 1155 'variant' => $variant,
869 1156 'scope' => 'product_variant_item'
870 - ]);
1157 + ]));
871 1158 } ?>
872 1159 </div>
873 1160 <?php
874 1161 }
@@ -874,17 +1161,24 @@
874 1161 }
875 1162
876 1163 public function renderItemPrice()
877 1164 {
1165 + // Same 'price' gate as renderPrices(): one filter hides the price
1166 + // wherever it appears, rather than making callers hunt for the second
1167 + // place the single product page prints one.
1168 + if (!RenderGate::shouldRender('price', RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant))) {
1169 + return;
1170 + }
1171 +
878 1172 if ($this->product->detail->variation_type === 'simple' && !$this->hasSubscription) {
879 1173 return; // for simple product we already rendered the price
880 1174 }
881 1175
882 - do_action('fluent_cart/product/single/before_price_block', [
1176 + do_action('fluent_cart/product/single/before_price_block', RenderContext::decorate([
883 1177 'product' => $this->product,
884 1178 'current_price' => $this->defaultVariant ? $this->defaultVariant->item_price : 0,
885 1179 'scope' => 'product_variant_price'
886 - ]);
1180 + ]));
887 1181
888 1182 foreach ($this->product->variants as $variant) {
889 1183 if ($this->shouldRenderPriceInPriceSection()) {
890 1184 $this->renderVariantPricingWrapperStart($variant);
@@ -918,18 +1212,31 @@
918 1212
919 1213
920 1214
921 1215
922 - do_action('fluent_cart/product/single/after_price_block', [
1216 + do_action('fluent_cart/product/single/after_price_block', RenderContext::decorate([
923 1217 'product' => $this->product,
924 1218 'current_price' => $this->defaultVariant ? $this->defaultVariant->item_price : 0,
925 1219 'scope' => 'product_variant_price'
926 - ]);
1220 + ]));
927 1221 }
928 1222
929 1223 public function shouldRenderPriceInPriceSection(): bool
930 1224 {
931 - return !($this->viewType === 'text' && $this->columnType === 'one');
1225 + // simple_variations keeps the legacy inline price flow for the
1226 + // one-column layouts that render the variant title (text-only and
1227 + // image+text), where the price sits on each variant row.
1228 + // Every other variation type always renders the price in the dedicated
1229 + // below-block so the data-fluent-cart-product-item-price element keeps
1230 + // a consistent position across every view/column combination.
1231 + if ($this->product->detail->variation_type === Helper::PRODUCT_TYPE_SIMPLE_VARIATION) {
1232 + $isInlineRowLayout = in_array($this->viewType, ['text', 'both'], true)
1233 + && $this->columnType === 'one';
1234 +
1235 + return !$isInlineRowLayout;
1236 + }
1237 +
1238 + return true;
932 1239 }
933 1240
934 1241 public function applyVariationPriceFilter($variant, $paymentType = 'onetime')
935 1242 {
@@ -938,14 +1245,15 @@
938 1245 'product' => $this->product,
939 1246 'variant' => $variant,
940 1247 'scope' => 'product_variant_price'
941 1248 ]));
942 - do_action('fluent_cart/product/after_price', [
1249 + do_action('fluent_cart/product/after_price', RenderContext::decorate([
943 1250 'product' => $this->product,
944 1251 'variant' => $variant,
945 1252 'current_price' => $variant->item_price,
946 1253 'scope' => 'product_variant_price'
947 - ]);
1254 + ]));
1255 + RenderHelper::renderPriceSuffix($this->product, $variant, 'product_variant_price');
948 1256 }
949 1257
950 1258 public function renderComparePriceWrapperStart($atts = [])
951 1259 {
@@ -967,8 +1275,9 @@
967 1275 return;
968 1276 } ?>
969 1277
970 1278 <span class="fct-compare-price">
1279 + <span class="fct-sr-only"><?php echo esc_html__('Original price:', 'fluent-cart'); ?></span>
971 1280 <del><?php echo esc_html(Helper::toDecimal($variant->compare_price)); ?></del>
972 1281 </span>
973 1282 <?php
974 1283 }
@@ -1054,8 +1363,14 @@
1054 1363 <?php }
1055 1364
1056 1365 public function renderQuantity()
1057 1366 {
1367 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
1368 +
1369 + if (!RenderGate::shouldRender('quantity', $gateContext)) {
1370 + return;
1371 + }
1372 +
1058 1373 $soldIndividually = $this->product->soldIndividually();
1059 1374
1060 1375 if (!$this->hasOnetime || $soldIndividually) {
1061 1376 return;
@@ -1074,12 +1389,12 @@
1074 1389 if ($this->hasSubscription && Arr::get($defaultVariantData, 'payment_type') !== 'onetime') {
1075 1390 $attributes['class'] .= ' is-hidden';
1076 1391 }
1077 1392
1078 - do_action('fluent_cart/product/single/before_quantity_block', [
1393 + do_action('fluent_cart/product/single/before_quantity_block', RenderContext::decorate([
1079 1394 'product' => $this->product,
1080 1395 'scope' => 'product_quantity_block'
1081 - ]);
1396 + ]));
1082 1397 ?>
1083 1398 <div <?php $this->renderAttributes($attributes); ?>>
1084 1399 <label for="fct-product-qty-input" class="quantity-title">
1085 1400 <?php esc_html_e('Quantity', 'fluent-cart'); ?>
@@ -1123,23 +1438,39 @@
1123 1438 </button>
1124 1439 </div>
1125 1440 </div>
1126 1441 <?php
1127 - do_action('fluent_cart/product/single/after_quantity_block', [
1442 + do_action('fluent_cart/product/single/after_quantity_block', RenderContext::decorate([
1128 1443 'product' => $this->product,
1129 1444 'scope' => 'product_quantity_block'
1130 - ]);
1445 + ]));
1131 1446 }
1132 1447
1133 1448 public function renderPurchaseButtons($atts = [])
1134 1449 {
1450 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
1451 +
1452 + if (!RenderGate::shouldRender('actions', $gateContext)) {
1453 + return;
1454 + }
1455 +
1456 + do_action('fluent_cart/product/single/before_actions_block', $gateContext);
1457 +
1135 1458 $buyNowButtonAtts = $atts;
1136 1459 $this->renderBuyNowButton($buyNowButtonAtts);
1137 1460 $this->renderAddToCartButton($atts);
1461 +
1462 + do_action('fluent_cart/product/single/after_actions_block', $gateContext);
1138 1463 }
1139 1464
1140 1465 public function renderBuyNowButton($atts = [])
1141 1466 {
1467 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
1468 +
1469 + if (!RenderGate::shouldRenderPurchaseButton('buy_now_button', $gateContext)) {
1470 + return;
1471 + }
1472 +
1142 1473 // Stock management check using isStock() method
1143 1474 // if (ModuleSettings::isActive('stock_management')) {
1144 1475 // if ($this->product->detail->variation_type === 'simple' && $this->defaultVariant) {
1145 1476 // if (!$this->defaultVariant->isStock()) {
@@ -1221,8 +1552,16 @@
1221 1552 }
1222 1553
1223 1554 public function renderBuyNowButtonBlock($atts = [])
1224 1555 {
1556 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
1557 +
1558 + // Same gate as the in-section button: a page assembled from standalone
1559 + // button blocks must honour catalog mode too, or the gate leaks.
1560 + if (!RenderGate::shouldRenderPurchaseButton('buy_now_button', $gateContext)) {
1561 + return;
1562 + }
1563 +
1225 1564 $text = Arr::get($atts, 'text', __('Buy Now', 'fluent-cart'));
1226 1565 $variantIds = Arr::get($atts, 'variant_ids', []);
1227 1566 $variantId = Arr::get($variantIds, 0);
1228 1567 $customClass = trim(Arr::get($atts, 'class', ''));
@@ -1307,8 +1646,14 @@
1307 1646 }
1308 1647
1309 1648 public function renderAddToCartButton($atts = [])
1310 1649 {
1650 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
1651 +
1652 + if (!RenderGate::shouldRenderPurchaseButton('add_to_cart_button', $gateContext)) {
1653 + return;
1654 + }
1655 +
1311 1656 $defaults = [
1312 1657 'buy_now_text' => __('Buy Now', 'fluent-cart'),
1313 1658 'add_to_cart_text' => __('Add To Cart', 'fluent-cart'),
1314 1659 ];
@@ -1356,10 +1701,17 @@
1356 1701 $wrapperAttributes = RenderHelper::getBlockWrapperAttributes($cartAttributes);
1357 1702 }
1358 1703
1359 1704
1360 - // Render add to cart if product supports onetime, or if out of stock (to show "Not Available")
1361 - if ($this->hasOnetime || $isOutOfStock) :
1705 + // Render add to cart when the product supports a one-time path, when out
1706 + // of stock (to show "Not Available"), or for advanced-variation products.
1707 + // The advanced selector toggles this button's visibility / disabled /
1708 + // payment-type state per selection, so it must exist in the DOM even for
1709 + // a subscription-only product whose in-stock default starts hidden via
1710 + // the is-hidden class applied above — otherwise an out-of-stock
1711 + // subscription combination has no button to surface "Not Available".
1712 + $isAdvancedVariation = $this->product->detail->variation_type === Helper::PRODUCT_TYPE_ADVANCE_VARIATION;
1713 + if ($this->hasOnetime || $isOutOfStock || $isAdvancedVariation) :
1362 1714 ?>
1363 1715 <?php
1364 1716 $variantTitle = $this->defaultVariant ? $this->defaultVariant->variation_title : '';
1365 1717 $addToCartAriaLabel = $variantTitle
@@ -1396,8 +1748,15 @@
1396 1748 }
1397 1749
1398 1750 public function renderAddToCartButtonBlock($atts = [])
1399 1751 {
1752 + $gateContext = RenderGate::context($this->product, RenderGate::SCOPE_SINGLE, $this->defaultVariant);
1753 +
1754 + // Same gate as the in-section button — see renderBuyNowButtonBlock().
1755 + if (!RenderGate::shouldRenderPurchaseButton('add_to_cart_button', $gateContext)) {
1756 + return;
1757 + }
1758 +
1400 1759 $text = Arr::get($atts, 'text', __('Add To Cart', 'fluent-cart'));
1401 1760 $customClass = trim(Arr::get($atts, 'class', ''));
1402 1761 $extraClass = trim(Arr::get($atts, 'extra_class', ''));
1403 1762
@@ -1492,9 +1851,9 @@
1492 1851 <p class="has-text-align-center has-large-font-size m-0">
1493 1852 <?php echo esc_html__('No Product Found!', 'fluent-cart'); ?>
1494 1853 </p>
1495 1854
1496 - <p class="has-text-align-center">
1855 + <p class="has-text-align-center m-0">
1497 1856 <?php echo esc_html__('You can try clearing any filters.', 'fluent-cart'); ?>
1498 1857 </p>
1499 1858 </div>
1500 1859 <?php
@@ -1531,14 +1890,8 @@
1531 1890 if ($variant->id == $defaultId) {
1532 1891 $itemClasses[] = 'selected';
1533 1892 }
1534 1893
1535 - $priceSuffix = apply_filters('fluent_cart/product/price_suffix_atts', '', [
1536 - 'product' => $this->product,
1537 - 'variant' => $variant,
1538 - 'scope' => 'variant_item'
1539 - ]);
1540 -
1541 1894 $renderingAttributes = [
1542 1895 'data-fluent-cart-product-variant' => '',
1543 1896 'data-cart-id' => $variant->id,
1544 1897 'data-item-stock' => $variant->isStock() ? 'in-stock' : 'out-of-stock',
@@ -1546,9 +1899,8 @@
1546 1899 'data-payment-type' => $paymentType,
1547 1900 'data-available-stock' => $availableStocks,
1548 1901 'data-item-price' => Helper::toDecimal($variant->item_price),
1549 1902 'data-compare-price' => $comparePrice,
1550 - 'data-price-suffix' => $priceSuffix,
1551 1903 'data-stock-management' => ModuleSettings::isActive('stock_management') ? 'yes' : 'no',
1552 1904 'data-sku' => $variant->sku ?? '',
1553 1905 'data-package-info' => $this->getVariantPackageInfoJson($variant),
1554 1906 ];
@@ -1594,30 +1946,29 @@
1594 1946 if ($this->viewType === 'both' || $this->viewType === 'image') {
1595 1947 $this->renderVariantImage($variant);
1596 1948 }
1597 1949 ?>
1598 - <?php
1599 - if ($this->viewType === 'both' || $this->viewType === 'text') {
1600 - echo '<div class="fct-product-variant-title" aria-label="' . esc_attr(__('Variant title', 'fluent-cart')) . '">' . esc_html($variant->variation_title) . '</div>';
1601 - }
1602 - ?>
1950 + <?php if ($this->viewType === 'both' || $this->viewType === 'text'): ?>
1951 + <div class="fct-product-variant-text">
1952 + <div class="fct-product-variant-title"><?php echo esc_html($variant->variation_title); ?></div>
1953 + <?php if (!$this->shouldRenderPriceInPriceSection() && $paymentType === 'subscription'): ?>
1954 + <?php $this->renderSubscriptionInfo($variant); ?>
1955 + <?php endif; ?>
1956 + </div>
1957 + <?php endif; ?>
1603 1958 </div>
1604 1959
1605 - <?php if ($this->viewType === 'text' && $paymentType === 'subscription' && $this->columnType === 'one'): ?>
1606 -
1607 - <?php $this->renderSubscriptionInfo($variant); ?>
1608 - <?php endif; ?>
1609 -
1610 - <?php if ($this->viewType === 'text' && $this->columnType === 'one'): ?>
1960 + <?php if (!$this->shouldRenderPriceInPriceSection()): ?>
1611 1961 <div class="fct-product-variant-price">
1612 1962 <?php if ($comparePrice): ?>
1613 1963 <div class="fct-product-variant-compare-price">
1614 - <del aria-label="<?php echo esc_attr(__('Original price', 'fluent-cart')); ?>">
1964 + <span class="fct-sr-only"><?php echo esc_html__('Original price:', 'fluent-cart'); ?></span>
1965 + <del>
1615 1966 <span><?php echo esc_html(Helper::toDecimal($comparePrice)); ?></span></del>
1616 1967 </div>
1617 1968 <?php endif; ?>
1618 - <div class="fct-product-variant-item-price"
1619 - aria-label="<?php echo esc_attr(__('Current price', 'fluent-cart')); ?>">
1969 + <div class="fct-product-variant-item-price">
1970 + <span class="fct-sr-only"><?php echo $comparePrice ? esc_html__('Sale price:', 'fluent-cart') : esc_html__('Price:', 'fluent-cart'); ?></span>
1620 1971 <span><?php echo esc_html(Helper::toDecimal($itemPrice)); ?></span>
1621 1972 </div>
1622 1973 </div>
1623 1974 <?php endif; ?>
@@ -1637,9 +1988,9 @@
1637 1988 public function renderVariantImage($variant)
1638 1989 {
1639 1990 $image = $variant->thumbnail;
1640 1991 if (!$image) {
1641 - $image = Vite::getAssetUrl('images/placeholder.svg');
1992 + $image = Helper::getProductPlaceholderUrl();
1642 1993 }
1643 1994 ?>
1644 1995 <div class="fct-product-variant-image">
1645 1996 <img role="img" alt="<?php echo esc_attr($variant->variation_title); ?>"
@@ -1741,21 +2092,21 @@
1741 2092 //Convert to collection safely before sorting
1742 2093 $variants = (new Collection($variants))->sortBy('serial_index')->values();
1743 2094
1744 2095 foreach ($variants as $variant) {
1745 - do_action('fluent_cart/product/single/before_variant_item', [
2096 + do_action('fluent_cart/product/single/before_variant_item', RenderContext::decorate([
1746 2097 'product' => $this->product,
1747 2098 'variant' => $variant,
1748 2099 'scope' => 'product_variant_item'
1749 - ]);
2100 + ]));
1750 2101
1751 2102 $this->renderVariationItem($variant, $this->defaultVariationId);
1752 2103
1753 - do_action('fluent_cart/product/single/after_variant_item', [
2104 + do_action('fluent_cart/product/single/after_variant_item', RenderContext::decorate([
1754 2105 'product' => $this->product,
1755 2106 'variant' => $variant,
1756 2107 'scope' => 'product_variant_item'
1757 - ]);
2108 + ]));
1758 2109 }
1759 2110 ?>
1760 2111 </div>
1761 2112