Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,77 @@
📖 Full documentation is available here:
👉 [Refund Plugin Documentation](https://docs.sylius.com/refund-plugin)

## Customization

### Adding Custom Refund Types

If you need to add custom refund types (e.g., fees, commissions), you can extend the `RefundType` class:

1. **Create your custom RefundType class:**

```php
<?php

declare(strict_types=1);

namespace App\Model;

use Sylius\RefundPlugin\Model\RefundType as BaseRefundType;
use Sylius\RefundPlugin\Model\RefundTypeInterface;

class RefundType extends BaseRefundType implements RefundTypeInterface
{
public const ORDER_FEES = 'commission';

public static function commission(): self
{
return new self(self::ORDER_FEES);
}
}
```

2. **Create your custom Doctrine RefundEnumType:**

```php
<?php

declare(strict_types=1);

namespace App\Doctrine\Type;

use App\Model\RefundType;
use Sylius\RefundPlugin\Entity\Type\RefundEnumType as BaseRefundEnumType;
use Sylius\RefundPlugin\Model\RefundTypeInterface;

class RefundEnumType extends BaseRefundEnumType
{
protected function createType(string $value): RefundTypeInterface
{
return new RefundType($value);
}
}
```

3. **Configure your application to use the custom classes:**

```yaml
# config/packages/sylius_refund.yaml
imports:
- { resource: "@SyliusRefundPlugin/config/parameters.php" }

parameters:
sylius_refund.refund_type: App\Model\RefundType
sylius_refund.refund_enum_type: App\Doctrine\Type\RefundEnumType
```

4. **Clear the cache:**

```bash
php bin/console cache:clear
```

Now you can use your custom refund type in templates and business logic.

## 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.
Expand Down