diff --git a/CHANGELOG.md b/CHANGELOG.md index afb54526..0aa4e2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,3 +40,10 @@ - Set parcels from different countries functionality added - Bugfix when no idcart in order page to select parcel +## [3.1.5] - 2021-03-25 +### Changed +- Added shipping cost to dpd shipment +- Translations added for carriers on webservice change +- Module tab install/uninstall dublication on module tab titles, all invisible titles are showing bug fixes added +- Maps loading sequence fixed + diff --git a/config/provider.yml b/config/provider.yml index 43c61246..b33bf660 100644 --- a/config/provider.yml +++ b/config/provider.yml @@ -30,5 +30,6 @@ services: - '@Invertus\dpdBaltics\Repository\ProductAvailabilityRepository' Invertus\dpdBaltics\Provider\CurrentCountryProvider: + class: 'Invertus\dpdBaltics\Provider\CurrentCountryProvider' arguments: - '@context' diff --git a/config/service.yml b/config/service.yml index ce3a627e..f7673d8e 100644 --- a/config/service.yml +++ b/config/service.yml @@ -236,3 +236,10 @@ services: class: 'Invertus\dpdBaltics\Grid\Row\PrintAccessibilityChecker' arguments: - '@Invertus\dpdBaltics\Repository\ShipmentRepository' + + Invertus\dpdBaltics\Service\Carrier\CarrierUpdateHandler: + class: 'Invertus\dpdBaltics\Service\Carrier\CarrierUpdateHandler' + arguments: + - '@Invertus\dpdBaltics\Repository\ProductRepository' + - '@Invertus\dpdBaltics\Service\Carrier\UpdateCarrierService' + - '@Invertus\dpdBaltics\Service\Product\ProductService' diff --git a/controllers/admin/AdminDPDBalticsSettingsController.php b/controllers/admin/AdminDPDBalticsSettingsController.php index 4439b305..b0a6a9f4 100644 --- a/controllers/admin/AdminDPDBalticsSettingsController.php +++ b/controllers/admin/AdminDPDBalticsSettingsController.php @@ -7,6 +7,8 @@ use Invertus\dpdBaltics\DTO\DPDProductInstall; use Invertus\dpdBaltics\Repository\ProductRepository; use Invertus\dpdBaltics\Service\Carrier\CreateCarrierService; +use Invertus\dpdBaltics\Service\Carrier\CarrierUpdateHandler; +use Invertus\dpdBaltics\Service\Carrier\UpdateCarrierService; use Invertus\dpdBaltics\Service\LogsService; use Invertus\dpdBaltics\Service\Product\ProductService; use Invertus\dpdBaltics\Templating\InfoBlockRender; @@ -149,10 +151,13 @@ public function postProcess() if (Tools::isSubmit('submitOptionsconfiguration')) { /** @var ProductService $productService */ $productService = $this->module->getModuleContainer()->get(ProductService::class); + /** @var CarrierUpdateHandler $carrierService */ + $carrierService = $this->module->getModuleContainer()->get(CarrierUpdateHandler::class); $newCountry = Tools::getValue(Config::WEB_SERVICE_COUNTRY); Configuration::updateValue(Config::DPD_PARCEL_IMPORT_COUNTRY_SELECTOR, Country::getByIso($newCountry)); $productService->updateCarriersOnCountryChange($newCountry); + $carrierService->updateCarrierName($newCountry); } $parentReturn = parent::postProcess(); diff --git a/dpdbaltics.php b/dpdbaltics.php index 50bdfb50..0f6eb441 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -98,7 +98,7 @@ public function __construct() $this->displayName = $this->l('DPDBaltics'); $this->author = 'Invertus'; $this->tab = 'shipping_logistics'; - $this->version = '3.1.4'; + $this->version = '3.1.5'; $this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_]; $this->need_instance = 0; parent::__construct(); @@ -663,6 +663,17 @@ public function hookActionAdminControllerSetMedia($params) { $currentController = Tools::getValue('controller'); + if (Config::isPrestashopVersionBelow174()) { + /** @var $tabs TabService*/ + $tabs = $this->getModuleContainer()->get(TabService::class); + $visibleClasses = $tabs->getTabsClassNames(false); + + if (in_array($currentController, $visibleClasses, true)) { + Media::addJsDef(['visibleTabs' => $tabs->getTabsClassNames(true)]); + $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/tabsHandlerBelowPs174.js'); + } + } + if ('AdminOrders' === $currentController) { $this->handleLabelPrintService(); diff --git a/src/Builder/Template/Admin/ProductBlockBuilder.php b/src/Builder/Template/Admin/ProductBlockBuilder.php index 17ef2cee..a7b1d6ff 100644 --- a/src/Builder/Template/Admin/ProductBlockBuilder.php +++ b/src/Builder/Template/Admin/ProductBlockBuilder.php @@ -116,6 +116,11 @@ public function renderProducts() } $carrier = Carrier::getCarrierByReference($product->id_reference); + + if (!$carrier) { + continue; + } + $delays = []; foreach ($carrier->delay as $key => $item) { $delays[Language::getIsoById($key)] = $item; diff --git a/src/Config/Config.php b/src/Config/Config.php index 4bf52808..604eb8b1 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -227,24 +227,85 @@ class Config const PRODUCT_TYPE_SAME_DAY_DELIVERY = '274'; const PS_VERSION_1_7_7 = '1.7.7.0'; + const PRODUCT_NAME_B2B = [ + 'LT' => 'Pristatymas privatiems asmenims', + 'EE' => 'DPD kuller', + 'LV' => 'Kurjerpiegādes Privātpersonām', + 'EN' => 'DPD courier', + ]; + + const PRODUCT_NAME_PUDO = [ + 'LT' => 'Pristatymas į paštomatą', + 'EE' => 'DPD pakiautomaat lunamaksega', + 'LV' => 'Piegādes uz Paku Skapjiem un Paku Bodēm', + 'EN' => 'DPD Pickup points', + ]; + + const PRODUCT_NAME_B2B_COD = [ + 'LT' => 'Atsiskaitymas pristatymo metu', + 'EE' => 'DPD kuller lunamaksega', + 'LV' => 'Naudas iekasēšana piegādes brīdī', + 'EN' => 'Cash on Delivery', + ]; + + + const PRODUCT_NAME_PUDO_COD = [ + 'LT' => 'DPD Paštomatas, atsiskaitymas grynaisiais', + 'EE' => 'DPD pakiautomaat lunamaksega', + 'LV' => 'DPD Pickup COD', + 'EN' => 'DPD Pickup COD', + ]; + + const PRODUCT_NAME_SATURDAY_DELIVERY = [ + 'LT' => 'Pristatymas šeštadienį', + 'EE' => 'DPD kuller laupäeval', + 'LV' => 'Sestdienas piegāde', + 'EN' => 'DPD Saturday', + ]; + + const PRODUCT_NAME_SATURDAY_DELIVERY_COD = [ + 'LT' => 'Pristatymas Šestadienį, atsiskaitymas grynaisiais', + 'EE' => 'DPD kuller laupäeval lunamaksega', + 'LV' => 'Saturday Delivery COD', + 'EN' => 'Saturday Delivery COD', + ]; - public static function getProducts() + const PRODUCT_NAME_SAME_DAY_DELIVERY = [ + 'LT' => 'Pristatymas tą pačią dieną', + 'EE' => 'Samal päeval kohaletoimetamine', + 'LV' => 'Same day Delivery', + 'EN' => 'Same day Delivery', + ]; + + public static function getProducts($webServiceCountry = 'EN') { $collection = new DPDProductInstallCollection(); - $product = self::getProductByReference(self::PRODUCT_TYPE_B2B); + $product = self::getProductByReference(self::PRODUCT_TYPE_B2B, $webServiceCountry); + $collection->add($product); + + $product = self::getProductByReference(self::PRODUCT_TYPE_PUDO, $webServiceCountry); $collection->add($product); - $product = self::getProductByReference(self::PRODUCT_TYPE_PUDO); + $product = self::getProductByReference(self::PRODUCT_TYPE_B2B_COD, $webServiceCountry); $collection->add($product); - $product = self::getProductByReference(self::PRODUCT_TYPE_B2B_COD); + $product = self::getProductByReference( + self::PRODUCT_TYPE_SATURDAY_DELIVERY, + $webServiceCountry + ); $collection->add($product); - $product = self::getProductByReference(self::PRODUCT_TYPE_SATURDAY_DELIVERY); + $product = self::getProductByReference( + self::PRODUCT_TYPE_PUDO_COD, + $webServiceCountry + ); $collection->add($product); - $product = self::getProductByReference(self::PRODUCT_TYPE_SATURDAY_DELIVERY_COD); + $product = self::getProductByReference( + self::PRODUCT_TYPE_SATURDAY_DELIVERY_COD, + $webServiceCountry + ); $collection->add($product); return $collection; @@ -259,7 +320,7 @@ public static function getPsAndModuleVersion() { $module = Module::getInstanceByName('dpdbaltics'); - return 'PS_'._PS_VERSION_.';'. $module->version; + return 'PS_'._PS_VERSION_.'|'. $module->version; } @@ -304,12 +365,13 @@ public static function getOnBoardImportTypes() ]; } - public static function getProductByReference($productReference) + public static function getProductByReference($productReference, $countryCode = 'EN') { + switch ($productReference) { case self::PRODUCT_TYPE_B2B: $product = new DPDProductInstall(); - $product->setName('DPD B2C'); + $product->setName(self::PRODUCT_NAME_B2B[$countryCode]); $product->setId(self::PRODUCT_TYPE_B2B); $product->setDelay('Your delivery experts'); $product->setIsPudo(0); @@ -318,7 +380,7 @@ public static function getProductByReference($productReference) break; case self::PRODUCT_TYPE_PUDO: $product = new DPDProductInstall(); - $product->setName('DPD Pickup'); + $product->setName(self::PRODUCT_NAME_PUDO[$countryCode]); $product->setId(self::PRODUCT_TYPE_PUDO); $product->setDelay('Your delivery experts'); $product->setIsPudo(1); @@ -327,7 +389,7 @@ public static function getProductByReference($productReference) break; case self::PRODUCT_TYPE_B2B_COD: $product = new DPDProductInstall(); - $product->setName('DPD B2C COD'); + $product->setName(self::PRODUCT_NAME_B2B_COD[$countryCode]); $product->setId(self::PRODUCT_TYPE_B2B_COD); $product->setDelay('Your delivery experts'); $product->setIsPudo(0); @@ -336,7 +398,7 @@ public static function getProductByReference($productReference) break; case self::PRODUCT_TYPE_PUDO_COD: $product = new DPDProductInstall(); - $product->setName('DPD Pickup COD'); + $product->setName(self::PRODUCT_NAME_PUDO_COD[$countryCode]); $product->setId(Config::PRODUCT_TYPE_PUDO_COD); $product->setDelay('Your delivery experts'); $product->setIsPudo(1); @@ -345,7 +407,7 @@ public static function getProductByReference($productReference) break; case self::PRODUCT_TYPE_SATURDAY_DELIVERY: $product = new DPDProductInstall(); - $product->setName('Saturday Delivery'); + $product->setName(self::PRODUCT_NAME_SATURDAY_DELIVERY[$countryCode]); $product->setId(self::PRODUCT_TYPE_SATURDAY_DELIVERY); $product->setDelay('Your delivery experts'); $product->setIsPudo(0); @@ -354,7 +416,7 @@ public static function getProductByReference($productReference) break; case self::PRODUCT_TYPE_SATURDAY_DELIVERY_COD: $product = new DPDProductInstall(); - $product->setName('Saturday Delivery COD'); + $product->setName(self::PRODUCT_NAME_SATURDAY_DELIVERY_COD[$countryCode]); $product->setId(self::PRODUCT_TYPE_SATURDAY_DELIVERY_COD); $product->setDelay('Your delivery experts'); $product->setIsPudo(0); @@ -363,7 +425,7 @@ public static function getProductByReference($productReference) break; case self::PRODUCT_TYPE_SAME_DAY_DELIVERY: $product = new DPDProductInstall(); - $product->setName('Same day Delivery'); + $product->setName(self::PRODUCT_NAME_SAME_DAY_DELIVERY[$countryCode]); $product->setId(self::PRODUCT_TYPE_SAME_DAY_DELIVERY); $product->setDelay('Your delivery experts'); $product->setIsPudo(1); @@ -513,4 +575,12 @@ public static function isPrestashopVersionAbove177() return false; } + + /** + * @return bool + */ + public static function isPrestashopVersionBelow174() + { + return (bool) version_compare(_PS_VERSION_, '1.7.4', '<'); + } } diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 079340f5..d396f032 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -15,8 +15,10 @@ use Invertus\dpdBaltics\Service\Carrier\CreateCarrierService; use Invertus\dpdBaltics\Factory\TabFactory; use Invertus\dpdBaltics\Service\Label\LabelPositionService; +use Invertus\dpdBaltics\Uninstaller\ModuleTabs\ModuleTabsUninstaller; use Invertus\psModuleTabs\Object\TabsCollection; use Invertus\psModuleTabs\Service\TabsInitializer; +use Invertus\psModuleTabs\Service\TabsUninstaller; use Symfony\Component\Validator\Constraints\Count; use Tools; use Validate; @@ -120,7 +122,7 @@ public function uninstall() } if (!$this->uninstallTabs()) { - $this->errors[] = $this->module->l('Failed to install tabs', self::FILE_NAME); + $this->errors[] = $this->module->l('Failed to uninstall tabs', self::FILE_NAME); return false; } @@ -288,9 +290,11 @@ private function uninstallConfiguration() private function installTabs() { + if (!Config::isPrestashopVersionBelow174()) { + return true; + } /** @var TabsCollection $tabCollection */ $tabCollection = $this->tabFactory->getTabsCollection(); - $tabsInitializer = new TabsInitializer(_PS_VERSION_, $tabCollection); return $tabsInitializer->initializeTabsByPsVersion(); @@ -298,8 +302,16 @@ private function installTabs() private function uninstallTabs() { - //TODO uninstall tabs - return true; + if (!Config::isPrestashopVersionBelow174()) { + return true; + } + + /** @var TabsCollection $tabCollection */ + $tabCollection = $this->tabFactory->getTabsCollection()->getTabsCollection(); + + $tabsUninstaller = new ModuleTabsUninstaller($tabCollection); + + return $tabsUninstaller->uninstallTabs(); } private function processDeleteCarriers() { diff --git a/src/Service/Carrier/CarrierUpdateHandler.php b/src/Service/Carrier/CarrierUpdateHandler.php new file mode 100644 index 00000000..ba125c5c --- /dev/null +++ b/src/Service/Carrier/CarrierUpdateHandler.php @@ -0,0 +1,50 @@ +productRepository = $productRepository; + $this->updateCarrierService = $updateCarrierService; + $this->productService = $productService; + } + + /** + * @param $webServiceCountry + * + * @throws \Invertus\dpdBaltics\Exception\ProductUpdateException + */ + public function updateCarrierName($webServiceCountry) + { + $products = Config::getProducts($webServiceCountry); + + foreach ($products as $product) { + $productId = $this->productRepository->getProductIdByProductReference($product->getId()); + $this->updateCarrierService->updateCarrierName($productId, $product->getName()); + $this->productService->updateProductName($productId, $product->getName()); + } + } +} diff --git a/src/Service/Carrier/UpdateCarrierService.php b/src/Service/Carrier/UpdateCarrierService.php index 7d71b0d2..2f38c58a 100644 --- a/src/Service/Carrier/UpdateCarrierService.php +++ b/src/Service/Carrier/UpdateCarrierService.php @@ -59,4 +59,28 @@ public function updateCarrier($productId, $params) throw new ProductUpdateException($e->getMessage()); }; } + + /** + * @param int $productId + * @param $name + * + * @throws ProductUpdateException + */ + public function updateCarrierName($productId, $name) + { + try { + $dpdProduct = new DPDProduct($productId); + + $this->carrierUpdateValidate->validateCarrierName($name); + $carrier = Carrier::getCarrierByReference($dpdProduct->id_reference); + + if (!$carrier) { + return; + } + $carrier->name = $name; + $carrier->update(); + } catch (Exception $e) { + throw new ProductUpdateException($e->getMessage()); + } + } } diff --git a/src/Service/Product/ProductService.php b/src/Service/Product/ProductService.php index 35f70ac0..49b148ef 100644 --- a/src/Service/Product/ProductService.php +++ b/src/Service/Product/ProductService.php @@ -47,7 +47,28 @@ public function updateProduct($productId, $active) $dpdProduct->update(); } catch (Exception $e) { throw new ProductUpdateException($e->getMessage()); - }; + } + } + + /** + * @param $productId + * @param $name + * + * @throws ProductUpdateException + */ + public function updateProductName($productId, $name) + { + + try { + $dpdProduct = new DPDProduct($productId); + if (!\Validate::isLoadedObject($dpdProduct)) { + return; + } + $dpdProduct->name = $name; + $dpdProduct->update(); + } catch (Exception $e) { + throw new ProductUpdateException($e->getMessage()); + } } public function deleteProduct($productReference) @@ -66,10 +87,10 @@ public function deleteProduct($productReference) return $this->productRepository->deleteByProductReference($product->getProductReference()); } - public function addProduct($productReference) + public function addProduct($productReference, $countryCode = null) { $collection = new DPDProductInstallCollection(); - $product = Config::getProductByReference($productReference); + $product = Config::getProductByReference($productReference, $countryCode); $collection->add($product); return $this->createCarrierService->createCarriers($collection); @@ -78,25 +99,31 @@ public function addProduct($productReference) public function updateCarriersOnCountryChange($newCountryIsoCode) { - $productId = $this->productRepository->getProductIdByProductReference(Config::PRODUCT_TYPE_PUDO_COD); + $productId = $this->productRepository->getProductIdByProductReference( + Config::PRODUCT_TYPE_PUDO_COD + ); if ($newCountryIsoCode === Config::LATVIA_ISO_CODE) { $this->deleteProduct(Config::PRODUCT_TYPE_PUDO_COD); } elseif (!$productId) { - $this->addProduct(Config::PRODUCT_TYPE_PUDO_COD); + $this->addProduct(Config::PRODUCT_TYPE_PUDO_COD, $newCountryIsoCode); } - $productId = $this->productRepository->getProductIdByProductReference(Config::PRODUCT_TYPE_SAME_DAY_DELIVERY); + $productId = $this->productRepository->getProductIdByProductReference( + Config::PRODUCT_TYPE_SAME_DAY_DELIVERY + ); if ($newCountryIsoCode !== Config::LATVIA_ISO_CODE) { $this->deleteProduct(Config::PRODUCT_TYPE_SAME_DAY_DELIVERY); } elseif (!$productId) { - $this->addProduct(Config::PRODUCT_TYPE_SAME_DAY_DELIVERY); + $this->addProduct(Config::PRODUCT_TYPE_SAME_DAY_DELIVERY, $newCountryIsoCode); } - $productId = $this->productRepository->getProductIdByProductReference(Config::PRODUCT_TYPE_SATURDAY_DELIVERY_COD); + $productId = $this->productRepository->getProductIdByProductReference( + Config::PRODUCT_TYPE_SATURDAY_DELIVERY_COD + ); if ($newCountryIsoCode === Config::LATVIA_ISO_CODE) { $this->deleteProduct(Config::PRODUCT_TYPE_SATURDAY_DELIVERY_COD); } elseif (!$productId) { - $this->addProduct(Config::PRODUCT_TYPE_SATURDAY_DELIVERY_COD); + $this->addProduct(Config::PRODUCT_TYPE_SATURDAY_DELIVERY_COD, $newCountryIsoCode); } return true; diff --git a/src/Service/ShipmentService.php b/src/Service/ShipmentService.php index cff68089..23bc7213 100644 --- a/src/Service/ShipmentService.php +++ b/src/Service/ShipmentService.php @@ -182,10 +182,12 @@ private function createNonDistributedShipment(Order $order, $idProduct, $isTestM $products = $order->getProducts(); $parcelPrice = 0; $parcelWeight = 0; + $orderShippingCost = $order->total_shipping_tax_incl ?: 0; foreach ($products as $product) { $parcelPrice += round($product['total_wt'], 2); $parcelWeight += $product['weight'] * $product['product_quantity']; } + $parcelPrice += $orderShippingCost; $shipment = $this->createShipment($order, $idProduct, $isTestMode, 1, $parcelWeight, $parcelPrice); if (!$shipment->id) { @@ -201,15 +203,16 @@ private function createParcelDistributedShipments(Order $order, $idProduct, $isT $parcelPrice = 0; $parcelWeight = 0; $parcelsNum = 0; + $orderShippingCost = $order->total_shipping_tax_incl ?: 0; + foreach ($products as $product) { $parcelPrice += round($product['total_wt'], 2); + $parcelPrice += $orderShippingCost; $parcelWeight += $product['weight'] * $product['product_quantity']; $parcelsNum++; $shipment = $this->createShipment($order, $idProduct, $isTestMode, $parcelsNum, $parcelWeight, $parcelPrice); } - - if (!$shipment->id) { return false; } @@ -223,12 +226,15 @@ private function createParcelQuantityDistributedShipments(Order $order, $idProdu $parcelPrice = 0; $parcelWeight = 0; $parcelsNum = 0; + $orderShippingCost = $order->total_shipping_tax_incl ?: 0; + foreach ($products as $product) { $parcelPrice += round($product['total_wt'], 2); $parcelWeight += $product['weight'] * $product['product_quantity']; $parcelsNum += $product['product_quantity']; } + $parcelPrice += $orderShippingCost; $shipment = $this->createShipment($order, $idProduct, $isTestMode, $parcelsNum, $parcelWeight, $parcelPrice); if (!$shipment->id) { return false; diff --git a/src/Service/TabService.php b/src/Service/TabService.php index 8de295e8..51492938 100644 --- a/src/Service/TabService.php +++ b/src/Service/TabService.php @@ -172,4 +172,22 @@ public function getTabs() ], ]; } + + /** + * Filter visible tabs to handle in javascript for ps versiosns below 1704 + */ + public function getTabsClassNames($visible = true) + { + $filtered = []; + $tabs = $this->getTabs(); + + foreach ($tabs as $tab) { + if ($visible && isset($tab['visible']) && $tab['visible']) { + $filtered[] = $tab['class_name']; + } else { + $filtered[] = $tab['class_name']; + } + } + return $filtered; + } } diff --git a/src/Uninstaller/ModuleTabs/ModuleTabsUninstaller.php b/src/Uninstaller/ModuleTabs/ModuleTabsUninstaller.php new file mode 100644 index 00000000..bd8a92c4 --- /dev/null +++ b/src/Uninstaller/ModuleTabs/ModuleTabsUninstaller.php @@ -0,0 +1,39 @@ +tabs = $tabs; + } + + public function uninstallTabs() + { + + foreach ($this->tabs as $tab) { + $idTab = Tab::getIdFromClassName($tab->getClassName()); + + if (!$idTab) { + continue; + } + + $tab = new Tab($idTab); + if (!$tab->delete()) { + return false; + } + } + + return true; + } +} diff --git a/views/js/admin/tabsHandlerBelowPs174.js b/views/js/admin/tabsHandlerBelowPs174.js new file mode 100644 index 00000000..33e84849 --- /dev/null +++ b/views/js/admin/tabsHandlerBelowPs174.js @@ -0,0 +1,40 @@ + +$(document).ready(function (){ + var tabs = $('.page-head-tabs > a'); + var visible = visibleTabs; + var seen = {}; + $( tabs ).each(function() { + //Extracts distinct value from module tab names as ps version < 174 cannot handle lang + var txt = $(this).text(); + if (seen[txt]) { + $(this).remove(); + } else { + seen[txt] = true; + } + + var href = $( this ).attr('href'); + var controller = getUrlParam('controller', href); + if (!inArray(controller, visible)) { + $(this).remove(); + } + }); + + function getUrlParam( name, url ) { + + //Extracs param value from href link + var extractedParamValue = "[\\?&]"+name+"=([^&#]*)"; + var regex = new RegExp( extractedParamValue ); + var results = regex.exec( url ); + return results == null ? null : results[1]; + } + + function inArray(needle, haystack) { + var length = haystack.length; + for(var i = 0; i < length; i++) { + if(haystack[i] == needle){ + return true; + } + } + return false; + } +}); diff --git a/views/js/front/pudo.js b/views/js/front/pudo.js index 90903972..8df13963 100644 --- a/views/js/front/pudo.js +++ b/views/js/front/pudo.js @@ -23,11 +23,13 @@ var dpdMap = {}; var infoWindow; -if (typeof google !== 'undefined') { - infoWindow = new google.maps.InfoWindow(); -} $(document).ready(function () { + + if (typeof google !== 'undefined') { + infoWindow = new google.maps.InfoWindow(); + } + $(".dpd-input-wrapper .dpd-input-placeholder").on("click", function () { $(this).closest(".dpd-input-wrapper").find("input").focus(); });