Events
Sonata e-commerce provides events through Symfony2’s EventDispatcher to allow you to further customize your business logic.
Basket
| final class BasketEvents
{
const PRE_ADD_PRODUCT = 'sonata.ecommerce.basket.pre_add_product'; // AddBasketElementEvent
const POST_ADD_PRODUCT = 'sonata.ecommerce.basket.post_add_product'; // AddBasketElementEvent
const PRE_MERGE_PRODUCT = 'sonata.ecommerce.basket.pre_merge_product'; // AddBasketElementEvent
const POST_MERGE_PRODUCT = 'sonata.ecommerce.basket.post_merge_product'; // AddBasketElementEvent
const PRE_CALCULATE_PRICE = 'sonata.ecommerce.basket.pre_calculate_price'; // BeforeCalculatePriceEvent
const POST_CALCULATE_PRICE = 'sonata.ecommerce.basket.post_calculate_price'; // AfterCalculatePriceEvent
}
|
Payment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 | final class PaymentEvents
{
// Fires only PaymentEvent instances
const PRE_ERROR = "sonata.ecommerce.payment.pre_error";
// Sent just before adding the order to the message queue
const POST_ERROR = "sonata.ecommerce.payment.post_error";
const CONFIRMATION = "sonata.ecommerce.payment.confirmation";
const PRE_CALLBACK = "sonata.ecommerce.payment.pre_callback";
// Sent just before adding the order to the message queue
const POST_CALLBACK = "sonata.ecommerce.payment.post_callback";
const PRE_SENDBANK = "sonata.ecommerce.payment.pre_sendbank";
const POST_SENDBANK = "sonata.ecommerce.payment.post_sendbank";
}
|
Order
We were planning on adding events on order creation/alteration/deletion and status change; however the most effective way is to listen to events fired by the doctrine ORM layer. See How to Register Event Listeners and Subscribers on the Symfony documentation to do so.