setono / sylius-age-verification-plugin
Setono example plugin for Sylius.
Package info
github.com/Setono/sylius-age-verification-plugin
Type:sylius-plugin
pkg:composer/setono/sylius-age-verification-plugin
Fund package maintenance!
Requires
- php: >=8.1
- doctrine/orm: ^2.0 || ^3.0
- doctrine/persistence: ^3.4
- setono/doctrine-orm-trait: ^1.2
- sylius/admin-bundle: ^1.0
- sylius/channel: ^1.0
- sylius/core: ^1.0
- sylius/core-bundle: ^1.0
- sylius/order: ^1.0
- sylius/product-bundle: ^1.0
- symfony/config: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/event-dispatcher: ^6.4
- symfony/form: ^6.4
- symfony/http-client-contracts: ^3.4
- symfony/http-foundation: ^6.4
- symfony/http-kernel: ^6.4
- symfony/routing: ^6.4
- symfony/uid: ^6.4
- twig/twig: ^2.0 || ^3.0
- webmozart/assert: ^1.11
Requires (Dev)
- api-platform/core: ^2.7.16
- babdev/pagerfanta-bundle: ^3.8
- behat/behat: ^3.14
- doctrine/doctrine-bundle: ^2.11
- jms/serializer-bundle: ^4.2
- lexik/jwt-authentication-bundle: ^2.17
- setono/sylius-plugin-pack: ~1.14.1
- shipmonk/composer-dependency-analyser: ^1.6
- sylius-labs/polyfill-symfony-security: ^1.1.2
- symfony/debug-bundle: ^6.4
- symfony/dotenv: ^6.4
- symfony/intl: ^6.4
- symfony/property-info: ^6.4
- symfony/serializer: ^6.4
- symfony/web-profiler-bundle: ^6.4
- symfony/webpack-encore-bundle: ^1.17.2
- willdurand/negotiation: ^3.1
This package is auto-updated.
Last update: 2026-03-10 10:16:36 UTC
README
A plugin to add age verification to your Sylius store using VerifyID as the age verification provider.
During checkout, if the customer's cart contains products with a minimum age requirement and the shipping address is in an enabled country, the plugin prompts the customer to verify their age via VerifyID before completing the order. Supported minimum age thresholds are 16 and 18.
Prerequisites
You need a VerifyID account. From the VerifyID dashboard, obtain your Plugin Key.
Installation
Step 1: Install the plugin
composer require setono/sylius-age-verification-plugin
Step 2: Register the bundle
Add the plugin to your config/bundles.php file:
return [ // ... Setono\SyliusAgeVerificationPlugin\SetonoSyliusAgeVerificationPlugin::class => ['all' => true], // ... ];
Step 3: Configure environment variables
Add the following environment variable to your .env.local:
VERIFYID_PLUGIN_KEY=your-plugin-key
Step 4: Import routes
Create config/routes/setono_sylius_age_verification.yaml:
setono_sylius_age_verification: resource: "@SetonoSyliusAgeVerificationPlugin/Resources/config/routes.yaml"
Step 5: Configure the plugin
Create config/packages/setono_sylius_age_verification.yaml:
setono_sylius_age_verification: enabled_countries: - DK # Add the country codes where age verification should be enforced
Step 6: Extend entities
Extend the Customer entity
<?php declare(strict_types=1); namespace App\Entity\Customer; use Doctrine\ORM\Mapping as ORM; use Setono\SyliusAgeVerificationPlugin\Model\AgeAwareCustomerInterface; use Setono\SyliusAgeVerificationPlugin\Model\AgeAwareCustomerTrait; use Sylius\Component\Core\Model\Customer as BaseCustomer; #[ORM\Entity] #[ORM\Table(name: 'sylius_customer')] class Customer extends BaseCustomer implements AgeAwareCustomerInterface { use AgeAwareCustomerTrait; }
Register it in your Sylius configuration (e.g. config/packages/_sylius.yaml):
sylius_customer: resources: customer: classes: model: App\Entity\Customer\Customer
Extend the Product entity
<?php declare(strict_types=1); namespace App\Entity\Product; use Doctrine\ORM\Mapping as ORM; use Setono\SyliusAgeVerificationPlugin\Model\AgeAwareProductInterface; use Setono\SyliusAgeVerificationPlugin\Model\AgeAwareProductTrait; use Sylius\Component\Core\Model\Product as BaseProduct; #[ORM\Entity] #[ORM\Table(name: 'sylius_product')] class Product extends BaseProduct implements AgeAwareProductInterface { use AgeAwareProductTrait; }
Register it in your Sylius configuration (e.g. config/packages/_sylius.yaml):
sylius_product: resources: product: classes: model: App\Entity\Product\Product
Step 7: Update your database schema
bin/console doctrine:migrations:diff bin/console doctrine:migrations:migrate
Usage
Once installed, an Age verification tab appears on the product edit page in the Sylius admin. Set a minimum age (16 or 18) for any product that requires age verification.
During checkout, if the order contains age-restricted products and the shipping address is in one of the configured enabled_countries, the customer will be prompted to verify their age via VerifyID before they can complete the order. Once verified, the result is stored on the customer entity and reused for future orders.