33 lines
904 B
PHP
33 lines
904 B
PHP
<?php
|
|
|
|
namespace DpdPoland\Service;
|
|
|
|
use Address;
|
|
use Cart;
|
|
use Country;
|
|
use Exception;
|
|
|
|
class PickupIframeService
|
|
{
|
|
const PL_CONST = 'PL';
|
|
const PUDO_BASE_URL = '//pudofinder.dpd.com.pl/widget?key=1ae3418e27627ab52bebdcc1a958fa04';
|
|
|
|
public static function getPickupIframeUrl($isCod, $isSwipbox, $idCart)
|
|
{
|
|
try {
|
|
$cart = new Cart($idCart);
|
|
$orderAddress = new Address((int)$cart->id_address_delivery);
|
|
$countryIso = Country::getIsoById($orderAddress->id_country);
|
|
} catch (Exception $e) {
|
|
$countryIso = self::PL_CONST;
|
|
}
|
|
|
|
if ($isCod)
|
|
return self::PUDO_BASE_URL . '&direct_delivery_cod=1&query=' . $countryIso;
|
|
|
|
if ($isSwipbox)
|
|
return self::PUDO_BASE_URL . '&swip_box=1&hideFilters=1&query=' . $countryIso;
|
|
|
|
return self::PUDO_BASE_URL . '&query=' . $countryIso;
|
|
}
|
|
} |