setono / sylius-climate-partner-plugin
Setono为Sylius提供的示例插件。
dev-master / 1.0.x-dev
2022-01-26 12:04 UTC
Requires
- php: >=7.4
- api-platform/core: ^2.6
- doctrine/persistence: ^1.3 || ^2.2
- knplabs/knp-menu: ^3.2
- psr/log: ^1.1
- sylius/resource-bundle: ^1.6
- symfony/config: ^4.4 || ^5.0
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/form: ^4.4 || ^5.0
- symfony/http-foundation: ^4.4 || ^5.0.7
- symfony/http-kernel: ^4.4 || ^5.1.5
- symfony/messenger: ^4.4 || ^5.0
- symfony/routing: ^4.4 || ^5.0
- symfony/translation-contracts: ^1.1 || ^2.4
- webmozart/assert: ^1.10
Requires (Dev)
- friendsofsymfony/oauth-server-bundle: >2.0.0-alpha.0 ^2.0@dev
- lexik/jwt-authentication-bundle: ^2.14
- matthiasnoback/symfony-config-test: ^4.3
- matthiasnoback/symfony-dependency-injection-test: ^4.3
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.16.1
- psalm/plugin-symfony: ^3.0
- roave/security-advisories: dev-latest
- setono/code-quality-pack: ^2.1.3
- setono/sylius-behat-pack: ^0.2.2
- sylius/admin-api-bundle: ^1.10
- sylius/sylius: ~1.10.7
- symfony/debug-bundle: ^4.4 || ^5.0
- symfony/dotenv: ^4.4 || ^5.0
- symfony/intl: ^4.4 || ^5.0
- symfony/property-info: ^4.4 || ^5.0
- symfony/proxy-manager-bridge: ^4.4.25 || ^5.0
- symfony/serializer: ^4.4 || ^5.0
- symfony/web-profiler-bundle: ^4.4 || ^5.0
- symfony/webpack-encore-bundle: ^1.13
This package is auto-updated.
Last update: 2024-09-15 19:12:21 UTC
README
此插件允许客户在订单中添加气候补偿。
frontend.mp4
安装
composer require setono/sylius-climate-partner-plugin
导入配置
# config/packages/setono_sylius_climate_partner.yaml imports: # ... - { resource: "@SetonoSyliusClimatePartnerPlugin/Resources/config/app/config.yaml" }
导入路由
# config/routes/setono_sylius_climate_partner.yaml setono_sylius_climate_partner: resource: "@SetonoSyliusClimatePartnerPlugin/Resources/config/routes.yaml"
或者如果你的应用不使用区域设置
# config/routes/setono_sylius_climate_partner.yaml setono_sylius_climate_partner: resource: "@SetonoSyliusClimatePartnerPlugin/Resources/config/routes_no_locale.yaml"
将插件类添加到你的 bundles.php
确保你将其添加在 SyliusGridBundle
之前,否则你会得到 您请求了一个不存在的参数 "setono_sylius_climate_partner.model.channel_climate_fee.class"。
异常。
<?php // config/bundles.php $bundles = [ // ... Setono\SyliusClimatePartnerPlugin\SetonoSyliusClimatePartnerPlugin::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], // ... ];
复制API资源
为了将ClimatePartner API端点添加到Sylius订单部分,必须覆盖API资源声明。如果您尚未覆盖这些配置,您可以简单地将整个文件复制到您的本地 config/api_resources
文件夹中。如果您已经覆盖了它们,则只需将您的配置与我们所添加的端点合并即可。
需要复制的资源声明是
如果您已经覆盖了它们,请添加以下项目操作
<itemOperation name="shop_apply_climate_offset"> <attribute name="method">PATCH</attribute> <attribute name="path">/shop/orders/{tokenValue}/apply-climate-offset</attribute> <attribute name="messenger">input</attribute> <attribute name="input">Setono\SyliusClimatePartnerPlugin\Api\Command\ApplyClimateOffset</attribute> <attribute name="openapi_context"> <attribute name="summary">Apply climate offset to cart</attribute> </attribute> <attribute name="denormalization_context"> <attribute name="groups">shop:climate-offset:apply</attribute> </attribute> </itemOperation> <itemOperation name="shop_remove_climate_offset"> <attribute name="method">PATCH</attribute> <attribute name="path">/shop/orders/{tokenValue}/remove-climate-offset</attribute> <attribute name="messenger">input</attribute> <attribute name="input">Setono\SyliusClimatePartnerPlugin\Api\Command\RemoveClimateOffset</attribute> <attribute name="openapi_context"> <attribute name="summary">Remove climate offset to cart</attribute> </attribute> <attribute name="denormalization_context"> <attribute name="groups">shop:climate-offset:apply</attribute> </attribute> </itemOperation>