mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge branch 'trunk' into PCP-850-during-pay-pal-express-checkout-pui-is-available-as-a-payment-method
This commit is contained in:
commit
a86abb4cec
4 changed files with 24 additions and 4 deletions
|
@ -22,7 +22,8 @@ class Renderer {
|
|||
this.renderButtons(
|
||||
settings.button.wrapper,
|
||||
settings.button.style,
|
||||
contextConfig
|
||||
contextConfig,
|
||||
hasEnabledSeparateGateways
|
||||
);
|
||||
} else {
|
||||
// render each button separately
|
||||
|
@ -38,6 +39,7 @@ class Renderer {
|
|||
settings.button.wrapper,
|
||||
style,
|
||||
contextConfig,
|
||||
hasEnabledSeparateGateways,
|
||||
fundingSource
|
||||
);
|
||||
}
|
||||
|
@ -50,13 +52,14 @@ class Renderer {
|
|||
data.wrapper,
|
||||
data.style,
|
||||
contextConfig,
|
||||
hasEnabledSeparateGateways,
|
||||
fundingSource
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
renderButtons(wrapper, style, contextConfig, fundingSource = null) {
|
||||
if (! document.querySelector(wrapper) || this.isAlreadyRendered(wrapper, fundingSource) || 'undefined' === typeof paypal.Buttons ) {
|
||||
renderButtons(wrapper, style, contextConfig, hasEnabledSeparateGateways, fundingSource = null) {
|
||||
if (! document.querySelector(wrapper) || this.isAlreadyRendered(wrapper, fundingSource, hasEnabledSeparateGateways) || 'undefined' === typeof paypal.Buttons ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,7 +82,14 @@ class Renderer {
|
|||
this.renderedSources.add(wrapper + fundingSource ?? '');
|
||||
}
|
||||
|
||||
isAlreadyRendered(wrapper, fundingSource) {
|
||||
isAlreadyRendered(wrapper, fundingSource, hasEnabledSeparateGateways) {
|
||||
// Simply check that has child nodes when we do not need to render buttons separately,
|
||||
// this will reduce the risk of breaking with different themes/plugins
|
||||
// and on the cart page (where we also do not need to render separately), which may fully reload this part of the page.
|
||||
// Ideally we should also find a way to detect such full reloads and remove the corresponding keys from the set.
|
||||
if (!hasEnabledSeparateGateways) {
|
||||
return document.querySelector(wrapper).hasChildNodes();
|
||||
}
|
||||
return this.renderedSources.has(wrapper + fundingSource ?? '');
|
||||
}
|
||||
|
||||
|
|
|
@ -559,6 +559,12 @@ class SmartButton implements SmartButtonInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
|
||||
|
||||
if ( ! isset( $available_gateways[ $gateway_id ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The wrapper is needed for the loading spinner,
|
||||
// otherwise jQuery block() prevents buttons rendering.
|
||||
echo '<div class="ppc-button-wrapper"><div id="ppc-button-' . esc_attr( $gateway_id ) . '"></div></div>';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue