4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
+ declare (strict_types=1 );
8
+
7
9
namespace Magento \PayPal \Block \PayLater ;
8
10
9
11
use Magento \Checkout \Block \Checkout \LayoutProcessorInterface ;
@@ -46,6 +48,10 @@ public function __construct(PayLaterConfig $payLaterConfig, SdkUrl $sdkUrl)
46
48
public function process ($ jsLayout )
47
49
{
48
50
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
+
49
55
return $ jsLayout ;
50
56
}
51
57
@@ -57,20 +63,26 @@ public function process($jsLayout)
57
63
['children ' ]['payment ' ]['children ' ]['payments-list ' ]['children ' ]['before-place-order ' ]['children ' ]
58
64
['paylater-place-order ' ];
59
65
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 = [
67
68
'sdkUrl ' => $ this ->sdkUrl ->getUrl (),
68
- 'attributes ' => $ attributes ,
69
69
'displayAmount ' => true ,
70
70
'amountComponentConfig ' => [
71
71
'component ' => 'Magento_Paypal/js/view/amountProviders/checkout '
72
72
]
73
73
];
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 ;
74
86
}
75
87
76
88
return $ jsLayout ;
0 commit comments