Giter Site home page Giter Site logo

sylius / adminordercreationplugin Goto Github PK

View Code? Open in Web Editor NEW
56.0 16.0 50.0 813 KB

Create orders in Sylius as an Administrator

License: MIT License

PHP 63.36% JavaScript 2.54% Gherkin 16.15% Twig 17.94%
sylius php symfony ecommerce sylius-plugin hacktoberfest

adminordercreationplugin's Introduction

Sylius is an Open Source eCommerce framework on top of Symfony.

The highest quality of code, strong testing culture, built-in Agile (BDD) workflow and exceptional flexibility make it the best solution for applications tailored to your business requirements. Powerful REST API allows for easy integrations and creating unique customer experience on any device.

We're using full-stack Behavior-Driven-Development, with phpspec and Behat.

Enjoy being an eCommerce Developer again!

⚙️ Installation

Install Sylius with Composer (see requirements details).

Follow the Getting started with Sylius tutorial!

📖 Documentation

Documentation is available at docs.sylius.com.

➕ Sylius Plus

Sylius Plus offers modular features like OnePageCheckout and a B2B suite, alongside advanced capabilities such as multi-store management, partial order fulfillment, smooth returns handling, a loyalty system and multi-source inventory. Pick and choose the modules you need to supercharge your eCommerce projects effortlessly.

🤝 Community

Get Sylius support on Slack or Stack Overflow or get professional SLA-backed support and Project Success Assistance with Sylius Plus license! Learn more.

Stay updated by following our Twitter and Facebook.

Would like to help us and build the most developer-friendly eCommerce framework? Start from reading our Contributing Guide!

👮 Security issues

If you think that you have found a security issue in Sylius, please do not use the issue tracker and do not post it publicly. Instead, all security issues must be sent to [email protected].

📦 Plugins and Extensions: Sylius Store

You can find Sylius plugins on our Sylius Store which is a Marketplace with Sylius extensions.

Or search for packages marked as sylius-plugin on Packagist.

📃 License

Sylius is completely free and released under the MIT License.

✍️ Authors

Sylius was originally created by Paweł Jędrzejewski.

Kudos to all Sylius contributors 🙏

... and others!

See the full list of contributors from our awesome community.

adminordercreationplugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adminordercreationplugin's Issues

Transition "select_shipping" cannot be applied on state "shipping_skipped" of object "App\Entity\Order\Order" with graph "sylius_order_checkout"

When I create an order from admin, I have this error :

Transition "select_shipping" cannot be applied on state "shipping_skipped" of object "App\Entity\Order\Order" with graph "sylius_order_checkout"

I create an order with product without shipping (virtual products).
I think this is why I have this exception, I don't need shipping for this order and something in the code try to select it.

Here is the stacktrace :

SM\SMException:
Transition "select_shipping" cannot be applied on state "shipping_skipped" of object "App\Entity\Order\Order" with graph "sylius_order_checkout"

  at vendor/winzou/state-machine/src/SM/StateMachine/StateMachine.php:122
  at SM\StateMachine\StateMachine->apply('select_shipping')
     (vendor/sylius/admin-order-creation-plugin/src/EventListener/OrderCreationListener.php:44)
  at Sylius\AdminOrderCreationPlugin\EventListener\OrderCreationListener->completeOrderBeforeCreation(object(ResourceControllerEvent), 'sylius.order.pre_admin_create', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ResourceControllerEvent), 'sylius.order.pre_admin_create', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:212)
  at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener)), 'sylius.order.pre_admin_create', object(ResourceControllerEvent))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:44)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('sylius.order.pre_admin_create', object(ResourceControllerEvent))
     (vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:145)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch('sylius.order.pre_admin_create', object(ResourceControllerEvent))
     (vendor/sylius/resource-bundle/src/Bundle/Controller/EventDispatcher.php:76)
  at Sylius\Bundle\ResourceBundle\Controller\EventDispatcher->dispatchPreEvent('admin_create', object(RequestConfiguration), object(Order))
     (vendor/sylius/resource-bundle/src/Bundle/Controller/ResourceController.php:191)
  at Sylius\Bundle\ResourceBundle\Controller\ResourceController->createAction(object(Request))
     (vendor/symfony/http-kernel/HttpKernel.php:150)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:67)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:198)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:25)

Validate item and order discount inputs

Steps to reproduce

  1. Create new order in Admin panel
  2. Add item discount greater than item's total
  3. Greater amount is accepted

screen shot 2018-09-19 at 09 52 27

  1. Create new order in Admin panel
  2. Add order discount greater than order's total
  3. 500 error

Endless spinner on setting the shipment

Problem:
Order item validation is kicked off when the available shipments are loaded. Then the request runs into a validation issue and throws an error which breaks the request and the spinner keeps loading.

Steps to reproduce:

  • Create an order with the plugin where you add one item with an amount greater than what you have in stock
  • Fill in the Shipping and billing information
  • Add a shipment (loads)

Address selection/creation not required

Apparently its not a required form component to fill out the address of a created order. If you dont do it, it redirects you to the preview page and crashes with an error "return value must be of type string, null returned" in Sylius\Bundle\AddressingBundle\Twig\CountryNameExtension due to the template trying to render the uninitiated address.

The migrations doesn't make sense

Am I missing something or does the two migration files leave the database unchanged?

The first one adds to fields and the second one removes them?

If that's the case, why not remove these files? :)

Move admin as a prefix out of the plugin

Move route name admin as a prefix out of the plugin.

The way it's done in AdminBundle

sylius_admin:
    resource: "@SyliusAdminBundle/Resources/config/routing.yml"
    prefix: /admin

The way it's done in the plugin
now:

sylius_admin_order_creation:
    resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing.yml"

change to:

sylius_admin_order_creation:
    resource: "@SyliusAdminOrderCreationPlugin/Resources/config/app/routing.yml"
    prefix: /admin

and remove admin from SyliusAdminOrderCreationPlugin/Resources/config/app/routing.yml

if it's okay I can commit changes

The payments contraint breaks the cart

vendor/sylius/admin-order-creation-plugin/src/Resources/config/validation.xml has a declaration of min/max count of 1 payment in the Order resource. That being said, at the cart stage where there are no payments at all it throws the Violation error and breaks the cart usability. Screenshot:

Screenshot 2019-06-12 at 22 19 09

Migration error

After I copied the migration files, I issued the command bin/console doctrine:migrations:migrate which led me to the following error:

[Doctrine\DBAL\Migrations\MigrationException]
  Migration class "DoctrineMigrations\Version20180626065141" was not found. Is it placed in "DoctrineMigrations" namespace?

I had to change the namespace of the migration files from Sylius\Migrations; -> DoctrineMigrations;.

Not sure if this is a documentation or a code issue.

Useless migration

If you check and compare 2 migration files which you copy and run in your project you will notice that one cancels another:
Version20180626065141.php
Version20180709120541.php

So up method in first migration creates fields, and up in another field deletes fields. In the end 2 migrations dont do any change. So they could be deleted? Or there is some error in one of them?

Unknown locale filter

in vendor/sylius/admin-order-creation-plugin/src/Resources/views/Order/preview.html.twig:31
{{ flags.fromLocaleCode(order.localeCode) }}{{ order.localeCode|locale }}
there is an error when creating an order (on order preview page /admin/orders/new/24/DE_SHOP/preview)

Text of the error: Uncaught PHP Exception Twig\Error\SyntaxError: "Unknown "locale" filter. Did you mean "locale_name", "sylius_locale_name", "sylius_locale_country"?" at /srv/sylius/vendor/sylius/admin-order-creation-plugin/src/Resources/views/Order/preview.html.twig line 31

Infinite loading circle when country does not have a shipping method

The problem occurs when selecting a country with no shipping method possible.

Steps to reproduce:

  • Create a country (zone) with no shipments defined.
  • Create a new order
  • Select the created country in the shipping address
  • When trying to add a shipment the loader tries to load but gets a 500

The problem could be fixed by checking if the shipment is null:

public function __invoke(Request $request): Response
{
    $order = $this->orderPreparator->prepareFromRequest($request);
    $shipment = $order->getShipments()->get((int) $request->attributes->get('shipmentNumber'));
    $availableShippingMethods = [];
    if ($shippment !== null) {
        $availableShippingMethods = $this->availableShippingMethodsListProvider->__invoke($shipment);
    }
    return new JsonResponse($availableShippingMethods);
}

in

$shipment = $order->getShipments()->get((int) $request->attributes->get('shipmentNumber'));

Extract repository methods to traits

If you extract the concrete methods in the repositories to traits it would be easier to use the plugin, i.e. you could just use the trait and implement the interface and you would be good to go. Now you have to copy the method manually.

Missing discount amount

After adding discount per item, discount isn't filled. But total looks correct.

Added 22.00$ Discount:
untitled

plugin installation issue

help me for installation plugin i did try php 7.0 with sylius so i can use all plugins installation
i am getting error at 7.0 php version incompatibility

anyone can help me or suggestion me ? i would like to install all plugins and library with sylius

as 7.0 result here

/opt/rh/rh-php70/root/bin/php -d memory_limit=-1 /usr/bin/composer require sylius/admin-order-creation-plugin

[InvalidArgumentException]
Package sylius/admin-order-creation-plugin at version has a PHP requirement incompatible with your PHP version (7.0.27)

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] []...

Customer Reorder Integration

Steps to reproduce:

  • Create a customer
  • Create an order with discounts on the order or the order items
  • Try to reorder this order and the order does not have the discount applied.

I don't know if that is expected behavior.

Routes not existing

Hi,

I'm using Sylius v1.7.4 on Symfony 4.48. The installation worked well but when i'm trying to create a new customer or a new order for a customer i got the following errors :

Uncaught Error: The route "sylius_admin_order_creation_customer_create" does not exist.
Uncaught Error: The route "sylius_admin_order_creation_order_create" does not exist

Could you help me with that ? I'm going crazy!!

Thx

[FEATURE] Allow Doctrine\ORM\*Repository to be embeddable

I don't know if it the right word to use here : "embeddable" but if we have several plugins or src/Repository/* classes we can have some troubles.
So we are force to decorate the service or to copy/paste the repository methods.

Is there any other way to make this to work, if for exemple we have another ProductVariantRepository ?

Missing form error messages

In the order creation form there is no check for quantities of products. So when creating the order and getting to the review step, there is a form validation error saying not enough quantity in stock. However, this only shows up in the debug toolbar. And the fact that the price of the product is 0.

Steps to reproduce:

  • Create a product in a low quantity
  • Create an order in the admin panel with this product
  • Set the quantity higher than it is available for.
  • Submit the form
  • When reviewing the created order and clicking confirm nothing happens because the form validation error is not shown

Error when searching customer

As I want create an order for a customer, I start typing the email address but got the error

{
    code: 500,
    message: "Notice: Undefined index: customer"
}

Proper Order fields values

We need to validate following properties while creating order in Admin panel:

  1. Shipping method - select with available shipping methods should display only shipping methods that are eligible for creating order (should be probably reloaded after each significant order change, like adding a product or changing shipping address)
  2. Payment method - pretty much the same as 1.
  3. Items
    3.1. Validate if there is at least one item
    3.2. Merge order items if there are few of them added with the same variant
  4. Customer
    4.1. Validate if new Customer email is an email
    4.2. Validate if new Customer email is already used (now it just uses an existing customer)

Related with #7

State machine error on order creation

When creating an order on Sylius 1.7.4 an error is made by Winzou State machine:

Transition "select_payment" cannot be applied on state "payment_skipped" of object "App\Entity\Order\Order" with graph "sylius_order_checkout"

This occurs when the channel flag skipping_shipping_step_allowed or skipping_payment_step_allowed are enabled and only one payment/shipping provider is available.

Order creation refactoring

Not saving order during creation and before preview does more harm than good. During the current changing of custom discounts functionality, it's a real nightmare.
My idea is to refactor it this way:

  1. Provide new state for order in_creation (or sth similar), that would be an equivalent of cart state in Admin panel
  2. Save order with this state immediately after the first step of creation (before preview)
  3. Applying discount on preview page could be done with some custom actions (with commands and everything that is beautiful)
  4. After pressing Cancel button order would be removed from database (we have the ID, as it's already saved)
  5. If Admin would abandon order we could have a command clear_abandoned_admin_order (we have something similar for customer orders)
    5*. In the future, we could even listen to the event of leaving a page and display a modal

Possible features about plugin [ROADMAP]

Hello, today I tried this plugin, and I want to congratulate, I see this plugin very interesting.

But I have some suggestions to share with community.. If some feature is interesting we can create an issue specific

  1. Create an order for a specific user

Now when you visit a customer and click in create an order, we navigate to main page of plugin, and we must select the customer into list ALL customers.... It is very inneficient.... with a list big, the select is very lazy.
And now I cannot write the email directly.

It create the second point.

  1. To have a Select with all customers, in a big ecommerce it is crazy...

I think this pull request can help to this problem
Sylius/Sylius#8778

Maybe the select would to be an autocomplete, and write three characteres by example... or to have possibility to write the customer`s email directly.

  1. Discount 100%
    If you create a order with discount of 100%, ie the value order equals zero... I get the error...

What do you think about these things?

[Reorder] Todo scenarios

Some scenarios are disabled after changing logic associated with adjustment:

  • reordering_placed_order_with_modified_total_price.feature
  • reordering_placed_order_with_modified_unit_price.feature

Should use ApiPlatform's CustomerProvider

I noticed AdminOrderCreationPlugin has its own CustomerProvider

public function provideNewCustomer(string $email): CustomerInterface
{
/** @var CustomerInterface $customer */
$customer = $this->customerFactory->createNew();
$customer->setEmail($email);
$this->customerRepository->add($customer);
return $customer;
}

It should use the one from \Sylius\Bundle\ApiBundle\Provider\CustomerProviderInterface so that it can support Sylius Plus properly.

Validation Order Payments

The validation to check if there is only one payment should have another group to avoid blocking checkout validation in shop if there is multiple payments

<class name="Sylius\Component\Core\Model\Order"> <property name="payments"> <constraint name="Count"> <option name="min">1</option> <option name="max">1</option> <option name="groups">sylius_admin_order</option> </constraint> </property> </class>

Filter products that are sufficiently stocked

In the product selection it should not show products that have no stock to ship, as it will cause problems in the next step. Alternatively you could also add some kind of visual indicator of it being sold out.

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.