gewebe / sylius-product-deposit-plugin
A Sylius plugin that allows products with deposit price
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:sylius-plugin
Requires
- php: ^7.3
- sylius/sylius: ^1.8
Requires (Dev)
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.4
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- lakion/mink-debug-extension: ^2.0.0
- phpspec/phpspec: ^7.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: 0.12.25
- phpstan/phpstan-doctrine: 0.12.13
- phpstan/phpstan-strict-rules: ^0.12.0
- phpstan/phpstan-webmozart-assert: 0.12.4
- phpunit/phpunit: ^9.5
- sensiolabs/security-checker: ^6.0
- sylius-labs/coding-standard: ^3.1
- symfony/browser-kit: ^4.4
- symfony/debug-bundle: ^4.4|^5.0
- symfony/dotenv: ^4.4|^5.0
- symfony/intl: ^4.4|^5.0
- symfony/web-profiler-bundle: ^4.4|^5.0
- symfony/web-server-bundle: ^4.4|^5.0
- vimeo/psalm: 4.3.1
This package is auto-updated.
Last update: 2021-02-13 17:15:59 UTC
README
The product deposit plugin in Sylius allows you to set an amount of refundable deposit price for any product. For example: deposit for bottles, cans, pallets, batteries or car replacement parts.
Features
- Store individual deposit prices for each product variant and channel
- The deposit price is displayed on the product detail page
- At shopping cart / checkout / order the total unit price inclusive deposit is displayed.
Installation
Download the plugin via composer
composer require gewebe/sylius-product-deposit-plugin
Enable the plugin
Register the plugin by adding it to your config/bundles.php
file
<?php return [ // ... Gewebe\SyliusProductDepositPlugin\GewebeSyliusProductDepositPlugin::class => ['all' => true], ];
Configure the plugin
# config/packages/gewebe_sylius_product_deposit.yaml imports: - { resource: '@GewebeSyliusProductDepositPlugin/Resources/config/app/config.yml'}
Extend ProductVariant
entity
- If you use
annotations
mapping:
# src/Entity/Product/ProductVariant.php namespace App\Entity\Product; use Doctrine\ORM\Mapping as ORM; use Gewebe\SyliusProductDepositPlugin\Entity\ProductVariantInterface as ProductVariantDepositInterface; use Gewebe\SyliusProductDepositPlugin\Entity\ProductVariantDepositTrait; use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant; /** * @ORM\Entity * @ORM\Table(name="sylius_product_variant") */ class ProductVariant extends BaseProductVariant implements ProductVariantDepositInterface { use ProductVariantDepositTrait; public function __construct() { parent::__construct(); $this->initProductVariantDepositTrait(); } // ... }
- If you use
yaml
mapping add also:
App\Entity\Product\ProductVariant: type: entity table: sylius_product_variant manyToOne: depositTaxCategory: targetEntity: Sylius\Component\Taxation\Model\TaxCategoryInterface joinColumn: name: deposit_tax_category_id referencedColumnName: id onDelete: SET NULL oneToMany: channelDeposits: targetEntity: Gewebe\SyliusProductDepositPlugin\Entity\ChannelDepositInterface mappedBy: productVariant orphanRemoval: true indexBy: channelCode cascade: - all
Update your database schema
bin/console doctrine:migrations:diff bin/console doctrine:migrations:migrate
Usage
1. Add a deposit price to a product variant
2. Browse a product variant with deposit price
3. Buy a product with deposit price included in final product price
Testing
Setup
$ composer install $ cd tests/Application $ yarn install $ yarn run gulp $ bin/console assets:install public -e test $ bin/console doctrine:schema:create -e test $ bin/console server:run 127.0.0.1:8080 -d public -e test
Run Tests
$ vendor/bin/behat $ vendor/bin/phpspec run $ vendor/bin/phpstan analyse -c phpstan.neon -l max src/