mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Add place order method in block together with express
This commit is contained in:
parent
ea35893a82
commit
758bb5da29
3 changed files with 53 additions and 31 deletions
|
@ -320,7 +320,7 @@ const PayPalComponent = ({
|
|||
|
||||
const features = ['products'];
|
||||
|
||||
if (config.usePlaceOrder && !config.scriptData.continuation) {
|
||||
if ((config.addPlaceOrderMethod || config.usePlaceOrder) && !config.scriptData.continuation) {
|
||||
registerPaymentMethod({
|
||||
name: config.id,
|
||||
label: <div dangerouslySetInnerHTML={{__html: config.title}}/>,
|
||||
|
@ -333,8 +333,9 @@ if (config.usePlaceOrder && !config.scriptData.continuation) {
|
|||
features: features,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
if (config.scriptData.continuation) {
|
||||
}
|
||||
|
||||
if (config.scriptData.continuation) {
|
||||
registerPaymentMethod({
|
||||
name: config.id,
|
||||
label: <div dangerouslySetInnerHTML={{__html: config.title}}/>,
|
||||
|
@ -346,7 +347,7 @@ if (config.usePlaceOrder && !config.scriptData.continuation) {
|
|||
features: [...features, 'ppcp_continuation'],
|
||||
},
|
||||
});
|
||||
} else {
|
||||
} else if (!config.usePlaceOrder) {
|
||||
const paypalScriptPromise = loadPaypalScriptPromise(config.scriptData);
|
||||
|
||||
for (const fundingSource of ['paypal', ...config.enabledFundingSources]) {
|
||||
|
@ -367,5 +368,4 @@ if (config.usePlaceOrder && !config.scriptData.continuation) {
|
|||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ return array(
|
|||
$container->get( 'blocks.settings.final_review_enabled' ),
|
||||
$container->get( 'session.cancellation.view' ),
|
||||
$container->get( 'session.handler' ),
|
||||
$container->get( 'blocks.add-place-order-method' ),
|
||||
$container->get( 'wcgateway.use-place-order-button' ),
|
||||
$container->get( 'wcgateway.place-order-button-text' ),
|
||||
$container->get( 'wcgateway.all-funding-sources' )
|
||||
|
@ -57,4 +58,14 @@ return array(
|
|||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
|
||||
'blocks.add-place-order-method' => function ( ContainerInterface $container ) : bool {
|
||||
/**
|
||||
* Whether to create a non-express method with the standard "Place order" button redirecting to PayPal.
|
||||
*/
|
||||
return apply_filters(
|
||||
'woocommerce_paypal_payments_blocks_add_place_order_method',
|
||||
true
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -88,7 +88,14 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
private $session_handler;
|
||||
|
||||
/**
|
||||
* Whether to use the standard "Place order" button.
|
||||
* Whether to create a non-express method with the standard "Place order" button.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $add_place_order_method;
|
||||
|
||||
/**
|
||||
* Whether to use the standard "Place order" button instead of PayPal buttons.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
|
@ -120,7 +127,8 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
* @param bool $final_review_enabled Whether the final review is enabled.
|
||||
* @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 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 array $all_funding_sources All existing funding sources for PayPal buttons.
|
||||
*/
|
||||
|
@ -134,6 +142,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
bool $final_review_enabled,
|
||||
CancelView $cancellation_view,
|
||||
SessionHandler $session_handler,
|
||||
bool $add_place_order_method,
|
||||
bool $use_place_order,
|
||||
string $place_order_button_text,
|
||||
array $all_funding_sources
|
||||
|
@ -148,6 +157,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
$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;
|
||||
|
@ -219,6 +229,7 @@ class PayPalPaymentMethod extends AbstractPaymentMethodType {
|
|||
'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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue