GENERAL
BACKEND
FRONTEND
ADDITIONAL
We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.
Package | Version |
---|---|
PHP | >= 8.1 |
sylius/sylius | 1.12.x - 1.13.x |
MySQL | >= 5.7 |
NodeJS | >= 14.x |
composer require bitbag/agreement-plugin --no-scripts
Add plugin dependencies to your config/bundles.php
file:
# config/bundles.php
return [
...
BitBag\SyliusAgreementPlugin\BitBagSyliusAgreementPlugin::class => ['all' => true],
];
Import required config in your config/packages/_sylius.yaml
file:
# config/packages/_sylius.yaml
imports:
...
- { resource: "@BitBagSyliusAgreementPlugin/Resources/config/config.yaml" }
Add routing to your config/routes.yaml
file:
# config/routes.yaml
bitbag_sylius_agreement_plugin:
resource: "@BitBagSyliusAgreementPlugin/Resources/config/routing.yml"
-
In other words, depending on where you want the agreement checkbox to appear, you need to extend other entities and make other configuration changes.
-
The configuration for the
registration form
has already been added:
vendor/bitbag/agreement-plugin/src/Resources/config/config.yaml
- example for the configuration of the following form:
bit_bag_sylius_agreement:
contexts:
checkout_form:
- Sylius\Bundle\CoreBundle\Form\Type\Checkout\AddressType
Add a translation for the new form, e.g. in translations/messages.en.yaml
:
bitbag_sylius_agreement_plugin:
ui:
agreement:
contexts:
checkout_form: Checkout form
bin/console cache:clear
- Before you start extending entities, first determine what entity the form uses (in this case -
Customer
). Then add to the entity:
use AgreementsRequiredTrait;
...and interfaces.
You can implement entity configuration by using both xml-mapping and attribute-mapping. Depending on your preference, choose either one or the other:
First, please run legacy-versioned migrations by using command:
bin/console doctrine:migrations:migrate
After migration, please create a new diff migration and update database:
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
Note: If you are running it on production, add the -e prod
flag to this command.
bin/console cache:clear
Note: If you are running it on production, add the -e prod
flag to this command.
To add the agreement checkbox to the registration form, you need to add following code to the template with form:
{% for agreement in form.agreements %}
{{ form_row(agreement.approved) }}
{% endfor %}
For registration form
you can copy the template from the plugin:
ShopBundle (templates/bundles/SyliusShopBundle
):
vendor/bitbag/agreement-plugin/tests/Application/templates/bundles/SyliusShopBundle/Register/_form.html.twig
To run the tests, execute the commands:
composer install
cd tests/Application
yarn install
yarn build
bin/console doctrine:database:create --env=test
bin/console doctrine:schema:create --env=test
bin/console sylius:fixtures:load --env=test
APP_ENV=test symfony server:start --dir=public/
cd ../..
vendor/bin/behat
For incorrectly displayed translations, execute the command:
bin/console cache:clear