first commit
This commit is contained in:
75
class/deliveries/class.GLS.php
Normal file
75
class/deliveries/class.GLS.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
use KupShop\KupShopBundle\Util\Delivery\RestrictionParams;
|
||||
use KupShop\OrderingBundle\Entity\Purchase\PurchaseState;
|
||||
|
||||
class GLS extends Delivery
|
||||
{
|
||||
public static $className = 'GLS';
|
||||
|
||||
protected $heureka_delivery_id = 'GLS';
|
||||
protected $zbozi_delivery_id = 'GLS';
|
||||
|
||||
protected $track_and_trace = [
|
||||
'CZ' => 'https://gls-group.eu/CZ/cs/sledovani-zasilek?match=[PACKAGE_ID]',
|
||||
'DE' => 'https://www.gls-pakete.de/sendungsverfolgung?match=[PACKAGE_ID]',
|
||||
'HR' => 'https://gls-group.eu/HR/hr/pracenje-paketa/?match=[PACKAGE_ID]',
|
||||
'SI' => 'https://gls-group.eu/SI/sl/sledenje-posiljki?match=[PACKAGE_ID]',
|
||||
'RO' => 'https://gls-group.eu/RO/ro/urmarire-colet.html?match=[PACKAGE_ID]',
|
||||
'SK' => 'https://gls-group.eu/SK/sk/sledovanie-zasielok.html?match=[PACKAGE_ID]',
|
||||
'PL' => 'https://gls-group.com/PL/pl/sledzenie-paczek.html?match=[PACKAGE_ID]',
|
||||
'ES' => 'https://www.gls-spain.es/es/recibir-paquetes/seguimiento-envio/?match=[PACKAGE_ID]&international=1',
|
||||
'DK' => 'https://gls-group.eu/DK/da/find-pakke.html?match=[PACKAGE_ID]',
|
||||
'FI' => 'https://gls-group.eu/FI/fi/laehetysseuranta.html?match=[PACKAGE_ID]',
|
||||
'FR' => 'https://gls-group.eu/FR/fr/suivi-colis.html?match=[PACKAGE_ID]',
|
||||
'IE' => 'https://gls-group.eu/IE/en/parcel-tracking.html?match=[PACKAGE_ID]',
|
||||
'IT' => 'https://gls-group.eu/IT/it/servizi-online/ricerca-spedizioni.html?match=[PACKAGE_ID]&type=INT',
|
||||
'HU' => 'https://gls-group.eu/HU/hu/csomagkovetes.html?match=[PACKAGE_ID]',
|
||||
];
|
||||
|
||||
public $defaultIcon = '../../common/static/deliveries/gls.svg';
|
||||
|
||||
public $config = [
|
||||
'price_limit' => 60000,
|
||||
'maxLength' => 200.0, // Maximální rozměr strany položky
|
||||
// kombinace délky + obvodu je max 300cm.
|
||||
// Vypočte se jako 2x výška plus 2x šířka plus 1x nejdelší strana.
|
||||
// Např. balík 25x25x200cm => součet rozměrů tří stran 250cm
|
||||
'maxSumOfDimensions' => 250.0, // Maximální součet rozměrů všech tří stran položky
|
||||
'maxDimensions' => [80.0, 60.0, 200.0],
|
||||
// legacy config:
|
||||
'max_length' => 230, // Maximální rozměr jedné strany zásilky
|
||||
'max_dimensions' => 300, // Maximální součet délky a obvodu
|
||||
];
|
||||
|
||||
public function check(Cart $cart)
|
||||
{
|
||||
if ($cart->hasData('delivery') && $cart->hasData('user')) {
|
||||
$this->zipExists($cart->invoice);
|
||||
$this->zipExists($cart->delivery);
|
||||
}
|
||||
|
||||
return parent::check($cart);
|
||||
}
|
||||
|
||||
protected function getRestrictionParams(PurchaseState $purchaseState): RestrictionParams
|
||||
{
|
||||
$rParams = clone parent::getRestrictionParams($purchaseState);
|
||||
|
||||
// GLS ma vypocet obvodu stejnej jako PPL
|
||||
Delivery::includeClass('PPL');
|
||||
$rParams->setMaxSumOfDimensions(
|
||||
PPL::calculateMaxSumOfDimensions($rParams)
|
||||
);
|
||||
|
||||
return $rParams;
|
||||
}
|
||||
|
||||
public function getDimensionsSum(array $dimensions)
|
||||
{
|
||||
// Součet délky a obvodu = Obvod obchodního balíku plus nejdelší strana
|
||||
// x+2*y+2*z= max 300
|
||||
|
||||
return $dimensions[0] + 2 * ($dimensions[1] + $dimensions[2]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user