How to add a custom shipping method rule?
Example Use Case
1. Create a New Shipping Method Rule Checker
<?php
// src/Shipping/Checker/Rule/TotalVolumeLessThanOrEqualRuleChecker.php
namespace App\Shipping\Checker\Rule;
use Sylius\Component\Shipping\Checker\Rule\RuleCheckerInterface;
use Sylius\Component\Shipping\Model\ShippingSubjectInterface;
final class TotalVolumeLessThanOrEqualRuleChecker implements RuleCheckerInterface
{
public const TYPE = 'total_volume_less_than_or_equal';
public function isEligible(ShippingSubjectInterface $shippingSubject, array $configuration): bool
{
return $shippingSubject->getShippingVolume() <= $configuration['volume'];
}
}2. Prepare a Configuration Form Type for Your New Rule
3. Register the Rule Checker as a Service
4. Add Translations
5. Configure the Product Variant to Not Meet the Requirements

6. Configure the Shipping Method with a Maximum Volume

✅ Result

Last updated
Was this helpful?
