sylius / admin-order-creation-plugin
Sylius Plugin for order creation in Admin panel
Installs: 542 202
Dependents: 4
Suggesters: 0
Security: 0
Stars: 55
Watchers: 14
Forks: 50
Open Issues: 36
Type:sylius-plugin
Requires
- php: ^8.1
- friendsofsymfony/jsrouting-bundle: ^3.2
- sylius/sylius: ~1.12.0 || ~1.13.0
Requires (Dev)
- behat/behat: ^3.6
- behat/mink-selenium2-driver: ^1.4
- dbrekelmans/bdi: ^1.1
- 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-debug-extension: ^2.0
- friends-of-behat/mink-extension: ^2.5
- 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
- phpspec/phpspec: ^7.2
- phpstan/phpstan: ^1.8
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^10.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- robertfausk/behat-panther-extension: ^1.1
- sylius-labs/coding-standard: ^4.2
- sylius-labs/suite-tags-extension: ^0.2
- symfony/debug-bundle: ^5.4 || ^6.4
- symfony/dotenv: ^5.4 || ^6.4
- symfony/runtime: ^5.4 || ^6.4
- symfony/web-profiler-bundle: ^5.4 || ^6.4
README
Admin Order Creation Plugin
This plugin allows to create an order in admin panel.
Business value
So far it was up to the Customer to place an order using available product variants as well as payment and shipping methods.
The whole process of placing an order is not that obvious, however. For some reason a Customer may feel a little bit confused when a promotion is no longer available or shipping method is not eligible for given area. Here comes Admin Order Creation Plugin.
Briefly speaking, it allows an Administrator to place or reorder an order in the name of a Customer. It helps them solve even more of Customers' fundamental problems and equips an Administrator with basic tools making creating an order possible.
Admin Order Creation Plugin processes are strongly based on standard Order model taken from SyliusCoreBundle. The only things that differ are order creation context and business requirements. Right now it is up to the Administrator to provide a channel, locale and currency in which an Order is created. What's more, the Administrator is able to add a discount for any item or the whole Order, which is, technically speaking, a new type of Sylius Adjustments.
After creating an Order via Admin panel, this new Order is listed like any other order placed via Sylius.
Installation
Beware!
This installation instruction assumes that you're using Symfony Flex. If you don't, take a look at the legacy installation instruction. However, we strongly encourage you to use Symfony Flex, it's much quicker! :)
-
Require plugin with composer:
composer require sylius/admin-order-creation-plugin
Remember to allow community recipes with
composer config extra.symfony.allow-contrib true
or during plugin installation process -
Copy Sylius templates overridden in plugin to your templates directory (e.g
templates/bundles/
):mkdir -p templates/bundles/SyliusAdminBundle/ cp -R vendor/sylius/admin-order-creation-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/
-
Override repositories
- Create repository classes
mkdir src/Repository touch src/Repository/CustomerRepository.php touch src/Repository/ProductVariantRepository.php
- Paste the following content to the
src/Repository/CustomerRepository.php
:<?php declare(strict_types=1); namespace App\Repository; use Sylius\AdminOrderCreationPlugin\Doctrine\ORM\CustomerRepositoryInterface; use Sylius\AdminOrderCreationPlugin\Doctrine\ORM\CustomerRepositoryTrait; use Sylius\Bundle\CoreBundle\Doctrine\ORM\CustomerRepository as BaseCustomerRepository; final class CustomerRepository extends BaseCustomerRepository implements CustomerRepositoryInterface { use CustomerRepositoryTrait; }
- Paste the following content to the
src/Repository/ProductVariantRepository.php
:<?php declare(strict_types=1); namespace App\Repository; use Sylius\AdminOrderCreationPlugin\Doctrine\ORM\ProductVariantRepositoryInterface; use Sylius\AdminOrderCreationPlugin\Doctrine\ORM\ProductVariantRepositoryTrait; use Sylius\Bundle\CoreBundle\Doctrine\ORM\ProductVariantRepository as BaseProductVariantRepository; final class ProductVariantRepository extends BaseProductVariantRepository implements ProductVariantRepositoryInterface { use ProductVariantRepositoryTrait; }
- Configure repositories in
config/packages/_sylius.yaml
:
sylius_customer: resources: customer: classes: model: App\Entity\Customer\Customer + repository: App\Repository\CustomerRepository sylius_product: resources: product_variant: classes: model: App\Entity\Product\ProductVariant + repository: App\Repository\ProductVariantRepository
- Create repository classes
Extension points
Admin Order Creation Plugin makes it possible to add custom discount during order creation - thus some of Order
Show templates need to be replaced with those placed in Resources/views
package.
Payment link generation and sending process is based on logic placed in the PaymentLinkCreationListener class. Thus, it can be easily replaced with suitable implementation.
Adjustments set is not closed and strictly defined - adding custom adjustment means defining a new constant in the AdjustmentType class.
Significant part of Reorder Processing is inspired by official Sylius
Customer Reorder Plugin. In case of the need for more processors,
just add new class implementing ReorderProcessor
interface, declare it in reorder_processing.xml
file and match
it with a proper tag.
Admin Order Creation process is based on Symfony Forms. To find out more about Symfony Forms extension possibilities, check out Symfony Docs.
Security issues
If you think that you have found a security issue, please do not use the issue tracker and do not post it publicly.
Instead, all security issues must be sent to security@sylius.com
.