-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(checkout): allow multiple address (#738)
* fix(checkout): allow multiple address * fix(pix): hide qrcode when order has not been created * feat(success): show pix on multishipping success page
- Loading branch information
Showing
5 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace OpenPix\Pix\Block\Multishipping\Checkout; | ||
|
||
class Success extends \Magento\Multishipping\Block\Checkout\Success | ||
{ | ||
protected $checkoutSession; | ||
protected $customerSession; | ||
protected $_orderFactory; | ||
protected $_helperData; | ||
|
||
const LOG_NAME = 'pix_multishipping_checkout_success_block'; | ||
|
||
public function __construct( | ||
\Magento\Checkout\Model\Session $checkoutSession, | ||
\Magento\Customer\Model\Session $customerSession, | ||
\Magento\Framework\View\Element\Template\Context $context, | ||
\Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping, | ||
\Magento\Sales\Model\OrderFactory $orderFactory, | ||
\OpenPix\Pix\Helper\Data $helper, | ||
array $data = [], | ||
) { | ||
parent::__construct($context, $multishipping, $data); | ||
|
||
$this->checkoutSession = $checkoutSession; | ||
$this->customerSession = $customerSession; | ||
$this->_helperData = $helper; | ||
$this->_orderFactory = $orderFactory; | ||
} | ||
|
||
public function getQrCodes() | ||
{ | ||
$orderIds = $this->_session->getOrderIds(); | ||
|
||
if (! $orderIds || ! is_array($orderIds)) { | ||
return []; | ||
} | ||
|
||
$qrCodes = []; | ||
|
||
foreach ($orderIds as $orderId) { | ||
$order = $this->_orderFactory->create() | ||
->loadByIncrementId($orderId); | ||
|
||
if (! $order->getId()) { | ||
continue; | ||
} | ||
|
||
$correlationID = $order->getOpenpixCorrelationid(); | ||
|
||
if (empty($correlationID)) { | ||
continue; | ||
} | ||
|
||
$qrCodes[] = [ | ||
'paymentLinkUrl' => $order->getOpenpixPaymentlinkurl(), | ||
'brCodeImage' => $order->getOpenpixQrcodeimage(), | ||
'brCode' => $order->getOpenpixBrcode(), | ||
'correlationID' => $correlationID, | ||
]; | ||
} | ||
|
||
return $qrCodes; | ||
} | ||
|
||
public function getAppID(): string | ||
{ | ||
$appID = $this->_helperData->getAppID(); | ||
|
||
if (isset($appID)) { | ||
return $appID; | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
public function getPluginSrc(): string | ||
{ | ||
return $this->_helperData->getOpenPixPluginUrlScript(); | ||
} | ||
|
||
public function getCustomerId() | ||
{ | ||
return $this->customerSession->getCustomer()->getId(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Pix/view/frontend/layout/multishipping_checkout_success.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0"?> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<head> | ||
<script src="OpenPix_Pix::js/copytoclipboard.js"/> | ||
</head> | ||
<body> | ||
<referenceBlock name="checkout_success"> | ||
<block class="OpenPix\Pix\Block\Multishipping\Checkout\Success" name="openpix.info.payment.multishipping" template="OpenPix_Pix::multishipping/checkout/success.phtml" /> | ||
</referenceBlock> | ||
</body> | ||
</page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
<?php | ||
|
||
/** | ||
* @var $block \OpenPix\Pix\Block\Info\Pix | ||
* @var \OpenPix\Pix\Block\Info\Pix $block | ||
*/ | ||
|
||
$order = $block->getInfo()->getOrder(); | ||
?> | ||
|
||
<dl class="payment-method purchase order"> | ||
<dt class="title"><?= $block->escapeHtml($block->getMethod()->getTitle()) ?></dt> | ||
<dd class="content"> | ||
<img src="<?= $block->getInfo()->getOrder()->getOpenpixQrcodeimage() ?>" width="200" height="200" /> | ||
<?php if ($order): ?> | ||
<img src="<?= $order->getOpenpixQrcodeimage() ?>" width="200" height="200" /> | ||
<?php endif; ?> | ||
</dd> | ||
</dl> | ||
</dl> |
24 changes: 24 additions & 0 deletions
24
Pix/view/frontend/templates/multishipping/checkout/success.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
/** @var $block \Magento\Checkout\Block\Onepage\Success */ | ||
|
||
$src = $block->getPluginSrc(); | ||
$qrCodes = $block->getQrCodes(); | ||
$correlationID = $block->getCorrelationID(); | ||
$appID = $block->getAppID(); | ||
?> | ||
|
||
<?php foreach ($qrCodes as $qrCode): ?> | ||
<div class="actions-toolbar flex"> | ||
<div id="openpix-order" data-appid="<?= $appID ?>" data-correlationID="<?= $qrCode['correlationID'] ?>"></div> | ||
|
||
<script> | ||
require(["jquery", "OpenPix"], function($, pym) {}); | ||
</script> | ||
</div> | ||
<?php endforeach; ?> |