b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / a / home / dev2.destoffenstraat.com / app / code / WeSupply / Toolbox / Block / Estimations /
Filename/home/a/home/dev2.destoffenstraat.com/app/code/WeSupply/Toolbox/Block/Estimations/DisplayEta.php
Size2.34 kb
Permissionrwxrwxrwx
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified17-May-2021 07:15
Last accessed23-Aug-2025 09:08
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace WeSupply\Toolbox\Block\Estimations;

use Magento\Checkout\Block\Onepage\Success;
use Magento\Checkout\Model\Session;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\App\Http\Context as HttpContext;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Config;
use WeSupply\Toolbox\Helper\Data as WeSupplyHelper;

/**
* Class DisplayEta
* @package WeSupply\Toolbox\Block\Estimations
*/
class DisplayEta extends Success
{
/**
* @var WeSupplyHelper
*/
private $helper;

/**
* DisplayEta constructor.
* @param Context $context
* @param Session $checkoutSession
* @param Config $orderConfig
* @param HttpContext $httpContext
* @param WeSupplyHelper $helper
* @param array $data.
*/
public function __construct(
Context $context,
Session $checkoutSession,
Config $orderConfig,
HttpContext $httpContext,
WeSupplyHelper $helper,
array $data = []
)
{
parent::__construct($context, $checkoutSession, $orderConfig, $httpContext, $data);

$this->helper = $helper;
}

/**
* Get saved delivery timestamp from order
* and prepare it to be displayed on page
* @return bool|string
*/
public function getEstimatedDelivery()
{
$estimatedDelivery = [];
$order = $this->getOrder();

if ($order->getId() && $estimatedTimestamp = $order->getDeliveryTimestamp()) {
$estimatedTimestamp = explode(',', $estimatedTimestamp);
$estimationsFormat = $this->helper->getDeliveryEstimationsFormat();
$prevTimestamp = false;
foreach ($estimatedTimestamp as $timestamp) {
$currentTimestamp = $timestamp;
if ($prevTimestamp && $currentTimestamp == $prevTimestamp) {
continue;
}

$estimatedDelivery[] = date($estimationsFormat, $timestamp);
$prevTimestamp = $currentTimestamp;
}
}

return $estimatedDelivery ? implode(' - ', $estimatedDelivery) : false;
}

/**
* @return Order
*/
protected function getOrder()
{
return $this->_checkoutSession->getLastRealOrder();
}
}