Documentation » Ecommerce

Order »

« Basket



The SonataDeliveryBundle allows you to handle the various Delivery methods for your product. A basic free delivery method is offered to you, but you can add your own as you see fit.

There, you’re able to define several services, such as the Delivery pool (regrouping all services tagged and the Delivery methods:

  • The delivery pool regroups the various delivery methods.
  • The delivery selector selects the appropriate delivery method(s) for a given product.


You can override the Delivery selector and pool classes through the following parameters:



In order to use a different selector, yours should override the default one (Sonata\Component\Delivery\Selector). If you just want to implement a brand new class based on Sonata\Component\Delivery\ServiceDeliverySelectorInterface, you will also have register it as a new service and reference it into your application configuration (see selector node below).

Default configuration:


    # This allows you to configure provided delivery methods
            name:                 free_address_required
            code:                 free_address_required
            priority:             10
            name:                 free_address_not_required
            code:                 free_address_not_required
            priority:             10

    # Here you will enable the delivery methods you wish to provide
    # and add your custom ones
        free_address_required: ~     # This is a provided method, we don't need to specify its service id
        take_away:    # Custom delivery method, we specify the service id

Add a custom delivery method

In order to add a custom delivery methods, here are the steps to follow:

  1. Create your own delivery method class:

    namespace App\Delivery;
    use Sonata\Component\Delivery\BaseServiceDelivery;
    class TakeAwayDelivery extends BaseServiceDelivery
        public function isAddressRequired()
            return false;
        public function getCode()
            return 'take_away';
  2. Declare the service associated (don’t forget the tag):

<service id="" class="App\Delivery\TakeAwayDelivery">
    <tag name=""/>
  1. Add it to your configuration:
    # ...

        # ...
  1. That’s it! The new method is configured (you’ll have to add it to your products though).

Found a typo? Something is wrong in this documentation? Just fork and edit it!