Skip to content

Commit

Permalink
Release version 5.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
afterpayplugins committed Aug 26, 2024
1 parent f59477e commit 6c53aae
Show file tree
Hide file tree
Showing 58 changed files with 3,124 additions and 200 deletions.
23 changes: 0 additions & 23 deletions Api/Data/Quote/ExtendedShippingInformationInterface.php

This file was deleted.

29 changes: 29 additions & 0 deletions Block/Cta/Cart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\Cta;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class Cart extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
if ($this->config->getIsEnableCtaCartPage() && !$this->config->getIsEnableCartPageHeadless()) {
return parent::_toHtml();
}

return '';
}
}
35 changes: 35 additions & 0 deletions Block/Cta/CartHeadless.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\Cta;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class CartHeadless extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
/** @var \Afterpay\Afterpay\ViewModel\Container\Cta\Headless $viewModel */
$viewModel = $this->getViewModel();
if ($viewModel && $viewModel->isContainerEnable() && $this->isEnabledForCart()) {
return parent::_toHtml();
}

return '';
}
public function isEnabledForCart(): bool
{
return $this->config->getIsEnableCtaCartPage() && $this->config->getIsEnableCartPageHeadless();
}
}
36 changes: 36 additions & 0 deletions Block/Cta/MiniCartHeadless.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\Cta;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class MiniCartHeadless extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
/** @var \Afterpay\Afterpay\ViewModel\Container\Cta\Headless $viewModel */
$viewModel = $this->getViewModel();
if ($viewModel && $viewModel->isContainerEnable() && $this->isEnabledForMinicart()) {
return parent::_toHtml();
}

return '';
}

public function isEnabledForMinicart(): bool
{
return $this->config->getIsEnableCtaMiniCart() && $this->config->getIsEnableMiniCartHeadless();
}
}
29 changes: 29 additions & 0 deletions Block/Cta/Product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\Cta;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class Product extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
if ($this->config->getIsEnableCtaProductPage() && !$this->config->getIsEnableProductPageHeadless()) {
return parent::_toHtml();
}

return '';
}
}
32 changes: 32 additions & 0 deletions Block/Cta/ProductHeadless.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\Cta;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class ProductHeadless extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
/** @var \Afterpay\Afterpay\ViewModel\Container\Cta\Headless $viewModel */
$viewModel = $this->getViewModel();
if ($viewModel && $viewModel->isContainerEnable()
&& $this->config->getIsEnableCtaProductPage() && $this->config->getIsEnableProductPageHeadless()) {
return parent::_toHtml();
}

return '';
}
}
29 changes: 29 additions & 0 deletions Block/ExpressCheckout/Cart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\ExpressCheckout;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class Cart extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
if ($this->config->getIsEnableExpressCheckoutCartPage() && !$this->config->getIsEnableCartPageHeadless()) {
return parent::_toHtml();
}

return '';
}
}
35 changes: 35 additions & 0 deletions Block/ExpressCheckout/CartHeadless.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\ExpressCheckout;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class CartHeadless extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
/** @var \Afterpay\Afterpay\ViewModel\Container\ExpressCheckout\Headless $viewModel */
$viewModel = $this->getViewModel();
if ($viewModel && $viewModel->isContainerEnable() && $this->isEnabledForCart()) {
return parent::_toHtml();
}

return '';
}
public function isEnabledForCart(): bool
{
return $this->config->getIsEnableExpressCheckoutCartPage() && $this->config->getIsEnableCartPageHeadless();
}
}
36 changes: 36 additions & 0 deletions Block/ExpressCheckout/MiniCartHeadless.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\ExpressCheckout;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class MiniCartHeadless extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
/** @var \Afterpay\Afterpay\ViewModel\Container\ExpressCheckout\Headless $viewModel */
$viewModel = $this->getViewModel();
if ($viewModel && $viewModel->isContainerEnable() && $this->isEnabledForMinicart()) {
return parent::_toHtml();
}

return '';
}

public function isEnabledForMinicart(): bool
{
return $this->config->getIsEnableExpressCheckoutMiniCart() && $this->config->getIsEnableMiniCartHeadless();
}
}
29 changes: 29 additions & 0 deletions Block/ExpressCheckout/Product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\ExpressCheckout;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class Product extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
if ($this->config->getIsEnableExpressCheckoutProductPage() && !$this->config->getIsEnableProductPageHeadless()) {
return parent::_toHtml();
}

return '';
}
}
32 changes: 32 additions & 0 deletions Block/ExpressCheckout/ProductHeadless.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);

namespace Afterpay\Afterpay\Block\ExpressCheckout;

use Afterpay\Afterpay\Model\Config;
use Magento\Framework\View\Element\Template;

class ProductHeadless extends Template
{
private Config $config;

public function __construct(
Template\Context $context,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
}

protected function _toHtml()
{
/** @var \Afterpay\Afterpay\ViewModel\Container\ExpressCheckout\Headless $viewModel */
$viewModel = $this->getViewModel();
if ($viewModel && $viewModel->isContainerEnable()
&& $this->config->getIsEnableExpressCheckoutProductPage() && $this->config->getIsEnableProductPageHeadless()) {
return parent::_toHtml();
}

return '';
}
}
22 changes: 5 additions & 17 deletions Gateway/Request/ExpressCheckoutDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@

class ExpressCheckoutDataBuilder extends \Afterpay\Afterpay\Gateway\Request\Checkout\CheckoutDataBuilder
{
private \Afterpay\Afterpay\Api\Data\Quote\ExtendedShippingInformationInterface $extendedShippingInformation;

public function __construct(
\Magento\Framework\UrlInterface $url,
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
\Afterpay\Afterpay\Model\CBT\CheckCBTCurrencyAvailabilityInterface $checkCBTCurrencyAvailability,
\Afterpay\Afterpay\Api\Data\Quote\ExtendedShippingInformationInterface $extendedShippingInformation
) {
parent::__construct($url, $productRepository, $searchCriteriaBuilder, $checkCBTCurrencyAvailability);
$this->extendedShippingInformation = $extendedShippingInformation;
}

public function build(array $buildSubject): array
{
/** @var \Magento\Quote\Model\Quote $quote */
Expand All @@ -26,10 +13,11 @@ public function build(array $buildSubject): array
$amount = $isCBTCurrencyAvailable ? $quote->getGrandTotal() : $quote->getBaseGrandTotal();
$currencyCode = $isCBTCurrencyAvailable ? $currentCurrencyCode : $quote->getBaseCurrencyCode();
$popupOriginUrl = $buildSubject['popup_origin_url'];
$lastSelectedShippingRate = $this->extendedShippingInformation->getParam(
$quote,
\Afterpay\Afterpay\Api\Data\Quote\ExtendedShippingInformationInterface::LAST_SELECTED_SHIPPING_RATE
);

$lastSelectedShippingRate = null;
if ($quote->getShippingAddress() && $quote->getShippingAddress()->getShippingMethod()) {
$lastSelectedShippingRate = $quote->getShippingAddress()->getShippingMethod();
}

$data = [
'mode' => 'express',
Expand Down
Loading

0 comments on commit 6c53aae

Please sign in to comment.