🐛 Show PayPal payment button in ACDC-only mode

When only using ACDC without smart buttons, this commit makes the default “Proceed to PayPal” button visible
This commit is contained in:
Philipp Stracker 2024-11-28 13:04:10 +01:00
parent 47b57058fb
commit 5e4157d488
No known key found for this signature in database
2 changed files with 15 additions and 1 deletions

View file

@ -211,6 +211,7 @@ class CheckoutBootstap {
const isFreeTrial = PayPalCommerceGateway.is_free_trial_cart; const isFreeTrial = PayPalCommerceGateway.is_free_trial_cart;
const hasVaultedPaypal = const hasVaultedPaypal =
PayPalCommerceGateway.vaulted_paypal_email !== ''; PayPalCommerceGateway.vaulted_paypal_email !== '';
const useSmartButtons = this.renderer.useSmartButtons ?? true;
const paypalButtonWrappers = { const paypalButtonWrappers = {
...Object.entries( PayPalCommerceGateway.separate_buttons ).reduce( ...Object.entries( PayPalCommerceGateway.separate_buttons ).reduce(
@ -225,7 +226,8 @@ class CheckoutBootstap {
this.standardOrderButtonSelector, this.standardOrderButtonSelector,
( isPaypal && isFreeTrial && hasVaultedPaypal ) || ( isPaypal && isFreeTrial && hasVaultedPaypal ) ||
isNotOurGateway || isNotOurGateway ||
isSavedCard, isSavedCard ||
( isPaypal && ! useSmartButtons ),
'ppcp-hidden' 'ppcp-hidden'
); );
setVisible( '.ppcp-vaulted-paypal-details', isPaypal ); setVisible( '.ppcp-vaulted-paypal-details', isPaypal );

View file

@ -28,6 +28,18 @@ class Renderer {
this.reloadEventName = 'ppcp-reload-buttons'; this.reloadEventName = 'ppcp-reload-buttons';
} }
/**
* Determine is PayPal smart buttons are used by inspecting the existing plugin configuration:
* If the url-param "components" contains a "buttons" element, smart buttons are enabled.
*
* @return {boolean} True, if smart buttons are present on the page.
*/
get useSmartButtons() {
const components = this.defaultSettings?.url_params?.components || '';
return components.split( ',' ).includes( 'buttons' );
}
render( render(
contextConfig, contextConfig,
settingsOverride = {}, settingsOverride = {},