-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Admin][Order] Add order notes #5319
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Sylius\Migrations; | ||
|
||
use Doctrine\DBAL\Migrations\AbstractMigration; | ||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
class Version20160622114217 extends AbstractMigration | ||
{ | ||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function up(Schema $schema) | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE sylius_order DROP additional_information, CHANGE notes notes VARCHAR(1000) DEFAULT NULL'); | ||
} | ||
|
||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function down(Schema $schema) | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE sylius_order ADD additional_information VARCHAR(1000) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE notes notes VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci'); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
features/order/placing_an_order/adding_notes_for_customer_service.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@placing_orders | ||
Feature: Adding a note to order | ||
In order to provide some extra information to order | ||
As a Customer | ||
I want to be able to provide a note for customer service | ||
|
||
Background: | ||
Given the store operates on a single channel in "France" | ||
And the store has a product "PHP T-Shirt" priced at "$19.99" | ||
And the store ships everywhere for free | ||
And the store allows paying offline | ||
And there is an administrator identified by "sylius@example.com" | ||
And there is a customer account "customer@example.com" identified by "sylius" | ||
And I am logged in as "customer@example.com" | ||
|
||
@ui | ||
Scenario: Adding note on the checkout summary step | ||
Given I have product "PHP T-Shirt" in the cart | ||
And I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "France" for "Jon Snow" | ||
And I proceed order with "Free" shipping method and "Offline" payment | ||
When I provide additional note like "Code to the front gateway is #44*" | ||
And I confirm my order | ||
Then the customer service should know about this additional note for this order made by "customer@example.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,24 +12,35 @@ | |
namespace Sylius\Behat\Context\Transform; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Sylius\Component\Core\Model\OrderInterface; | ||
use Sylius\Component\Core\Repository\OrderRepositoryInterface; | ||
use Sylius\Component\User\Repository\CustomerRepositoryInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
/** | ||
* @author Grzegorz Sadowski <grzegorz.sadowski@lakion.com> | ||
*/ | ||
final class OrderContext implements Context | ||
{ | ||
/** | ||
* @var CustomerRepositoryInterface | ||
*/ | ||
private $customerRepository; | ||
|
||
/** | ||
* @var OrderRepositoryInterface | ||
*/ | ||
private $orderRepository; | ||
|
||
/** | ||
* @param CustomerRepositoryInterface $customerRepository | ||
* @param OrderRepositoryInterface $orderRepository | ||
*/ | ||
public function __construct(OrderRepositoryInterface $orderRepository) | ||
{ | ||
public function __construct( | ||
CustomerRepositoryInterface $customerRepository, | ||
OrderRepositoryInterface $orderRepository | ||
) { | ||
$this->customerRepository = $customerRepository; | ||
$this->orderRepository = $orderRepository; | ||
} | ||
|
||
|
@@ -46,6 +57,20 @@ public function getOrderByNumber($orderNumber) | |
return $order; | ||
} | ||
|
||
/** | ||
* @Transform /^this order made by "([^"]+)"$/ | ||
*/ | ||
public function getOrderByCustomer($email) | ||
{ | ||
$customer = $this->customerRepository->findOneBy(['email' => $email]); | ||
Assert::notNull($customer, sprintf('Cannot find customer with email %s.', $email)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use this transformer then why we have https://github.com/Sylius/Sylius/pull/5319/files#r68388816? |
||
|
||
$orders = $this->orderRepository->findByCustomer($customer); | ||
Assert::notEmpty($orders); | ||
|
||
return end($orders); | ||
} | ||
|
||
/** | ||
* @Transform :orderNumber | ||
* @Transform /^an order "([^"]+)"$/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/Sylius/Bundle/AdminBundle/Resources/views/Order/Show/_notes.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% if order.notes is not null %} | ||
<h4 class="ui top attached styled header"> | ||
{{ 'sylius.ui.notes'|trans }} | ||
</h4> | ||
<div class="ui attached segment" id="sylius-order-notes"> | ||
{{ order.notes }} | ||
</div> | ||
{% endif %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing blank line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change customer service to administrator in shared storage and method name too.