Giter Club home page Giter Club logo

adminordercreationplugin's Introduction

Admin Order Creation Plugin

This plugin allows to create an order in admin panel.

Screenshot showing the order creation page, Shipments&Payments section

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! :)

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

  2. 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/
  3. Override repositories

    1. Create repository classes
      mkdir src/Repository
      touch src/Repository/CustomerRepository.php
      touch src/Repository/ProductVariantRepository.php
    2. 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;
      }
    3. 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;
      }
    4. 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

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 [email protected].

adminordercreationplugin's People

Contributors

zales0123 avatar gsadee avatar bartoszpietrzak1994 avatar pamil avatar roshyo avatar mamazu avatar pierre-h avatar lchrusciel avatar themilek avatar igormukhingmailcom avatar maciekpaprocki avatar konafets avatar jacquesbh avatar arminek avatar adamkasp avatar clem21 avatar herveemagma avatar pogorivan avatar kayue avatar coldic3 avatar dunglas avatar codermaggie avatar peterukena 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.