setono/sylius-climate-partner-plugin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

setono/sylius-climate-partner-plugin

Composer 安装命令:

composer require setono/sylius-climate-partner-plugin

包简介

Setono example plugin for Sylius.

README 文档

README

Latest Version Latest Unstable Version Software License Build Status Code Coverage

This plugin will allow customers to add climate offsets to their orders.

frontend.mp4

Installation

composer require setono/sylius-climate-partner-plugin

Import configuration

# config/packages/setono_sylius_climate_partner.yaml
imports:
    # ...
    - { resource: "@SetonoSyliusClimatePartnerPlugin/Resources/config/app/config.yaml" }

Import routing

# config/routes/setono_sylius_climate_partner.yaml
setono_sylius_climate_partner:
    resource: "@SetonoSyliusClimatePartnerPlugin/Resources/config/routes.yaml"

or if your app doesn't use locales:

# config/routes/setono_sylius_climate_partner.yaml
setono_sylius_climate_partner:
    resource: "@SetonoSyliusClimatePartnerPlugin/Resources/config/routes_no_locale.yaml"

Add plugin class to your bundles.php

Make sure you add it before SyliusGridBundle, otherwise you'll get You have requested a non-existent parameter "setono_sylius_climate_partner.model.channel_climate_fee.class". exception.

<?php
// config/bundles.php

$bundles = [
    // ...
    Setono\SyliusClimatePartnerPlugin\SetonoSyliusClimatePartnerPlugin::class => ['all' => true],
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
    // ...
];

Copy API resources

In order to add ClimatePartner API endpoints to Sylius Order section, the API Resource declaration has to be overridden. If you've not overridden those configuration yet, you can simply copy the whole files into your local config/api_resources folder. If you've overridden them already, then you can just merge your config with the endpoints we added.

Resources declaration that need to be copied are:

If you already have them overridden, just add the following item operations:

Order.xml

<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>

统计信息

  • 总下载量: 13.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-07