Files
kupshop/class/deliveries/class.ZasilkovnaDodaniNaAdresu.php
2025-08-02 16:30:27 +02:00

40 lines
1.4 KiB
PHP

<?php
use KupShop\OrderingBundle\Exception\DeliveryException;
class ZasilkovnaDodaniNaAdresu extends Delivery
{
public static $className = 'Zásilkovna - Dodání na adresu';
protected $track_and_trace = 'https://www.zasilkovna.cz/vyhledavani/[PACKAGE_ID]';
protected $heureka_delivery_id = 'ZASILKOVNA_NA_ADRESU';
protected $zbozi_delivery_id = 'ZASILKOVNA_NA_ADRESU';
public $defaultIcon = '../../common/static/deliveries/zasilkovna.svg';
public function check(Cart $cart)
{
if ($cart->hasData('user') && $cart->addressesSet && !empty($cart->invoice['zip'])) {
// Check ZIP exists
$country = $cart->invoice['country'];
if ($country == 'CZ' || $country == 'SK') {
$zip = $cart->invoice['zip'];
$zipRow = sqlQueryBuilder()
->select('*')
->from('kupshop_shared.delivery_zip_codes')
->where('country=:country AND zip=:zip')
->setParameters(['country' => $country, 'zip' => $zip])
->setMaxResults(1)
->execute()
->fetch();
if (!$zipRow && $cart->hasData('delivery')) {
throw new DeliveryException(translate('false_zip', 'order_error'));
}
}
}
return parent::check($cart);
}
}