Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Jun 28, 2024
1 parent 1a52190 commit 3cdbf9a
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,64 @@ Edit orders inside your admin interface.
composer require setono/sylius-order-edit-plugin
```

### Import routing

```yaml
# config/routes/setono_sylius_order_edit.yaml
setono_sylius_order_edit:
resource: "@SetonoSyliusOrderEditPlugin/Resources/config/routes.yaml"
```
### Extend the `Order` entity

```php
<?php
declare(strict_types=1);
namespace App\Entity\Order;
use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusOrderEditPlugin\Entity\EditableOrderInterface;
use Setono\SyliusOrderEditPlugin\Entity\EditableOrderTrait;
use Sylius\Component\Core\Model\Order as BaseOrder;
#[ORM\Entity]
#[ORM\Table(name: 'sylius_order')]
class Order extends BaseOrder implements EditableOrderInterface
{
use EditableOrderTrait;
}
```

### Update your database schema

```shell
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
```

The plugin adds a new field to the `Order` entity named `initialTotal` which will contain the order total and is used when editing orders.

To set the `initialTotal` field for existing orders, you can add the following to your migration:

```php
<?php
// ...
public function up(Schema $schema): void
{
// ...
$this->addSql('UPDATE sylius_order SET initial_total = total');
}
// ...
```

### Done!

You should be able to edit orders in your admin interface. Enjoy :tada:

[ico-version]: https://poser.pugx.org/setono/sylius-order-edit-plugin/v/stable
[ico-license]: https://poser.pugx.org/setono/sylius-order-edit-plugin/license
[ico-github-actions]: https://github.com/Setono/sylius-order-edit-plugin/workflows/build/badge.svg
Expand Down

0 comments on commit 3cdbf9a

Please sign in to comment.