mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
♻️ Move DCC hooks to separate helper method
This commit is contained in:
parent
3cfbd1002f
commit
3fead84a70
1 changed files with 69 additions and 60 deletions
|
@ -342,6 +342,51 @@ class SmartButton implements SmartButtonInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->dcc_configuration->is_enabled() ) {
|
if ( $this->dcc_configuration->is_enabled() ) {
|
||||||
|
$this->render_dcc_wrapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->is_free_trial_cart() ) {
|
||||||
|
add_action(
|
||||||
|
'woocommerce_review_order_after_submit',
|
||||||
|
function () {
|
||||||
|
$vaulted_email = $this->get_vaulted_paypal_email();
|
||||||
|
if ( ! $vaulted_email ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="ppcp-vaulted-paypal-details">
|
||||||
|
<?php
|
||||||
|
echo wp_kses_post(
|
||||||
|
sprintf(
|
||||||
|
// translators: %1$s - email, %2$s, %3$s - HTML tags for a link.
|
||||||
|
esc_html__(
|
||||||
|
'Using %2$s%1$s%3$s PayPal.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
$vaulted_email,
|
||||||
|
'<b>',
|
||||||
|
'</b>'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->sanitize_woocommerce_filters();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers hooks and callbacks that are only relevant for DCC (ACDC) payments.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function render_dcc_wrapper(): void {
|
||||||
add_action(
|
add_action(
|
||||||
$this->checkout_dcc_button_renderer_hook(),
|
$this->checkout_dcc_button_renderer_hook(),
|
||||||
array( $this, 'dcc_renderer' ),
|
array( $this, 'dcc_renderer' ),
|
||||||
|
@ -359,10 +404,10 @@ class SmartButton implements SmartButtonInterface {
|
||||||
'woocommerce_credit_card_form_fields',
|
'woocommerce_credit_card_form_fields',
|
||||||
function ( array $default_fields, $id ) use ( $subscription_helper ) : array {
|
function ( array $default_fields, $id ) use ( $subscription_helper ) : array {
|
||||||
if (
|
if (
|
||||||
is_user_logged_in()
|
CreditCardGateway::ID === $id
|
||||||
|
&& is_user_logged_in()
|
||||||
&& $this->settings->has( 'vault_enabled_dcc' )
|
&& $this->settings->has( 'vault_enabled_dcc' )
|
||||||
&& $this->settings->get( 'vault_enabled_dcc' )
|
&& $this->settings->get( 'vault_enabled_dcc' )
|
||||||
&& CreditCardGateway::ID === $id
|
|
||||||
&& apply_filters( 'woocommerce_paypal_payments_should_render_card_custom_fields', true )
|
&& apply_filters( 'woocommerce_paypal_payments_should_render_card_custom_fields', true )
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -404,42 +449,6 @@ class SmartButton implements SmartButtonInterface {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->is_free_trial_cart() ) {
|
|
||||||
add_action(
|
|
||||||
'woocommerce_review_order_after_submit',
|
|
||||||
function () {
|
|
||||||
$vaulted_email = $this->get_vaulted_paypal_email();
|
|
||||||
if ( ! $vaulted_email ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
<div class="ppcp-vaulted-paypal-details">
|
|
||||||
<?php
|
|
||||||
echo wp_kses_post(
|
|
||||||
sprintf(
|
|
||||||
// translators: %1$s - email, %2$s, %3$s - HTML tags for a link.
|
|
||||||
esc_html__(
|
|
||||||
'Using %2$s%1$s%3$s PayPal.',
|
|
||||||
'woocommerce-paypal-payments'
|
|
||||||
),
|
|
||||||
$vaulted_email,
|
|
||||||
'<b>',
|
|
||||||
'</b>'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->sanitize_woocommerce_filters();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the hooks to render the credit messaging HTML depending on the settings.
|
* Registers the hooks to render the credit messaging HTML depending on the settings.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue