Elcodi\Store\CartBundle\EventListener\ShippingApplianceEventListener::removeInvalidShippingMethod PHP Метод

removeInvalidShippingMethod() публичный Метод

Remove shipping method from cart if this is not valid anymore
public removeInvalidShippingMethod ( Elcodi\Component\Cart\Event\CartOnLoadEvent $event )
$event Elcodi\Component\Cart\Event\CartOnLoadEvent Event
    public function removeInvalidShippingMethod(CartOnLoadEvent $event)
    {
        $cart = $event->getCart();
        $cartShippingMethodId = $cart->getShippingMethod();
        if (null === $cartShippingMethodId) {
            return $this;
        }
        $shippingMethod = $this->shippingWrapper->getOneById($cart, $cartShippingMethodId);
        if (!$shippingMethod instanceof ShippingMethod) {
            $cart->setShippingMethod(null);
            $this->cartEventDispatcher->dispatchCartLoadEvents($cart);
            $event->stopPropagation();
        }
        return $this;
    }