Skip to content

Commit

Permalink
Merged in SC-134 (pull request #24)
Browse files Browse the repository at this point in the history
[SC-134] Adding customer reference

* [SC-134] Sets customer reference on order payment additional info when order is placed. Reference be shown on order view page in admin.


Approved-by: Alexandru-Georgian Mazalu
  • Loading branch information
martinSternelius authored and nwtamazalu committed Mar 23, 2022
1 parent 41bc056 commit be3a2e1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
9 changes: 9 additions & 0 deletions Block/Payment/Checkout/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ public function getSveaCheckoutId()
return "";
}
}

public function getSveaCustomerReference()
{
try {
return $this->getInfo()->getAdditionalInformation('svea_customer_reference');
} catch (\Exception $e) {
return "";
}
}
}
4 changes: 4 additions & 0 deletions Model/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,10 @@ public function placeOrder(GetOrderResponse $sveaOrder, Quote $quote)

//set payment
$payment = $quote->getPayment();
$customerReference = $sveaOrder->getCustomerReference();
if ($customerReference) {
$payment->setAdditionalInformation('svea_customer_reference', $customerReference);
}

//force payment method
if (!$payment->getMethod() || $payment->getMethod() != $this->_paymentMethod) {
Expand Down
23 changes: 17 additions & 6 deletions view/adminhtml/templates/payment/checkout/info.phtml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<?php
use Svea\Checkout\Block\Payment\Checkout\Info;
use Magento\Framework\Escaper;

/**
* @var $block \Svea\Checkout\Block\Payment\Checkout\Info
* @var Info $block
* @var Escaper $escaper
*/

?>
<div class="order-payment-method-name"><?php echo $block->escapeHtml($block->getMethod()->getTitle()); ?></div>
<div class="order-payment-method-name"><?= $escaper->escapeHtml($block->getMethod()->getTitle()); ?></div>
<table class="data-table admin__table-secondary">
<tr>
<th><?php echo $block->escapeHtml(__('Svea Checkout Order ID')); ?>:</th>
<td><?php echo $block->escapeHtml($block->getSveaCheckoutId()); ?></td>
<th><?= $escaper->escapeHtml(__('Svea Checkout Order ID')); ?>:</th>
<td><?= $escaper->escapeHtml($block->getSveaCheckoutId()); ?></td>
</tr>
<tr>
<th><?php echo $block->escapeHtml(__('Svea Payment Method')); ?>:</th>
<td><?php echo $block->escapeHtml($block->getSveaPaymentMethod()); ?></td>
<th><?= $escaper->escapeHtml(__('Svea Payment Method')); ?>:</th>
<td><?= $escaper->escapeHtml($block->getSveaPaymentMethod()); ?></td>
</tr>
<?php if ($block->getSveaCustomerReference()): ?>
<tr>
<th><?= $escaper->escapeHtml(__('Svea Customer Payment Reference')) ?>:</th>
<td><?= $escaper->escapeHtml($block->getSveaCustomerReference()) ?>
</tr>
<?php endif ?>
</table>

0 comments on commit be3a2e1

Please sign in to comment.