From 9d933b2b73f4c7db72d861487f4085a29a748e43 Mon Sep 17 00:00:00 2001 From: Alex P Date: Wed, 29 Nov 2023 16:59:59 +0200 Subject: [PATCH 1/3] Change Place Order text --- modules/ppcp-wc-gateway/services.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 913eaee9f..0f53c766d 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -1180,7 +1180,7 @@ return array( */ return apply_filters( 'woocommerce_paypal_payments_place_order_button_text', - __( 'Pay with PayPal', 'woocommerce-paypal-payments' ) + __( 'Proceed to PayPal', 'woocommerce-paypal-payments' ) ); }, From de1ab5b7bff302757d2a32a7a100cc2dee81c3d1 Mon Sep 17 00:00:00 2001 From: Alex P Date: Wed, 29 Nov 2023 17:01:55 +0200 Subject: [PATCH 2/3] Add addition Place Order description in block --- .../resources/js/checkout-block.js | 12 +++- modules/ppcp-blocks/services.php | 1 + .../ppcp-blocks/src/PayPalPaymentMethod.php | 63 +++++++++++-------- modules/ppcp-wc-gateway/services.php | 9 +++ 4 files changed, 57 insertions(+), 28 deletions(-) diff --git a/modules/ppcp-blocks/resources/js/checkout-block.js b/modules/ppcp-blocks/resources/js/checkout-block.js index 215e92a35..971f79f1b 100644 --- a/modules/ppcp-blocks/resources/js/checkout-block.js +++ b/modules/ppcp-blocks/resources/js/checkout-block.js @@ -321,11 +321,19 @@ const PayPalComponent = ({ const features = ['products']; if ((config.addPlaceOrderMethod || config.usePlaceOrder) && !config.scriptData.continuation) { + let descriptionElement =
; + if (config.placeOrderButtonDescription) { + descriptionElement =
+

+

+
; + } + registerPaymentMethod({ name: config.id, label:
, - content:
, - edit:
, + content: descriptionElement, + edit: descriptionElement, placeOrderButtonLabel: config.placeOrderButtonText, ariaLabel: config.title, canMakePayment: () => config.enabled, diff --git a/modules/ppcp-blocks/services.php b/modules/ppcp-blocks/services.php index 8ccd41724..e2fb01b64 100644 --- a/modules/ppcp-blocks/services.php +++ b/modules/ppcp-blocks/services.php @@ -38,6 +38,7 @@ return array( $container->get( 'blocks.add-place-order-method' ), $container->get( 'wcgateway.use-place-order-button' ), $container->get( 'wcgateway.place-order-button-text' ), + $container->get( 'wcgateway.place-order-button-description' ), $container->get( 'wcgateway.all-funding-sources' ) ); }, diff --git a/modules/ppcp-blocks/src/PayPalPaymentMethod.php b/modules/ppcp-blocks/src/PayPalPaymentMethod.php index fe0a381c6..d7526e0ba 100644 --- a/modules/ppcp-blocks/src/PayPalPaymentMethod.php +++ b/modules/ppcp-blocks/src/PayPalPaymentMethod.php @@ -108,6 +108,13 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType { */ protected $place_order_button_text; + /** + * The text for additional "Place order" description. + * + * @var string + */ + protected $place_order_button_description; + /** * All existing funding sources for PayPal buttons. * @@ -130,6 +137,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType { * @param bool $add_place_order_method Whether to create a non-express method with the standard "Place order" button. * @param bool $use_place_order Whether to use the standard "Place order" button instead of PayPal buttons. * @param string $place_order_button_text The text for the standard "Place order" button. + * @param string $place_order_button_description The text for additional "Place order" description. * @param array $all_funding_sources All existing funding sources for PayPal buttons. */ public function __construct( @@ -145,22 +153,24 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType { bool $add_place_order_method, bool $use_place_order, string $place_order_button_text, + string $place_order_button_description, array $all_funding_sources ) { - $this->name = PayPalGateway::ID; - $this->module_url = $module_url; - $this->version = $version; - $this->smart_button = $smart_button; - $this->plugin_settings = $plugin_settings; - $this->settings_status = $settings_status; - $this->gateway = $gateway; - $this->final_review_enabled = $final_review_enabled; - $this->cancellation_view = $cancellation_view; - $this->session_handler = $session_handler; - $this->add_place_order_method = $add_place_order_method; - $this->use_place_order = $use_place_order; - $this->place_order_button_text = $place_order_button_text; - $this->all_funding_sources = $all_funding_sources; + $this->name = PayPalGateway::ID; + $this->module_url = $module_url; + $this->version = $version; + $this->smart_button = $smart_button; + $this->plugin_settings = $plugin_settings; + $this->settings_status = $settings_status; + $this->gateway = $gateway; + $this->final_review_enabled = $final_review_enabled; + $this->cancellation_view = $cancellation_view; + $this->session_handler = $session_handler; + $this->add_place_order_method = $add_place_order_method; + $this->use_place_order = $use_place_order; + $this->place_order_button_text = $place_order_button_text; + $this->place_order_button_description = $place_order_button_description; + $this->all_funding_sources = $all_funding_sources; } /** @@ -223,23 +233,24 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType { ); return array( - 'id' => $this->gateway->id, - 'title' => $this->gateway->title, - 'description' => $this->gateway->description, - 'enabled' => $this->settings_status->is_smart_button_enabled_for_location( $script_data['context'] ), - 'fundingSource' => $this->session_handler->funding_source(), - 'finalReviewEnabled' => $this->final_review_enabled, - 'addPlaceOrderMethod' => $this->add_place_order_method, - 'usePlaceOrder' => $this->use_place_order, - 'placeOrderButtonText' => $this->place_order_button_text, - 'enabledFundingSources' => $funding_sources, - 'ajax' => array( + 'id' => $this->gateway->id, + 'title' => $this->gateway->title, + 'description' => $this->gateway->description, + 'enabled' => $this->settings_status->is_smart_button_enabled_for_location( $script_data['context'] ), + 'fundingSource' => $this->session_handler->funding_source(), + 'finalReviewEnabled' => $this->final_review_enabled, + 'addPlaceOrderMethod' => $this->add_place_order_method, + 'usePlaceOrder' => $this->use_place_order, + 'placeOrderButtonText' => $this->place_order_button_text, + 'placeOrderButtonDescription' => $this->place_order_button_description, + 'enabledFundingSources' => $funding_sources, + 'ajax' => array( 'update_shipping' => array( 'endpoint' => WC_AJAX::get_endpoint( UpdateShippingEndpoint::ENDPOINT ), 'nonce' => wp_create_nonce( UpdateShippingEndpoint::nonce() ), ), ), - 'scriptData' => $script_data, + 'scriptData' => $script_data, ); } } diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index 0f53c766d..ae82d7338 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -1183,6 +1183,15 @@ return array( __( 'Proceed to PayPal', 'woocommerce-paypal-payments' ) ); }, + 'wcgateway.place-order-button-description' => function ( ContainerInterface $container ) : string { + /** + * The text for additional description, when the "Place order" button mode is enabled. + */ + return apply_filters( + 'woocommerce_paypal_payments_place_order_button_description', + __( 'Clicking "Proceed to PayPal", will redirect you to PayPal to complete your purchase.', 'woocommerce-paypal-payments' ) + ); + }, 'wcgateway.helper.vaulting-scope' => static function ( ContainerInterface $container ): bool { try { From 9542a1b920811de1b2e13006119362b0ff9efb1a Mon Sep 17 00:00:00 2001 From: Alex P Date: Wed, 29 Nov 2023 18:40:23 +0200 Subject: [PATCH 3/3] Fix text --- modules/ppcp-wc-gateway/services.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index ae82d7338..9cd0e8eaf 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -1189,7 +1189,7 @@ return array( */ return apply_filters( 'woocommerce_paypal_payments_place_order_button_description', - __( 'Clicking "Proceed to PayPal", will redirect you to PayPal to complete your purchase.', 'woocommerce-paypal-payments' ) + __( 'Clicking "Proceed to PayPal" will redirect you to PayPal to complete your purchase.', 'woocommerce-paypal-payments' ) ); },