Refactor onboarding link update endpoint refactor.

This commit is contained in:
Pedro Silva 2023-09-26 13:58:33 +01:00
parent 26a2b80b1b
commit 43136ecf3c
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
10 changed files with 168 additions and 85 deletions

View file

@ -127,6 +127,7 @@ class Button implements ButtonInterface {
*/
public function initialize(): void {
add_filter( 'ppcp_onboarding_options', array( $this, 'add_onboarding_options' ), 10, 1 );
add_filter( 'ppcp_partner_referrals_option', array( $this, 'filter_partner_referrals_option' ), 10, 1 );
add_filter( 'ppcp_partner_referrals_data', array( $this, 'add_partner_referrals_data' ), 10, 1 );
}
@ -150,11 +151,28 @@ class Button implements ButtonInterface {
}
return $options
. '<li><label><input type="checkbox" id="ppcp-onboarding-google" ' . $checked . '> '
. '<li><label><input type="checkbox" id="ppcp-onboarding-google" ' . $checked . ' data-onboarding-option="ppcp-onboarding-google"> '
. __( 'Onboard with GooglePay', 'woocommerce-paypal-payments' )
. '</label></li>';
}
/**
* Filters a partner referrals option.
*
* @param array $option The option data.
* @return array
*/
public function filter_partner_referrals_option( array $option ): array {
if ( $option['valid'] ) {
return $option;
}
if ( $option['field'] === 'ppcp-onboarding-google' ) {
$option['valid'] = true;
$option['value'] = ( $option['value'] ? '1' : '' );
}
return $option;
}
/**
* Adds to partner referrals data.
*