From 7f553087c62c0be4a2198db295ad7596e70fe14c Mon Sep 17 00:00:00 2001 From: dinamiko Date: Tue, 20 Apr 2021 14:27:37 +0200 Subject: [PATCH] Display error message when order is not created, do not handle place order button display when acdc is not enabled --- .../ppcp-api-client/src/Endpoint/class-orderendpoint.php | 6 +++++- .../js/modules/ContextBootstrap/CheckoutBootstap.js | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-api-client/src/Endpoint/class-orderendpoint.php b/modules/ppcp-api-client/src/Endpoint/class-orderendpoint.php index dd2003b36..c0853b6f2 100644 --- a/modules/ppcp-api-client/src/Endpoint/class-orderendpoint.php +++ b/modules/ppcp-api-client/src/Endpoint/class-orderendpoint.php @@ -231,7 +231,11 @@ class OrderEndpoint { $response = $this->request( $url, $args ); if ( is_wp_error( $response ) ) { $error = new RuntimeException( - __( 'Could not create order.', 'woocommerce-paypal-payments' ) + sprintf( + // translators: %s is the error message. + __( 'Could not create order: %s', 'woocommerce-paypal-payments' ), + $response->get_error_message() + ) ); $this->logger->log( 'warning', diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js index f11a3e054..e4558e34a 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js @@ -89,6 +89,12 @@ class CheckoutBootstap { } displayPlaceOrderButtonForSavedCreditCards() { + const currentPaymentMethod = jQuery( + 'input[name="payment_method"]:checked').val(); + if (currentPaymentMethod !== 'ppcp-credit-card-gateway') { + return; + } + if (jQuery('#saved-credit-card').length && jQuery('#saved-credit-card').val() !== '') { this.renderer.hideButtons(this.gateway.button.wrapper) this.renderer.hideButtons(this.gateway.messages.wrapper)