🔀 Merge branch 'trunk'

# Conflicts:
#	modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js
#	modules/ppcp-button/resources/js/modules/Helper/CheckoutMethodState.js
This commit is contained in:
Philipp Stracker 2024-07-24 18:42:57 +02:00
commit 9f39a58f07
No known key found for this signature in database
26 changed files with 662 additions and 110 deletions

View file

@ -183,6 +183,8 @@ class CheckoutBootstap {
const isSeparateButtonGateway = [ PaymentMethods.CARD_BUTTON ].includes(
currentPaymentMethod
);
const isGooglePayMethod =
currentPaymentMethod === PaymentMethods.GOOGLEPAY;
const isApplePayMethod =
currentPaymentMethod === PaymentMethods.APPLEPAY;
const isSavedCard = isCard && isSavedCardSelected();
@ -190,6 +192,7 @@ class CheckoutBootstap {
! isPaypal &&
! isCard &&
! isSeparateButtonGateway &&
! isGooglePayMethod &&
! isApplePayMethod;
const isFreeTrial = PayPalCommerceGateway.is_free_trial_cart;
const hasVaultedPaypal =
@ -234,6 +237,7 @@ class CheckoutBootstap {
}
}
setVisible( '#ppc-button-ppcp-googlepay', isGooglePayMethod );
setVisible( '#ppc-button-ppcp-applepay', isApplePayMethod );
jQuery( document.body ).trigger( 'ppcp_checkout_rendered' );

View file

@ -7,6 +7,7 @@ import { getPlanIdFromVariation } from '../Helper/Subscriptions';
import SimulateCart from '../Helper/SimulateCart';
import { strRemoveWord, strAddWord, throttle } from '../Helper/Utils';
import merge from 'deepmerge';
import { debounce } from '../../../../../ppcp-blocks/resources/js/Helper/debounce';
class SingleProductBootstap {
constructor( gateway, renderer, errorHandler ) {
@ -20,9 +21,13 @@ class SingleProductBootstap {
// Prevent simulate cart being called too many times in a burst.
this.simulateCartThrottled = throttle(
this.simulateCart,
this.simulateCart.bind( this ),
this.gateway.simulate_cart.throttling || 5000
);
this.debouncedHandleChange = debounce(
this.handleChange.bind( this ),
100
);
this.renderer.onButtonsInit(
this.gateway.button.wrapper,
@ -74,7 +79,7 @@ class SingleProductBootstap {
}
jQuery( document ).on( 'change', this.formSelector, () => {
this.handleChange();
this.debouncedHandleChange();
} );
this.mutationObserver.observe( form, {
childList: true,

View file

@ -3,6 +3,7 @@ export const PaymentMethods = {
CARDS: 'ppcp-credit-card-gateway',
OXXO: 'ppcp-oxxo-gateway',
CARD_BUTTON: 'ppcp-card-button-gateway',
GOOGLEPAY: 'ppcp-googlepay',
APPLEPAY: 'ppcp-applepay',
};