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 / Trustpilot / Reviews / Block /
Filename/home/dev2.destoffenstraat.com/app/code/Trustpilot/Reviews/Block/Success.php
Size4.07 kb
Permissionrwxrwxrwx
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified25-Feb-2022 04:42
Last accessed22-Aug-2025 20:02
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
namespace Trustpilot\Reviews\Block;

use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Model\Order;
use Magento\Checkout\Model\Session;
use Magento\Framework\View\Element\Template;
use Trustpilot\Reviews\Helper\Data;
use Trustpilot\Reviews\Helper\TrustpilotPluginStatus;
use Trustpilot\Reviews\Helper\OrderData;
use Magento\Store\Model\ScopeInterface as StoreScopeInterface;
use Trustpilot\Reviews\Helper\TrustpilotLog;
use \Magento\Framework\UrlInterface;

class Success extends Template
{
protected $_salesFactory;
protected $_checkoutSession;
protected $_helper;
protected $_orderData;
protected $_trustpilotLog;
protected $_storeManager;
protected $_pluginStatus;

public function __construct(
Context $context,
Order $salesOrderFactory,
Session $checkoutSession,
Data $helper,
OrderData $orderData,
TrustpilotLog $trustpilotLog,
array $data = [],
TrustpilotPluginStatus $pluginStatus)
{
$this->_salesFactory = $salesOrderFactory;
$this->_checkoutSession = $checkoutSession;
$this->_helper = $helper;
$this->_orderData = $orderData;
$this->_trustpilotLog = $trustpilotLog;
$this->_storeManager = $context->getStoreManager();
$this->_pluginStatus = $pluginStatus;

parent::__construct($context, $data);
}

public function getOrder()
{
try {
$orderId = $this->_checkoutSession->getLastOrderId();
$order = $this->_salesFactory->load($orderId);
$storeId = $order->getStoreId();

$origin = $this->_storeManager->getStore($storeId)->getBaseUrl(UrlInterface::URL_TYPE_WEB);
$code = $this->_pluginStatus->checkPluginStatus($origin, $storeId);
if ($code > 250 && $code < 254) {
return 'undefined';
}

$general_settings = json_decode($this->_helper->getConfig('master_settings_field', $storeId, StoreScopeInterface::SCOPE_STORES))->general;
$data = $this->_orderData->getInvitation($order, 'magento2_success', \Trustpilot\Reviews\Model\Config::WITH_PRODUCT_DATA);

try {
$data['totalCost'] = $order->getGrandTotal();
$data['currency'] = $order->getOrderCurrencyCode();
} catch (\Throwable $e) {
$description = 'Unable to get order total cost';
$this->_trustpilotLog->error($e, $description, array(
'orderId' => $orderId,
'storeId' => $storeId
));
} catch (\Exception $e) {
$description = 'Unable to get order total cost';
$this->_trustpilotLog->error($e, $description, array(
'orderId' => $orderId,
'storeId' => $storeId
));
}

if (!in_array('trustpilotOrderConfirmed', $general_settings->mappedInvitationTrigger)) {
$data['payloadType'] = 'OrderStatusUpdate';
}

return json_encode($data, JSON_HEX_APOS);
} catch (\Throwable $e) {
$error = array('message' => $e->getMessage());
$data = array('error' => $error);
$vars = array(
'orderId' => isset($orderId) ? $orderId : null,
'storeId' => isset($storeId) ? $storeId : null,
);
$description = 'Unable to get order data';
$this->_trustpilotLog->error($e, $description, $vars);
return json_encode($data, JSON_HEX_APOS);
} catch (\Exception $e) {
$error = array('message' => $e->getMessage());
$data = array('error' => $error);
$vars = array(
'orderId' => isset($orderId) ? $orderId : null,
'storeId' => isset($storeId) ? $storeId : null,
);
$description = 'Unable to get order data';
$this->_trustpilotLog->error($e, $description, $vars);
return json_encode($data, JSON_HEX_APOS);
}
}
}