# This file is a part of the Sylius package.
# (c) Sylius Sp. z o.o.

sylius_shop_ajax_cart_add_item:
    path: /add
    methods: [POST]
    defaults:
        _controller: sylius.controller.order_item::addAction
        _format: json
        _sylius:
            factory:
                method: createForProduct
                arguments: [expr:notFoundOnNull(service('sylius.repository.product').find($productId))]
            form:
                type: Sylius\Bundle\CoreBundle\Form\Type\Order\AddToCartType
                options:
                    product: expr:notFoundOnNull(service('sylius.repository.product').find($productId))
            redirect:
                route: sylius_shop_cart_summary
                parameters: {}
            flash: sylius.cart.add_item

sylius_shop_ajax_cart_item_remove:
    path: /{id}/remove
    methods: [DELETE]
    defaults:
        _controller: sylius.controller.order_item::removeAction
        _format: json
        _sylius:
            flash: sylius.cart.remove_item
