diff --git a/Controller/Parcelshops/Index.php b/Controller/Parcelshops/Index.php
index 778da80..e988750 100644
--- a/Controller/Parcelshops/Index.php
+++ b/Controller/Parcelshops/Index.php
@@ -27,6 +27,7 @@
use DpdConnect\Shipping\Helper\Data;
use DpdConnect\Shipping\Helper\Services\DPDPickupService;
use Magento\Framework\View\Asset\Repository;
+use Magento\Framework\View\Element\Template;
class Index extends \Magento\Framework\App\Action\Action
{
@@ -205,15 +206,18 @@ protected function _getOpeningHoursHtml($openMorning, $closeMorning, $openAftern
$openingHoursAfternoon = __('Closed');
}
- $html = '
-
- |
- ' . __(strtolower($weekday)) . ' |
- ' . $openingHoursMorning . ' |
- ' . $openingHoursAfternoon . ' |
-
';
+ $layout = $this->_view->getLayout();
+ $openingHoursData = [
+ 'openingHoursMorning' => $openingHoursMorning,
+ 'openingHoursAfternoon'=> $openingHoursAfternoon,
+ 'weekday' => $weekday
+ ];
+
+ $block = $layout->createBlock(Template::class)
+ ->setTemplate('DpdConnect_Shipping::checkout/shipping/parcelshop-opening-hours.phtml')
+ ->setData('openingHours', $openingHoursData);
- return $html;
+ return $block->toHtml();
}
/**
@@ -227,30 +231,11 @@ protected function _getMarkerHtml($shop, $special)
{
$image = $this->assetRepo->getUrlWithParams('DpdConnect_Shipping::images/dpd_parcelshop_logo.png', array('_secure' => $this->getRequest()->isSecure()));
$routeIcon = $this->assetRepo->getUrlWithParams('DpdConnect_Shipping::images/icon_route.png', array('_secure' => $this->getRequest()->isSecure()));
-
- $html = '
-
-
-
-
-
-
- |
-
- ' . ($special ? $shop['getParcelshopPudoName']() : $shop['company']) . '
- ' . ($special ? $shop['getData']('parcelshop_address_1') : $shop['street'] . " " . $shop['houseNo']) . '
- ' . ($special ? $shop['getParcelshopPostCode']() . ' ' . $shop['getParcelshopTown']() : $shop['zipCode'] . ' ' . $shop['city']) . '
- |
-
-
-
- Openingstijden
- |
-
';
-
+ $layout = $this->_view->getLayout();
+ $openingHoursHtml = '';
if (!$special && isset($shop['openingHours']) && $shop['openingHours'] != "") {
foreach ($shop['openingHours'] as $openinghours) {
- $html .= $this->_getOpeningHoursHtml(
+ $openingHoursHtml .= $this->_getOpeningHoursHtml(
$openinghours['openMorning'],
$openinghours['closeMorning'],
$openinghours['openAfternoon'],
@@ -260,7 +245,7 @@ protected function _getMarkerHtml($shop, $special)
}
} else {
foreach (json_decode($shop['getParcelshopOpeninghours']()) as $openinghours) {
- $html .= $this->_getOpeningHoursHtml(
+ $openingHoursHtml .= $this->_getOpeningHoursHtml(
$openinghours['openMorning'],
$openinghours['closeMorning'],
$openinghours['openAfternoon'],
@@ -270,17 +255,16 @@ protected function _getMarkerHtml($shop, $special)
}
}
- $html .= '
-
- |
-
- ' . __('Select Parcelshop') . '
- |
-
-
-
-
';
-
- return $html;
+ $parcelShopData = [
+ 'shop' => $shop,
+ 'special' => $special,
+ 'image' => $image,
+ 'openingHoursHtml' => $openingHoursHtml
+ ];
+ $block = $layout->createBlock(Template::class)
+ ->setTemplate('DpdConnect_Shipping::checkout/shipping/parcelshop-marker.phtml')
+ ->setData('markerParams', $parcelShopData);
+
+ return $block->toHtml();
}
}
diff --git a/view/frontend/templates/checkout/shipping/parcelshop-marker.phtml b/view/frontend/templates/checkout/shipping/parcelshop-marker.phtml
new file mode 100644
index 0000000..d5cfe83
--- /dev/null
+++ b/view/frontend/templates/checkout/shipping/parcelshop-marker.phtml
@@ -0,0 +1,36 @@
+getData('markerParams');
+$shop = $markerParams['shop'];
+$special = $markerParams['special'];
+$image = $markerParams['image'];
+$openingHoursHtml = $markerParams['openingHoursHtml'];
+?>
+
+
+
+
+
+
+ |
+
+ = ($special ? $shop['getParcelshopPudoName']() : $shop['company']) ?>
+ = ($special ? $shop['getData']('parcelshop_address_1') : $shop['street'] . " " . $shop['houseNo']) . '
+ ' . ($special ? $shop['getParcelshopPostCode']() . ' ' . $shop['getParcelshopTown']() : $shop['zipCode'] . ' ' . $shop['city']) ?>
+ |
+
+
+
+ Openingstijden
+ |
+
+ = $openingHoursHtml; ?>
+
+ |
+
+ = __('Select Parcelshop') ?>
+ |
+
+
+
+
+
diff --git a/view/frontend/templates/checkout/shipping/parcelshop-opening-hours.phtml b/view/frontend/templates/checkout/shipping/parcelshop-opening-hours.phtml
new file mode 100644
index 0000000..2ce9d5a
--- /dev/null
+++ b/view/frontend/templates/checkout/shipping/parcelshop-opening-hours.phtml
@@ -0,0 +1,12 @@
+getData('openingHours');
+$openingHoursMorning = $openingHours['openingHoursMorning'];
+$openingHoursAfternoon= $openingHours['openingHoursAfternoon'];
+$weekday = $openingHours['weekday'];
+?>
+
+ |
+ = __(strtolower($weekday)) ?> |
+ = $openingHoursMorning ?> |
+ = $openingHoursAfternoon ?> |
+