Replace place order text in block

This commit is contained in:
Alex P 2023-11-16 16:01:32 +02:00
parent 2dcfd115a9
commit f232946afa
No known key found for this signature in database
GPG key ID: 54487A734A204D71
3 changed files with 35 additions and 22 deletions

View file

@ -323,6 +323,7 @@ if (config.usePlaceOrder && !config.scriptData.continuation) {
label: <div dangerouslySetInnerHTML={{__html: config.title}}/>,
content: <div dangerouslySetInnerHTML={{__html: config.description}}/>,
edit: <div dangerouslySetInnerHTML={{__html: config.description}}/>,
placeOrderButtonLabel: config.placeOrderButtonText,
ariaLabel: config.title,
canMakePayment: () => config.enabled,
supports: {

View file

@ -35,7 +35,8 @@ return array(
$container->get( 'blocks.settings.final_review_enabled' ),
$container->get( 'session.cancellation.view' ),
$container->get( 'session.handler' ),
$container->get( 'wcgateway.use-place-order-button' )
$container->get( 'wcgateway.use-place-order-button' ),
$container->get( 'wcgateway.place-order-button-text' )
);
},
'blocks.settings.final_review_enabled' => static function ( ContainerInterface $container ): bool {

View file

@ -94,6 +94,13 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
*/
protected $use_place_order;
/**
* The text for the standard "Place order" button.
*
* @var string
*/
protected $place_order_button_text;
/**
* Assets constructor.
*
@ -107,6 +114,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
* @param CancelView $cancellation_view The cancellation view.
* @param SessionHandler $session_handler The Session handler.
* @param bool $use_place_order Whether to use the standard "Place order" button.
* @param string $place_order_button_text The text for the standard "Place order" button.
*/
public function __construct(
string $module_url,
@ -118,19 +126,21 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
bool $final_review_enabled,
CancelView $cancellation_view,
SessionHandler $session_handler,
bool $use_place_order
bool $use_place_order,
string $place_order_button_text
) {
$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->use_place_order = $use_place_order;
$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->use_place_order = $use_place_order;
$this->place_order_button_text = $place_order_button_text;
}
/**
@ -185,20 +195,21 @@ 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,
'usePlaceOrder' => $this->use_place_order,
'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,
'usePlaceOrder' => $this->use_place_order,
'placeOrderButtonText' => $this->place_order_button_text,
'ajax' => array(
'update_shipping' => array(
'endpoint' => WC_AJAX::get_endpoint( UpdateShippingEndpoint::ENDPOINT ),
'nonce' => wp_create_nonce( UpdateShippingEndpoint::nonce() ),
),
),
'scriptData' => $script_data,
'scriptData' => $script_data,
);
}
}