drweb/sylius-trustpilot-plugin

Trustpilot integration plugin for Sylius - displays customer reviews with customizable widgets

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:sylius-plugin

pkg:composer/drweb/sylius-trustpilot-plugin


README

Sylius Logo.

Sylius Trustpilot Plugin

Latest Version Packagist Version License Total Downloads

Display Trustpilot customer reviews and ratings in your Sylius store with customizable widgets - no premium subscription required!

Overview

This plugin integrates Trustpilot reviews directly into your Sylius e-commerce store. It automatically fetches and displays customer reviews from your public Trustpilot profile, allowing you to showcase social proof throughout your store.

Features

Easy Configuration - Simple admin panel to configure all settings ✅ Multiple Widget Types - Choose from Mini, Carousel, or List display formats ✅ No Premium Required - All features work without Trustpilot premium subscription ✅ Flexible Placement - Display widgets on homepage and product pages ✅ Theme Support - Light and dark themes to match your store design ✅ Smart Caching - 1-hour cache reduces server load and improves performance ✅ Customizable Display - Control number of reviews, stars visibility, and review count ✅ Auto-placement - Uses Sylius Twig hooks for automatic widget injection

Requirements

  • PHP ^8.2
  • Sylius ^2.0

Installation

1. Install via Composer

composer require drweb/sylius-trustpilot-plugin

2. Enable the Plugin

The plugin should be automatically registered. If not, add it to config/bundles.php:

return [
    // ...
    Drweb\SyliusTrustpilotPlugin\DrwebSyliusTrustpilotPlugin::class => ['all' => true],
];

3. Import Configuration (if needed)

If your Sylius installation requires manual configuration import, add to config/packages/_sylius.yaml:

imports:
    - { resource: "@DrwebSyliusTrustpilotPlugin/config/config.yaml" }

4. Import Routes

Add to your config/routes.yaml:

drweb_sylius_trustpilot_admin:
    resource: "@DrwebSyliusTrustpilotPlugin/config/routes/admin.yaml"
    prefix: /admin

drweb_sylius_trustpilot_shop:
    resource: "@DrwebSyliusTrustpilotPlugin/config/routes/shop.yaml"

5. Run Database Migrations

php bin/console doctrine:migrations:migrate

6. Clear Cache

php bin/console cache:clear

Configuration

Admin Panel Setup

  1. Access Configuration Page

    • Log in to your Sylius admin panel
    • Navigate to: ConfigurationTrustpilot Configuration
    • Or directly access: /admin/trustpilot/configuration
  2. Enter Your Trustpilot Profile

    • Trustpilot URL: Enter your company's Trustpilot profile URL
      • Full URL: https://www.trustpilot.com/review/example.com
      • Or just domain: example.com
    • Click Test Connection to verify it works
  3. Configure Display Settings

    • Enable on Homepage: Toggle to show/hide on homepage
    • Enable on Product Pages: Toggle to show/hide on product pages
  4. Customize Widget Appearance

    • Theme: Choose Light or Dark
    • Template:
      • Mini - Compact rating display with star rating and review count
      • Carousel - Rotating reviews slider with auto-scroll
      • List - Vertical stacked list of reviews
    • Number of Reviews: Select how many reviews to display (1-20)
    • Show Star Rating: Toggle individual review stars on/off
    • Show Review Count: Toggle total review count display
  5. Save Changes

Widget Templates

Mini Widget

Compact display showing:

  • Trustpilot logo
  • Overall star rating
  • Trust score (e.g., 4.5/5)
  • Total number of reviews

Perfect for headers, footers, or tight spaces.

Carousel Widget

Interactive slider featuring:

  • Overall rating and review count header
  • Individual reviews with rotation
  • Star ratings, review titles, and excerpts
  • Author names and dates
  • Previous/Next navigation buttons
  • Auto-scroll every 5 seconds

Great for homepage and landing pages.

List Widget

Vertical list showing:

  • Overall rating header
  • Full individual reviews stacked vertically
  • Star ratings, titles, and full text
  • Author details and verification badges
  • Cleaner layout for detailed reading

Ideal for product pages and dedicated review sections.

Widget Placement

Automatic Placement (Default)

The plugin automatically places widgets using Sylius Twig hooks:

  • Homepage: Injected into the homepage index section
  • Product Page: Displayed in the product summary (after price info)

Manual Placement

You can manually place widgets anywhere in your templates:

{# Check if enabled and display widget #}
{% if trustpilot_is_enabled('homepage') %}
    {{ trustpilot_widget('homepage')|raw }}
{% endif %}

{# Or for product pages #}
{% if trustpilot_is_enabled('product') %}
    {{ trustpilot_widget('product')|raw }}
{% endif %}

Custom Hook Integration

The plugin registers the following Twig hooks:

# Shop hooks
- sylius_shop.homepage.index
- sylius_shop.product.show.content.info.summary
- sylius_shop.product.show.content.product_listing

How It Works

Smart Review Scraping

The plugin uses an intelligent scraping approach to fetch reviews from your public Trustpilot profile:

  1. Fetches Public Data: Retrieves reviews from your publicly accessible Trustpilot page
  2. Dual Extraction Method:
    • Primary: Extracts data from JSON-LD structured data (most reliable)
    • Fallback: HTML parsing if JSON-LD is unavailable
  3. Smart Caching: Reviews are cached for 1 hour to minimize server load
  4. No API Required: Works without Trustpilot API keys or premium subscription

What Gets Displayed

  • Overall trust score and star rating
  • Total number of reviews
  • Individual reviews with:
    • Star rating (1-5)
    • Review title
    • Review text (full or excerpt)
    • Author name
    • Review date
    • Verification badge (if verified)

Technical Details

  • Uses Symfony HTTP Client for requests
  • Adds ?languages=all parameter to get reviews in all languages
  • Fetches up to 20 reviews from initial page load
  • Fully styled, responsive widgets
  • No external JavaScript dependencies
  • Compatible with light and dark themes

Important Considerations

⚠️ Legal & Ethical Notice

This plugin scrapes publicly available data from Trustpilot. Before using in production:

  • Review Trustpilot's Terms of Service
  • Consider potential legal implications of web scraping
  • Be aware that Trustpilot may change their HTML structure at any time
  • Use responsibly and ethically

Advantages

  • No API costs or premium subscription required
  • All widget templates available
  • Full control over display and styling
  • Works with any Trustpilot business profile

⚠️ Limitations

  • Scraping may violate Trustpilot's Terms of Service
  • HTML structure changes could break functionality
  • Limited to ~20 reviews per page load
  • No real-time updates (1-hour cache)

Development

Running Tests

# PHPUnit
vendor/bin/phpunit

# Behat (non-JS)
vendor/bin/behat --strict --tags="~@javascript"

# PHPStan
vendor/bin/phpstan analyse -c phpstan.neon -l max src/

# Code Standards
vendor/bin/ecs check

Docker Development

# Initialize
make init

# Database setup
make database-init

# Load fixtures (optional)
make load-fixtures

# Start containers
make up

# Access at http://localhost

Traditional Development

# Install frontend dependencies
(cd vendor/sylius/test-application && yarn install)
(cd vendor/sylius/test-application && yarn build)
vendor/bin/console assets:install

# Database setup
vendor/bin/console doctrine:database:create
vendor/bin/console doctrine:migrations:migrate -n
vendor/bin/console sylius:fixtures:load -n

# Start server
symfony server:start -d

# Access at https://localhost:8000

Troubleshooting

Reviews Not Showing

  1. Verify Trustpilot URL: Make sure the URL is correct in admin configuration
  2. Test Connection: Use the "Test Connection" button in admin panel
  3. Clear Cache: Run php bin/console cache:clear
  4. Check Logs: Look in var/log/ for any errors

Widget Not Displaying

  1. Check Settings: Ensure widget is enabled for the desired location (homepage/product page)
  2. Clear Cache: Clear both Symfony and browser cache
  3. Verify Templates: Ensure templates are not overridden in your theme

Connection Errors

  1. Firewall: Check if your server can access trustpilot.com
  2. Rate Limiting: Trustpilot may block excessive requests
  3. Cache: Clear the cache to force a new fetch

Future Enhancements

  • Product-specific reviews using SKU mapping
  • Multi-channel/locale widget configurations
  • Review invitation automation
  • Additional customization options
  • Admin command for manual cache refresh
  • Fallback to official Trustpilot API
  • Enhanced error handling and logging
  • Support for Sylius 1.x versions

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This plugin is licensed under the MIT License.

Support

For issues, questions, or contributions, please use the GitHub issue tracker.

Credits

Developed by Drweb for the Sylius e-commerce platform.

Disclaimer

This plugin is not affiliated with, endorsed by, or sponsored by Trustpilot. Trustpilot is a registered trademark of Trustpilot A/S.