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

@ -147,6 +147,19 @@ class ApplePayButton implements ButtonInterface {
*/
public function initialize(): void {
add_filter( 'ppcp_onboarding_options', array( $this, 'add_apple_onboarding_option' ), 10, 1 );
add_filter(
'ppcp_partner_referrals_option',
function ( array $option ): array {
if ( $option['valid'] ) {
return $option;
}
if ( $option['field'] === 'ppcp-onboarding-apple' ) {
$option['valid'] = true;
$option['value'] = ( $option['value'] ? '1' : '' );
}
return $option;
}
);
add_filter(
'ppcp_partner_referrals_data',
function ( array $data ): array {
@ -206,7 +219,7 @@ class ApplePayButton implements ButtonInterface {
$checked = '';
}
return $options . '<li><label><input type="checkbox" id="ppcp-onboarding-apple" ' . $checked . '> ' .
return $options . '<li><label><input type="checkbox" id="ppcp-onboarding-apple" ' . $checked . ' data-onboarding-option="ppcp-onboarding-apple"> ' .
__( 'Onboard with ApplePay', 'woocommerce-paypal-payments' ) . '
</label></li>';