Skip to content

Commit

Permalink
Version 2.2.0 - MAG1-119 - MAG1-117 - MAG1-101
Browse files Browse the repository at this point in the history
- Put back implementation of MAG1-101, previously reverted
  • Loading branch information
ebanolopes committed Jan 29, 2018
1 parent aed8918 commit dffe466
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
89 changes: 89 additions & 0 deletions Block/Adminhtml/CaseInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

namespace Signifyd\Connect\Block\Adminhtml;

use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\Registry;
use Signifyd\Connect\Model\Casedata;

/**
* Get Signifyd Case Info
*
* @api
* @since 100.2.0
*/
class CaseInfo extends Template
{
/**
* @var Casedata
*/
private $caseEntity = false;

/**
* @var Registry
*/
private $coreRegistry = false;

/**
* CaseInfo constructor.
* @param Context $context
* @param Casedata $caseEntity
* @param Registry $registry
* @param array $data
*/
public function __construct(
Context $context,
Casedata $caseEntity,
Registry $registry,
array $data = []
) {
$this->caseEntity = $caseEntity;
$this->coreRegistry = $registry;

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

/**
* Gets case entity associated with order id.
*
* @return Casedata|null
*/
public function getCaseEntity()
{
if ($this->caseEntity->isEmpty()) {
$order = $this->getOrder();
if (!$order->isEmpty()) {
$this->caseEntity = $this->caseEntity->load($order->getIncrementId());
}
}

return $this->caseEntity;
}

/**
* Retrieve order model object
*
* @return \Magento\Sales\Model\Order
*/
public function getOrder()
{
return $this->coreRegistry->registry('sales_order');
}

/**
* Gets case guarantee disposition status
*/
public function getCaseGuaranteeDisposition()
{
return $this->getCaseEntity()->getData('guarantee');
}

/**
* Gets case score
*/
public function getCaseScore()
{
return floor($this->getCaseEntity()->getData('score'));
}
}
4 changes: 4 additions & 0 deletions view/adminhtml/layout/sales_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@
<block name="signifyd.sales.order.view.js" class="Magento\Framework\View\Element\Template"
template="Signifyd_Connect::sales_order_view.phtml"/>
</referenceContainer>

<referenceBlock name="order_additional_info">
<block class="Signifyd\Connect\Block\Adminhtml\CaseInfo" name="order_case_info" template="Signifyd_Connect::case_info.phtml"/>
</referenceBlock>
</body>
</page>
38 changes: 38 additions & 0 deletions view/adminhtml/templates/case_info.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile
?>
<?php /** @var $block Signifyd\Connect\Block\Adminhtml\CaseInfo */ ?>
<?php

if ($block->getCaseEntity()->isEmpty()) {
return '';
}
?>
<section class="admin__page-section order-case-info">
<div class="admin__page-section-title">
<span class="title"><?= $block->escapeHtml(__('Fraud Protection Information')) ?></span>
</div>
<div class="admin__page-section-content">
<div class="admin__page-section-item case-information">
<div class="admin__table-wrapper">
<table class="admin__table-secondary order-case-table">
<tbody>
<tr>
<th class="col-guarantee-disposition"><?= $block->escapeHtml(__('Signifyd Guarantee Decision')) ?></th>
<td class="col-guarantee-disposition"><?= $block->escapeHtml($block->getCaseGuaranteeDisposition()) ?></td>
</tr>
<tr>
<th class="col-guarantee-disposition"><?= $block->escapeHtml(__('Signifyd Score')) ?></th>
<td class="col-guarantee-disposition"><?= $block->escapeHtml($block->getCaseScore()) ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>

0 comments on commit dffe466

Please sign in to comment.