Coder Social home page Coder Social logo

keeper7 / syliuspaymentfeeplugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mangoweb-sylius/syliuspaymentfeeplugin

0.0 2.0 0.0 54 KB

Payment Fee Plugin adds possibility to charge the customer for specific payment method e.g. Cash on Delivery.

Shell 1.43% PHP 89.58% JavaScript 5.90% Twig 3.09%

syliuspaymentfeeplugin's Introduction

Payment Fee Plugin

Features

  • Charge extra fee for using payment method.
  • Typical usage: Cash on Delivery.
  • Taxes are implemented the same way as taxes for shipping fees.

Installation

  1. Run $ composer require mangoweb-sylius/sylius-payment-fee-plugin.
  2. Register \MangoSylius\PaymentFeePlugin\MangoSyliusPaymentFeePlugin in your Kernel.
  3. Your Entity PaymentMethod has to implement \MangoSylius\PaymentFeePlugin\Model\PaymentMethodWithFeeInterface. You can use Trait MangoSylius\PaymentFeePlugin\Model\PaymentMethodWithFeeTrait.

For guide how to use your own entity see Sylius docs - Customizing Models

Admin

  1. Add this to @SyliusAdmin/PaymentMethod/_form.html.twig template.
<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. Add this to 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 %}

Development

Usage

  • Create symlink from .env.dist to .env or create your own .env file
  • Develop your plugin in /src
  • See bin/ for useful commands

Testing

After your changes you must ensure that the tests are still passing.

  • Easy Coding Standard
    bin/ecs.sh
  • PHPStan
    bin/phpstan.sh

License

This library is under the MIT license.

Credits

Developed by manGoweb.

syliuspaymentfeeplugin's People

Contributors

ondrej-kuhnel avatar honzamatosik avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.