Skip to content

Commit 668cbdc

Browse files
committed
MC-42208: Pay Later message doesn't display on Bundle Product page
1 parent 6927912 commit 668cbdc

File tree

2 files changed

+45
-14
lines changed

2 files changed

+45
-14
lines changed

app/code/Magento/Paypal/Model/PayLaterConfig.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ class PayLaterConfig
4141

4242
/**
4343
* @param ScopeConfigInterface $scopeConfig
44-
* @param Config $config
44+
* @param ConfigFactory $configFactory
4545
*/
4646
public function __construct(
4747
ScopeConfigInterface $scopeConfig,
48-
Config $config
48+
ConfigFactory $configFactory
4949
) {
5050
$this->scopeConfig = $scopeConfig;
51-
$this->config = $config;
51+
$this->config = $configFactory->create();;
5252
}
5353

5454
/**
@@ -75,8 +75,13 @@ public function isEnabled(string $placement): bool
7575
*/
7676
private function isPPCreditEnabled()
7777
{
78-
return $this->config->isMethodAvailable(Config::METHOD_WPP_BML)
79-
|| $this->config->isMethodAvailable(Config::METHOD_WPS_BML)
78+
$isEnabled = false;
79+
if ($this->config->setMethod(Config::METHOD_EXPRESS)->getValue('in_context')) {
80+
$disabledFunding = $this->config->getValue('disable_funding_options');
81+
$isEnabled = $disabledFunding ? strpos($disabledFunding, 'CREDIT') === false : true;
82+
}
83+
84+
return $isEnabled || $this->config->isMethodAvailable(Config::METHOD_WPP_BML)
8085
|| $this->config->isMethodAvailable(Config::METHOD_WPP_PE_BML);
8186
}
8287

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

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,43 @@ define([
2525
sdkUrl: '',
2626
priceBoxSelector: '.price-box',
2727
qtyFieldSelector: '#product_addtocart_form [name="qty"]',
28+
refreshSelector: '',
2829
displayAmount: true,
2930
attributes: {}
3031
},
3132
amount: ko.observable(),
3233
qty: 1,
3334
price: 0,
35+
paypal: null,
3436

3537
/**
3638
* Initialize
3739
*
3840
* @returns {*}
3941
*/
4042
initialize: function () {
41-
var priceBox, qty;
43+
var priceBox;
4244

4345
this._super();
44-
this.loadPayPalSdk(this.sdkUrl);
46+
this.loadPayPalSdk()
47+
.then(this._setPayPalObject.bind(this));
4548

4649
if (this.displayAmount) {
4750
priceBox = $(this.priceBoxSelector);
51+
priceBox.on('priceUpdated', this._onPriceChange.bind(this));
4852

4953
if (priceBox.priceBox('option') &&
50-
priceBox.priceBox('option').prices
54+
priceBox.priceBox('option').prices &&
55+
priceBox.priceBox('option').prices.finalPrice
5156
) {
5257
this.price = priceBox.priceBox('option').prices.finalPrice.amount;
53-
priceBox.on('priceUpdated', this._onPriceChange.bind(this));
5458
}
5559

56-
qty = $(this.qtyFieldSelector);
57-
qty.on('change', this._onQtyChange.bind(this));
60+
$(this.qtyFieldSelector).on('change', this._onQtyChange.bind(this));
61+
62+
if (this.refreshSelector) {
63+
$(this.refreshSelector).on('click', this._refreshMessages.bind(this));
64+
}
5865

5966
this._updateAmount();
6067
}
@@ -113,11 +120,30 @@ define([
113120

114121
/**
115122
* Load PP SDK with preconfigured options
123+
*/
124+
loadPayPalSdk: function () {
125+
return paypalSdk(this.sdkUrl);
126+
},
127+
128+
/**
129+
* Set reference to paypal Sdk object
130+
*
131+
* @param {Object} paypal
132+
* @private
133+
*/
134+
_setPayPalObject: function (paypal) {
135+
this.paypal = paypal;
136+
},
137+
138+
/**
139+
* Render messages
116140
*
117-
* @param {String} sdkUrl
141+
* @private
118142
*/
119-
loadPayPalSdk: function (sdkUrl) {
120-
paypalSdk(sdkUrl);
143+
_refreshMessages: function () {
144+
if (this.paypal) {
145+
this.paypal.Messages.render();
146+
}
121147
}
122148
});
123149
});

0 commit comments

Comments
 (0)