Add addition Place Order description in block

This commit is contained in:
Alex P 2023-11-29 17:01:55 +02:00
parent 9d933b2b73
commit de1ab5b7bf
No known key found for this signature in database
GPG key ID: 54487A734A204D71
4 changed files with 57 additions and 28 deletions

View file

@ -321,11 +321,19 @@ const PayPalComponent = ({
const features = ['products'];
if ((config.addPlaceOrderMethod || config.usePlaceOrder) && !config.scriptData.continuation) {
let descriptionElement = <div dangerouslySetInnerHTML={{__html: config.description}}></div>;
if (config.placeOrderButtonDescription) {
descriptionElement = <div>
<p dangerouslySetInnerHTML={{__html: config.description}}></p>
<p style={{textAlign: 'center'}} className={'ppcp-place-order-description'} dangerouslySetInnerHTML={{__html: config.placeOrderButtonDescription}}></p>
</div>;
}
registerPaymentMethod({
name: config.id,
label: <div dangerouslySetInnerHTML={{__html: config.title}}/>,
content: <div dangerouslySetInnerHTML={{__html: config.description}}/>,
edit: <div dangerouslySetInnerHTML={{__html: config.description}}/>,
content: descriptionElement,
edit: descriptionElement,
placeOrderButtonLabel: config.placeOrderButtonText,
ariaLabel: config.title,
canMakePayment: () => config.enabled,

View file

@ -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' )
);
},

View file

@ -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,6 +153,7 @@ 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;
@ -160,6 +169,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
$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;
}
@ -232,6 +242,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
'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(

View file

@ -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 {