Skip to content

Instantly share code, notes, and snippets.

@vapvarun
Created October 17, 2025 12:55
Show Gist options
  • Select an option

  • Save vapvarun/fc6c80e95069ba11e3a9cf3c985d59af to your computer and use it in GitHub Desktop.

Select an option

Save vapvarun/fc6c80e95069ba11e3a9cf3c985d59af to your computer and use it in GitHub Desktop.
FluentCart Plugin Bug Report - ProductCardRender.php Line 45 Error

FluentCart Plugin Bug Report

Bug Description

There is a PHP syntax error in the FluentCart plugin that causes error messages and file paths to be displayed on product cards in archive/shop pages.

Affected File

File: app/Services/Renderer/ProductCardRender.php Line: 45

Current Code (WRONG)

<div data-fluent-cart-shop-app-single-product data-fc-product-card=""
     class="fc-single-product-card" <?php echo esc_attr($cursor); ?>
     style="width: <?php echo esc_attr($this->config['card_width'] . 'px' ?? ''); ?>;">

Issue

The null coalescing operator (??) is placed after the string concatenation, which means:

  1. It concatenates $this->config['card_width'] . 'px' first
  2. Then checks if the result is null (which a string never is)
  3. When $this->config['card_width'] doesn't exist, PHP throws a warning that gets output to the page

This results in error messages being displayed on product cards:

/Users/.../wp-content/plugins/fluent-cart/app/Services/Renderer/ProductCardRender.php on line 45
px;">

Correct Code (FIX)

<div data-fluent-cart-shop-app-single-product data-fc-product-card=""
     class="fc-single-product-card" <?php echo esc_attr($cursor); ?>
     style="width: <?php echo esc_attr(isset($this->config['card_width']) ? $this->config['card_width'] . 'px' : ''); ?>;">

Why This Fix Works

  1. First checks if $this->config['card_width'] exists using isset()
  2. Only concatenates with 'px' if the value exists
  3. Returns empty string if it doesn't exist
  4. No PHP warnings or errors are generated

How to Reproduce

  1. Install FluentCart plugin
  2. Create products with categories
  3. Visit any product category archive page
  4. View the product cards - you'll see error messages displayed

Environment

  • FluentCart Version: 1.2.2 (and likely other versions)
  • PHP Version: 8.x (where display_errors might be on)
  • WordPress Version: 6.8.3

Impact

  • Severity: Medium/High
  • Error messages with file paths are visible to end users
  • Affects all product archive, category, and brand pages
  • Makes the site look unprofessional
  • Could expose server file structure information

Recommended Action

Update line 45 in app/Services/Renderer/ProductCardRender.php with the corrected code above.

Additional Notes

This is a common PHP mistake where the null coalescing operator is placed incorrectly. The operator should check if the array key exists before concatenation, not after.


Reported by: BuddyX Theme Development Team Date: 2025-01-17 Plugin: FluentCart Version: 1.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment