<?php

use KupShop\OrderingBundle\Exception\PaymentException;

class Dobirka extends Payment
{
    public static $name = 'Platba na dobírku';
    protected ?string $defaultIcon = '../../common/static/payments/dobirka.svg';

    public $class = 'Dobirka';

    public $method;

    protected $pay_method = Payment::METHOD_COD;

    public function requiresEET()
    {
        return false;
    }

    /**
     * @param $cart \Cart
     */
    public function check(CartBase $cart)
    {
        if ($cart->hasVirtualProducts()) {
            $this->exception = new PaymentException(translate_shop('errorDobirkaVirtualProducts', 'payment'), translate_shop('errorDobirkaVirtualProducts_short', 'payment'));
        }

        if (!empty($this->exception) && $cart->max_step != 0) {
            throw $this->exception;
        }

        return parent::check($cart);
    }
}
