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
Requires
- php: ^8.2
- sylius/sylius: ^2.0
Requires (Dev)
- behat/behat: ^3.16
- dmore/behat-chrome-extension: ^1.4
- dmore/chrome-mink-driver: ^2.9
- friends-of-behat/mink: ^1.11
- friends-of-behat/mink-browserkit-driver: ^1.6
- friends-of-behat/mink-debug-extension: ^2.1
- friends-of-behat/mink-extension: ^2.7
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.6
- friends-of-behat/variadic-extension: ^1.6
- nyholm/psr7: ^1.8
- phpstan/phpstan: ^1.12
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^10.5
- robertfausk/behat-panther-extension: ^1.1
- sylius-labs/coding-standard: ^4.4
- sylius-labs/suite-tags-extension: ~0.2
- sylius/sylius-rector: ^2.0
- sylius/test-application: ^2.0.0@alpha
- symfony/browser-kit: ^6.4 || ^7.1
- symfony/debug-bundle: ^6.4 || ^7.1
- symfony/dotenv: ^6.4 || ^7.1
- symfony/http-client: ^6.4 || ^7.1
- symfony/intl: ^6.4 || ^7.1
- symfony/runtime: ^6.4 || ^7.1
- symfony/web-profiler-bundle: ^6.4 || ^7.1
- symfony/webpack-encore-bundle: ^2.2
README
Sylius Trustpilot Plugin
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
-
Access Configuration Page
- Log in to your Sylius admin panel
- Navigate to: Configuration → Trustpilot Configuration
- Or directly access:
/admin/trustpilot/configuration
-
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
- Full URL:
- Click Test Connection to verify it works
- Trustpilot URL: Enter your company's Trustpilot profile URL
-
Configure Display Settings
- Enable on Homepage: Toggle to show/hide on homepage
- Enable on Product Pages: Toggle to show/hide on product pages
-
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
-
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:
- Fetches Public Data: Retrieves reviews from your publicly accessible Trustpilot page
- Dual Extraction Method:
- Primary: Extracts data from JSON-LD structured data (most reliable)
- Fallback: HTML parsing if JSON-LD is unavailable
- Smart Caching: Reviews are cached for 1 hour to minimize server load
- 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=allparameter 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
- Verify Trustpilot URL: Make sure the URL is correct in admin configuration
- Test Connection: Use the "Test Connection" button in admin panel
- Clear Cache: Run
php bin/console cache:clear - Check Logs: Look in
var/log/for any errors
Widget Not Displaying
- Check Settings: Ensure widget is enabled for the desired location (homepage/product page)
- Clear Cache: Clear both Symfony and browser cache
- Verify Templates: Ensure templates are not overridden in your theme
Connection Errors
- Firewall: Check if your server can access
trustpilot.com - Rate Limiting: Trustpilot may block excessive requests
- 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.