|
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 / Valued / Magento2 / Block / |
Filename | /home/a/home/dev2.destoffenstraat.com/app/code/Valued/Magento2/Block/OrderConsentData.php |
Size | 2.34 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 14-Jan-2025 14:08 |
Last accessed | 22-Aug-2025 19:42 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace Valued\Magento2\Block;
use Magento\Checkout\Model\Session;
use Magento\Sales\Model\Order;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\View\Element\Template;
use Magento\Sales\Model\OrderFactory;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Widget\Block\BlockInterface;
use Valued\Magento2\Helper\Invitation as InvitationHelper;
use Valued\Magento2\Setup\ExtensionBase;
class OrderConsentData extends Template implements BlockInterface {
private $extension;
private $orderFactory;
private $checkoutSession;
private $configs;
public function __construct(
Context $context,
InvitationHelper $invitationHelper,
StoreManagerInterface $storeManager,
ExtensionBase $extension,
OrderFactory $orderFactory,
Session $checkoutSession,
array $data = []
) {
$this->invitationHelper = $invitationHelper;
$this->storeManager = $storeManager;
$this->extension = $extension;
$this->orderFactory = $orderFactory;
$this->checkoutSession = $checkoutSession;
$this->configs = $invitationHelper->getConfigData($this->storeManager->getStore()->getId());
parent::__construct($context, $data);
}
public function getConsentData(): ?string {
$store_id = $this->storeManager->getStore()->getId();
$config = $this->invitationHelper->getConfigData($store_id);
if (!$config) {
return null;
}
$webshop_id = trim($config['webshop_id']);
if (!$webshop_id) {
return null;
}
$order = $this->getOrder();
$consent_data = [
'webshopId' => $webshop_id,
'orderNumber' => $order->getIncrementId(),
'email' => $order->getCustomerEmail(),
'firstName' => $order->getBillingAddress()->getFirstname(),
'inviteDelay' => $config['delay'],
];
return json_encode($consent_data);
}
private function getOrder(): Order {
return $this->orderFactory->create()->loadByIncrementId(
$this->checkoutSession->getLastRealOrderId());
}
public function consentFlowEnabled(): bool {
return $this->configs['consent_flow'] ?? false;
}
public function getSystemKey(): string {
return $this->extension->getSlug();
}
}
namespace Valued\Magento2\Block;
use Magento\Checkout\Model\Session;
use Magento\Sales\Model\Order;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\View\Element\Template;
use Magento\Sales\Model\OrderFactory;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Widget\Block\BlockInterface;
use Valued\Magento2\Helper\Invitation as InvitationHelper;
use Valued\Magento2\Setup\ExtensionBase;
class OrderConsentData extends Template implements BlockInterface {
private $extension;
private $orderFactory;
private $checkoutSession;
private $configs;
public function __construct(
Context $context,
InvitationHelper $invitationHelper,
StoreManagerInterface $storeManager,
ExtensionBase $extension,
OrderFactory $orderFactory,
Session $checkoutSession,
array $data = []
) {
$this->invitationHelper = $invitationHelper;
$this->storeManager = $storeManager;
$this->extension = $extension;
$this->orderFactory = $orderFactory;
$this->checkoutSession = $checkoutSession;
$this->configs = $invitationHelper->getConfigData($this->storeManager->getStore()->getId());
parent::__construct($context, $data);
}
public function getConsentData(): ?string {
$store_id = $this->storeManager->getStore()->getId();
$config = $this->invitationHelper->getConfigData($store_id);
if (!$config) {
return null;
}
$webshop_id = trim($config['webshop_id']);
if (!$webshop_id) {
return null;
}
$order = $this->getOrder();
$consent_data = [
'webshopId' => $webshop_id,
'orderNumber' => $order->getIncrementId(),
'email' => $order->getCustomerEmail(),
'firstName' => $order->getBillingAddress()->getFirstname(),
'inviteDelay' => $config['delay'],
];
return json_encode($consent_data);
}
private function getOrder(): Order {
return $this->orderFactory->create()->loadByIncrementId(
$this->checkoutSession->getLastRealOrderId());
}
public function consentFlowEnabled(): bool {
return $this->configs['consent_flow'] ?? false;
}
public function getSystemKey(): string {
return $this->extension->getSlug();
}
}