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 / dev2.destoffenstraat.com / app / code / WeSupply / Toolbox / Block /
Filename/home/dev2.destoffenstraat.com/app/code/WeSupply/Toolbox/Block/Notification.php
Size5.49 kb
Permissionrwxrwxrwx
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified17-May-2021 07:14
Last accessed22-Aug-2025 02:07
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
namespace WeSupply\Toolbox\Block;

use Magento\Framework\View\Element\Template;
use WeSupply\Toolbox\Model\Config\Source\NotificationDesignMode;
use WeSupply\Toolbox\Model\Config\Source\NotificationDesignType;
use WeSupply\Toolbox\Model\Config\Source\NotificationDesignModeAlignment;
use WeSupply\Toolbox\Model\OrderInfoBuilder;

class Notification extends Template
{

const XML_CONFIG_COUNTRY_PATH = 'general/country/default';

/**
* @var \Magento\Checkout\Model\Session
*/
private $checkoutSession;

/**
* @var \WeSupply\Toolbox\Helper\Data
*/
private $helper;

/**
* @var \Magento\Sales\Api\OrderRepositoryInterface
*/
private $orderRepository;


private $phoneCodes;

private $scopeConfig;

/**
* Notification constructor.
* @param Template\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Checkout\Model\Session $checkoutSession,
\WeSupply\Toolbox\Helper\Data $helper,
\WeSupply\Toolbox\Helper\PhoneCodes $phoneCodes,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
array $data = []
) {
parent::__construct($context, $data);
$this->checkoutSession = $checkoutSession;
$this->orderRepository = $orderRepository;
$this->helper = $helper;
$this->phoneCodes = $phoneCodes;
$this->scopeConfig = $scopeConfig;
}

/**
* @return array
*/
public function getCountryPhoneCodes()
{
return $this->phoneCodes->getCountryPhoneCodes();
}


/**
* @return mixed
*/
public function getConfigDefaultCountryCode()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->scopeConfig->getValue(self::XML_CONFIG_COUNTRY_PATH, $storeScope);
}


/**
* @return string
*/
public function getWesupplyExternalOrderId()
{
return $this->checkoutSession->getData('last_real_order_id');
}

/**
* @return string
*/
public function getWesupplyOrderId()
{
$weSupplyOrderId = '';
if( array_key_exists('last_order_id', $this->checkoutSession->getData())){
$weSupplyOrderId = OrderInfoBuilder::PREFIX.$this->checkoutSession->getData('last_order_id');
}

return $weSupplyOrderId;
}

/**
* @return mixed
*/
public function getShippingPhone()
{
$lastOrderId = $this->checkoutSession->getData('last_order_id');
if ($lastOrderId) {
$orderObj = $this->orderRepository->get($lastOrderId);
$addressObj = $orderObj->getShippingAddress();

if (!$addressObj) {
$addressObj = $orderObj->getBillingAddress();
}

return $addressObj->getData('telephone') ?? '';
}

return '';
}

public function getShippingCountryCode()
{
$lastOrderId = $this->checkoutSession->getLastOrderId();
if($lastOrderId){
$orderObj = $this->orderRepository->get($lastOrderId);
$addresObj = $orderObj->getShippingAddress();
if(!$addresObj)
{
$addresObj = $orderObj->getBillingAddress();
}

return $addresObj->getCountryId() ?? $this->getConfigDefaultCountryCode();
}

return $this->getConfigDefaultCountryCode();
}

/**
* @return mixed
*/
public function getDomain()
{
return $this->helper->getWeSupplyDomain();
}

/**
* @return string
*/
public function getSubdomain()
{
return $this->helper->getWeSupplySubDomain();
}

/**
* @return mixed
*/
public function getDesign()
{
return $this->helper->getNotificationDesign();
}


public function getAlignment()
{
return $this->helper->getNotificationAlignment();
}

/**
* @return mixed
*/
public function getEnabledNotification()
{
if($this->helper->getWeSupplyEnabled()) {
return $this->helper->getEnabledNotification();
}

return false;
}

/**
* @return mixed
*/
public function getFirstDesignConstant()
{
return NotificationDesignMode::FIRST_DESIGN_CODE;
}

/**
* @return string
*/
public function getLeftAlignmentConstant()
{
return NotificationDesignModeAlignment::ALIGNMENT_LEFT_DESIGN_CODE;
}

/**
* @return string
*/
public function getCenterAlignmentConstant()
{
return NotificationDesignModeAlignment::ALIGNMENT_CENTER_DESIGN_CODE;
}

/**
* @return string
*/
public function getDefaultLocationType()
{
return NotificationDesignType::FIRST_TYPE_CODE;
}

/**
* @return mixed
*/
public function getNotificationBoxType()
{
return $this->helper->getNotificationBoxType();
}

/**
* @return string
*/
public function getAjaxUrl()
{
return $this->getUrl('wesupply/notification/notify');
}

/**
* @return bool
*/
public function getUnsubscribeFlag()
{
if (!$this->getData("unsubscribe")) {
return 0;
}
return $this->getData("unsubscribe");
}
}