setono / sylius-terms-plugin
Sylius 条款和条件插件
Requires
- php: >=8.1
- doctrine/collections: ^1.6
- doctrine/orm: ^2.7
- fakerphp/faker: ^1.23
- knplabs/knp-menu: ^3.1
- sylius/channel: ^1.0
- sylius/channel-bundle: ^1.0
- sylius/core: ^1.0
- sylius/core-bundle: ^1.0
- sylius/locale: ^1.0
- sylius/resource-bundle: ^1.6
- sylius/ui-bundle: ^1.0
- symfony/config: ^5.4 || ^6.4 || ^7.0
- symfony/dependency-injection: ^5.4 || ^6.4 || ^7.0
- symfony/event-dispatcher: ^5.4 || ^6.4 || ^7.0
- symfony/form: ^5.4 || ^6.4 || ^7.0
- symfony/http-foundation: ^5.4 || ^6.4 || ^7.0
- symfony/http-kernel: ^5.4 || ^6.4 || ^7.0
- symfony/options-resolver: ^5.4 || ^6.4 || ^7.0
- symfony/routing: ^5.4 || ^6.4 || ^7.0
- symfony/string: ^5.4 || ^6.4 || ^7.0
- symfony/translation-contracts: ^1.1 || ^2.4 || ^3.4
- symfony/validator: ^5.4 || ^6.4 || ^7.0
- twig/twig: ^2.14 || ^3.8
- 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
- infection/infection: ^0.27.9
- jms/serializer-bundle: ^4.2
- lexik/jwt-authentication-bundle: ^2.17
- matthiasnoback/symfony-config-test: ^4.3 || ^5.1
- matthiasnoback/symfony-dependency-injection-test: ^4.3 || ^5.0
- phpspec/prophecy-phpunit: ^2.1
- phpunit/phpunit: ^9.6
- psalm/plugin-phpunit: ^0.18
- setono/code-quality-pack: ^2.7
- sylius/sylius: ~1.12.13
- symfony/debug-bundle: ^5.4 || ^6.4 || ^7.0
- symfony/dotenv: ^5.4 || ^6.4 || ^7.0
- symfony/intl: ^5.4 || ^6.4 || ^7.0
- symfony/property-info: ^5.4 || ^6.4 || ^7.0
- symfony/serializer: ^5.4 || ^6.4 || ^7.0
- symfony/web-profiler-bundle: ^5.4 || ^6.4 || ^7.0
- symfony/webpack-encore-bundle: ^1.17
- willdurand/negotiation: ^3.1
This package is auto-updated.
Last update: 2024-09-23 08:09:37 UTC
README
将在选择表单中添加复选框,客户在接受条款和条件之前不能继续。
这可以确保客户在下单前已经接受了条款和条件。
屏幕截图
商店
在客户可以下单之前,他/她必须检查所需条款
管理员
这是一份条款列表。请注意与多个渠道关联的 terms_and_conditions
。
请注意,您选择显示条款的表单。默认情况下,只有 Checkout > Complete
表单可用,但您可以在 setono_sylius_terms.forms
配置选项中添加更多。
Label
字段是完整订单页面上显示的文本。请注意,您可以使用占位符 ([link:链接文本]
) 来告诉链接应该放在哪里。
安装
步骤 1:下载插件
composer require setono/sylius-terms-plugin
步骤 2:启用插件
然后,通过将其添加到项目 config/bundles.php
文件中注册的插件/包列表中来启用插件
<?php # config/bundles.php return [ // ... Setono\SyliusTermsPlugin\SetonoSyliusTermsPlugin::class => ['all' => true], // It is important to add plugin before the grid bundle Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], // ... ];
注意 您必须在网格包之前实例化插件,否则您将看到类似 您已请求不存在参数 "setono_sylius_terms.model.terms.class"。
的异常。
步骤 3:导入路由
# config/routes/setono_sylius_terms.yaml setono_sylius_terms: resource: "@SetonoSyliusTermsPlugin/Resources/config/routes.yaml"
还有一个非本地化商店的版本:@SetonoSyliusTermsPlugin/Resources/config/routes_no_locale.yaml
步骤 4:更新数据库模式
$ php bin/console doctrine:migrations:diff $ php bin/console doctrine:migrations:migrate
步骤 5:覆盖结账完成表单
覆盖 Sylius 表单
-
如果您还没有自己的
templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig
$ cp vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Complete/_form.html.twig \ templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig
-
如果您已经有了它
添加条款字段(精确地以这种方式添加)
{# templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig #} {% if form.terms is defined %} {{ form_row(form.terms) }} {% endif %}
所以最终的模板将看起来像这样
{# templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig #} {{ form_row(form.notes, {'attr': {'rows': 3}}) }} {% if form.terms is defined %} {{ form_row(form.terms) }} {% endif %}
故障排除
-
如果您看到
在类 "Symfony\Component\Form\FormView" 中 neither the property "terms" nor one of the methods "terms()", "getterms()"/"isterms()"/"hasterms()" or "__call()" exist and have public access.
然后查看 #13 并再次检查您是否在模板中添加了条款字段,如
覆盖结账完成表单
部分所述。 -
如果您看到
网格 "setono_sylius_terms_terms" 不存在
那么您忘记从
步骤 3:导入配置
部分导入配置。