Skip to content

Commit 3098ee3

Browse files
MC-41657: Reflect changed price: Checkout
- change class attribute and allow layout processor to get values from xml
1 parent ab532bd commit 3098ee3

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

app/code/Magento/Paypal/Block/PayLater/LayoutProcessor.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PayPal\Block\PayLater;
810

911
use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
@@ -46,6 +48,10 @@ public function __construct(PayLaterConfig $payLaterConfig, SdkUrl $sdkUrl)
4648
public function process($jsLayout)
4749
{
4850
if (!$this->payLaterConfig->isEnabled(PayLaterConfig::CHECKOUT_PAYMENT_PLACEMENT)) {
51+
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']
52+
['children']['payment']['children']['payments-list']['children']['before-place-order']['children']
53+
['paylater-place-order']);
54+
4955
return $jsLayout;
5056
}
5157

@@ -57,20 +63,26 @@ public function process($jsLayout)
5763
['children']['payment']['children']['payments-list']['children']['before-place-order']['children']
5864
['paylater-place-order'];
5965

60-
$attributes = $this->payLaterConfig->getSectionConfig(
61-
PayLaterConfig::CHECKOUT_PAYMENT_PLACEMENT,
62-
PayLaterConfig::CONFIG_KEY_STYLE
63-
);
64-
$attributes['data-pp-placement'] = self::PLACEMENT;
65-
66-
$payLaterPlaceOrder['config'] = [
66+
$componentConfig = $payLaterPlaceOrder['config'] ?? [];
67+
$defaultConfig = [
6768
'sdkUrl' => $this->sdkUrl->getUrl(),
68-
'attributes' => $attributes,
6969
'displayAmount' => true,
7070
'amountComponentConfig' => [
7171
'component' => 'Magento_Paypal/js/view/amountProviders/checkout'
7272
]
7373
];
74+
$config = array_replace($defaultConfig, $componentConfig);
75+
76+
$attributes = $this->payLaterConfig->getSectionConfig(
77+
PayLaterConfig::CHECKOUT_PAYMENT_PLACEMENT,
78+
PayLaterConfig::CONFIG_KEY_STYLE
79+
);
80+
$attributes['data-pp-placement'] = self::PLACEMENT;
81+
82+
$componentAttributes = $payLaterPlaceOrder['config']['attributes'] ?? [];
83+
$config['attributes'] = array_replace($attributes, $componentAttributes);
84+
85+
$payLaterPlaceOrder['config'] = $config;
7486
}
7587

7688
return $jsLayout;

app/code/Magento/Paypal/view/frontend/web/js/view/paylater.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ define([
2424
defaults: {
2525
template: 'Magento_Paypal/paylater',
2626
sdkUrl: '',
27-
attributes: {},
27+
attributes: {
28+
class: 'pay-later-message'
29+
},
2830
refreshSelector: '',
2931
displayAmount: false,
3032
amountComponentConfig: {

app/code/Magento/Paypal/view/frontend/web/template/paylater.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66
-->
7-
<div class="pay-later-message" data-pp-message data-bind="attr: {
7+
<div data-pp-message data-bind="attr: {
8+
'class': getAttribute('class'),
89
'data-pp-amount': amount,
910
'data-pp-placement': getAttribute('data-pp-placement'),
1011
'data-pp-style-layout': getAttribute('data-pp-style-layout'),

0 commit comments

Comments
 (0)