mangoweb-sylius/sylius-payment-fee-plugin

此包已弃用且不再维护。作者建议使用3brs/sylius-payment-fee-plugin包。

Sylius的支付费用插件。


README

38423357?s=200&v=4

支付费用插件
68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d616e676f7765622d73796c6975732f73796c6975732d7061796d656e742d6665652d706c7567696e2e737667 68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616e676f7765622d73796c6975732f73796c6975732d7061796d656e742d6665652d706c7567696e2e737667 68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d616e676f7765622d73796c6975732f53796c6975735061796d656e74466565506c7567696e2f6d61737465722e737667

特性

  • 对使用支付方式收取额外费用。
  • 典型用法:货到付款。
  • 税费的实施方式与运费税费相同。

admin.png

安装

  1. 运行 $ composer require mangoweb-sylius/sylius-payment-fee-plugin
  2. 在您的Kernel中注册 \MangoSylius\PaymentFeePlugin\MangoSyliusPaymentFeePlugin
  3. 您的实体 PaymentMethod 必须实现 \MangoSylius\PaymentFeePlugin\Model\PaymentMethodWithFeeInterface。您可以使用Trait MangoSylius\PaymentFeePlugin\Model\PaymentMethodWithFeeTrait

有关如何使用自己的实体的指南,请参阅Sylius文档 - 自定义模型

管理界面

  1. 将此内容添加到@SyliusAdmin/PaymentMethod/_form.html.twig模板中。
<div class="ui segment">
	<h4 class="ui dividing header">{{ 'mango-sylius.ui.payment_charges'|trans }}</h4>
	{{ form_row(form.calculator) }}
	{% for name, calculatorConfigurationPrototype in form.vars.prototypes %}
		<div id="{{ form.calculator.vars.id }}_{{ name }}" data-container=".calculatorConfiguration"
			 data-prototype="{{ form_widget(calculatorConfigurationPrototype)|e }}">
		</div>
	{% endfor %}
	<div class="ui segment calculatorConfiguration">
		{% if form.calculatorConfiguration is defined %}
			{% for field in form.calculatorConfiguration %}
				{{ form_row(field) }}
			{% endfor %}
		{% endif %}
	</div>
</div>
  1. 将此内容添加到AdminBundle/Resources/views/Order/Show/Summary/_totals.html.twig
{% set paymentFeeAdjustment = constant('MangoSylius\\PaymentFeePlugin\\Model\\AdjustmentInterface::PAYMENT_ADJUSTMENT') %}

{% set paymentFeeAdjustments = order.getAdjustmentsRecursively(paymentFeeAdjustment) %}
{% if paymentFeeAdjustments is not empty %}
	<tr>
		<td colspan="4" id="payment-fee">

			<div class="ui relaxed divided list">
				{% for paymentFeeLabel, paymentFeeAmount in sylius_aggregate_adjustments(paymentFeeAdjustments) %}
					<div class="item">
						<div class="content">
							<span class="header">{{ paymentFeeLabel }}</span>
							<div class="description">
								{{ money.format(paymentFeeAmount, order.currencyCode) }}
							</div>
						</div>
					</div>
				{% endfor %}
			</div>

		</td>
		<td colspan="4" id="paymentFee-total" class="right aligned">
			<strong>{{ 'mango-sylius.ui.paymentFee_total'|trans }}</strong>:
			{{ money.format(order.getAdjustmentsTotal(paymentFeeAdjustment) ,order.currencyCode) }}
		</td>
	</tr>
{% endif %}

开发

使用

  • 从.env.dist创建到.env的符号链接或创建自己的.env文件
  • /src中开发您的插件
  • 查看bin/中的有用命令

测试

更改后,您必须确保测试仍然通过。

  • 简单的编码标准
    bin/ecs.sh
  • PHPStan
    bin/phpstan.sh

许可证

此库受MIT许可证的约束。

致谢

manGoweb开发。