Skip to content

Commit 6c53aae

Browse files
Release version 5.4.0
1 parent f59477e commit 6c53aae

File tree

58 files changed

+3124
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3124
-200
lines changed

Api/Data/Quote/ExtendedShippingInformationInterface.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

Block/Cta/Cart.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\Cta;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class Cart extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
if ($this->config->getIsEnableCtaCartPage() && !$this->config->getIsEnableCartPageHeadless()) {
24+
return parent::_toHtml();
25+
}
26+
27+
return '';
28+
}
29+
}

Block/Cta/CartHeadless.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\Cta;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class CartHeadless extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
/** @var \Afterpay\Afterpay\ViewModel\Container\Cta\Headless $viewModel */
24+
$viewModel = $this->getViewModel();
25+
if ($viewModel && $viewModel->isContainerEnable() && $this->isEnabledForCart()) {
26+
return parent::_toHtml();
27+
}
28+
29+
return '';
30+
}
31+
public function isEnabledForCart(): bool
32+
{
33+
return $this->config->getIsEnableCtaCartPage() && $this->config->getIsEnableCartPageHeadless();
34+
}
35+
}

Block/Cta/MiniCartHeadless.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\Cta;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class MiniCartHeadless extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
/** @var \Afterpay\Afterpay\ViewModel\Container\Cta\Headless $viewModel */
24+
$viewModel = $this->getViewModel();
25+
if ($viewModel && $viewModel->isContainerEnable() && $this->isEnabledForMinicart()) {
26+
return parent::_toHtml();
27+
}
28+
29+
return '';
30+
}
31+
32+
public function isEnabledForMinicart(): bool
33+
{
34+
return $this->config->getIsEnableCtaMiniCart() && $this->config->getIsEnableMiniCartHeadless();
35+
}
36+
}

Block/Cta/Product.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\Cta;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class Product extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
if ($this->config->getIsEnableCtaProductPage() && !$this->config->getIsEnableProductPageHeadless()) {
24+
return parent::_toHtml();
25+
}
26+
27+
return '';
28+
}
29+
}

Block/Cta/ProductHeadless.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\Cta;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class ProductHeadless extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
/** @var \Afterpay\Afterpay\ViewModel\Container\Cta\Headless $viewModel */
24+
$viewModel = $this->getViewModel();
25+
if ($viewModel && $viewModel->isContainerEnable()
26+
&& $this->config->getIsEnableCtaProductPage() && $this->config->getIsEnableProductPageHeadless()) {
27+
return parent::_toHtml();
28+
}
29+
30+
return '';
31+
}
32+
}

Block/ExpressCheckout/Cart.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\ExpressCheckout;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class Cart extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
if ($this->config->getIsEnableExpressCheckoutCartPage() && !$this->config->getIsEnableCartPageHeadless()) {
24+
return parent::_toHtml();
25+
}
26+
27+
return '';
28+
}
29+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\ExpressCheckout;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class CartHeadless extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
/** @var \Afterpay\Afterpay\ViewModel\Container\ExpressCheckout\Headless $viewModel */
24+
$viewModel = $this->getViewModel();
25+
if ($viewModel && $viewModel->isContainerEnable() && $this->isEnabledForCart()) {
26+
return parent::_toHtml();
27+
}
28+
29+
return '';
30+
}
31+
public function isEnabledForCart(): bool
32+
{
33+
return $this->config->getIsEnableExpressCheckoutCartPage() && $this->config->getIsEnableCartPageHeadless();
34+
}
35+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\ExpressCheckout;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class MiniCartHeadless extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
/** @var \Afterpay\Afterpay\ViewModel\Container\ExpressCheckout\Headless $viewModel */
24+
$viewModel = $this->getViewModel();
25+
if ($viewModel && $viewModel->isContainerEnable() && $this->isEnabledForMinicart()) {
26+
return parent::_toHtml();
27+
}
28+
29+
return '';
30+
}
31+
32+
public function isEnabledForMinicart(): bool
33+
{
34+
return $this->config->getIsEnableExpressCheckoutMiniCart() && $this->config->getIsEnableMiniCartHeadless();
35+
}
36+
}

Block/ExpressCheckout/Product.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\ExpressCheckout;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class Product extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
if ($this->config->getIsEnableExpressCheckoutProductPage() && !$this->config->getIsEnableProductPageHeadless()) {
24+
return parent::_toHtml();
25+
}
26+
27+
return '';
28+
}
29+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Afterpay\Afterpay\Block\ExpressCheckout;
4+
5+
use Afterpay\Afterpay\Model\Config;
6+
use Magento\Framework\View\Element\Template;
7+
8+
class ProductHeadless extends Template
9+
{
10+
private Config $config;
11+
12+
public function __construct(
13+
Template\Context $context,
14+
Config $config,
15+
array $data = []
16+
) {
17+
parent::__construct($context, $data);
18+
$this->config = $config;
19+
}
20+
21+
protected function _toHtml()
22+
{
23+
/** @var \Afterpay\Afterpay\ViewModel\Container\ExpressCheckout\Headless $viewModel */
24+
$viewModel = $this->getViewModel();
25+
if ($viewModel && $viewModel->isContainerEnable()
26+
&& $this->config->getIsEnableExpressCheckoutProductPage() && $this->config->getIsEnableProductPageHeadless()) {
27+
return parent::_toHtml();
28+
}
29+
30+
return '';
31+
}
32+
}

Gateway/Request/ExpressCheckoutDataBuilder.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@
44

55
class ExpressCheckoutDataBuilder extends \Afterpay\Afterpay\Gateway\Request\Checkout\CheckoutDataBuilder
66
{
7-
private \Afterpay\Afterpay\Api\Data\Quote\ExtendedShippingInformationInterface $extendedShippingInformation;
8-
9-
public function __construct(
10-
\Magento\Framework\UrlInterface $url,
11-
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
12-
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
13-
\Afterpay\Afterpay\Model\CBT\CheckCBTCurrencyAvailabilityInterface $checkCBTCurrencyAvailability,
14-
\Afterpay\Afterpay\Api\Data\Quote\ExtendedShippingInformationInterface $extendedShippingInformation
15-
) {
16-
parent::__construct($url, $productRepository, $searchCriteriaBuilder, $checkCBTCurrencyAvailability);
17-
$this->extendedShippingInformation = $extendedShippingInformation;
18-
}
19-
207
public function build(array $buildSubject): array
218
{
229
/** @var \Magento\Quote\Model\Quote $quote */
@@ -26,10 +13,11 @@ public function build(array $buildSubject): array
2613
$amount = $isCBTCurrencyAvailable ? $quote->getGrandTotal() : $quote->getBaseGrandTotal();
2714
$currencyCode = $isCBTCurrencyAvailable ? $currentCurrencyCode : $quote->getBaseCurrencyCode();
2815
$popupOriginUrl = $buildSubject['popup_origin_url'];
29-
$lastSelectedShippingRate = $this->extendedShippingInformation->getParam(
30-
$quote,
31-
\Afterpay\Afterpay\Api\Data\Quote\ExtendedShippingInformationInterface::LAST_SELECTED_SHIPPING_RATE
32-
);
16+
17+
$lastSelectedShippingRate = null;
18+
if ($quote->getShippingAddress() && $quote->getShippingAddress()->getShippingMethod()) {
19+
$lastSelectedShippingRate = $quote->getShippingAddress()->getShippingMethod();
20+
}
3321

3422
$data = [
3523
'mode' => 'express',

0 commit comments

Comments
 (0)