From 21bba80f490d213f0faad22c30613401738c936a Mon Sep 17 00:00:00 2001 From: Alex P Date: Mon, 27 Mar 2023 10:59:08 +0300 Subject: [PATCH] Check the current method in block --- modules/ppcp-blocks/resources/js/checkout-block.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-blocks/resources/js/checkout-block.js b/modules/ppcp-blocks/resources/js/checkout-block.js index a9b8b21dc..1afbc9e1b 100644 --- a/modules/ppcp-blocks/resources/js/checkout-block.js +++ b/modules/ppcp-blocks/resources/js/checkout-block.js @@ -12,6 +12,7 @@ const PayPalComponent = ({ onError, eventRegistration, emitResponse, + activePaymentMethod, }) => { const {onPaymentSetup} = eventRegistration; const {responseTypes} = emitResponse; @@ -110,6 +111,10 @@ const PayPalComponent = ({ }; useEffect(() => { + if (activePaymentMethod !== config.id) { + return; + } + const unsubscribeProcessing = onPaymentSetup(() => { const shippingAddress = paypalOrderToWcShippingAddress(paypalOrder); let billingAddress = paypalPayerToWc(paypalOrder.payer); @@ -132,7 +137,7 @@ const PayPalComponent = ({ return () => { unsubscribeProcessing(); }; - }, [onPaymentSetup, paypalOrder]); + }, [onPaymentSetup, paypalOrder, activePaymentMethod]); if (!loaded) { return null;