mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge pull request #3120 from woocommerce/PCP-4211-connect-settings-connect-common-settings-with-the-frontend
Connect Common settings with the frontend (4211)
This commit is contained in:
commit
5059ca24ff
1 changed files with 50 additions and 7 deletions
|
@ -37,6 +37,10 @@ class SettingsTabMapHelper {
|
||||||
'subtotal_mismatch_behavior' => 'subtotal_adjustment',
|
'subtotal_mismatch_behavior' => 'subtotal_adjustment',
|
||||||
'landing_page' => 'landing_page',
|
'landing_page' => 'landing_page',
|
||||||
'smart_button_language' => 'button_language',
|
'smart_button_language' => 'button_language',
|
||||||
|
'prefix' => 'invoice_prefix',
|
||||||
|
'intent' => '',
|
||||||
|
'vault_enabled_dcc' => 'save_card_details',
|
||||||
|
'blocks_final_review_enabled' => 'enable_pay_now',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +61,12 @@ class SettingsTabMapHelper {
|
||||||
case 'landing_page':
|
case 'landing_page':
|
||||||
return $this->mapped_landing_page_value( $settings_model );
|
return $this->mapped_landing_page_value( $settings_model );
|
||||||
|
|
||||||
|
case 'intent':
|
||||||
|
return $this->mapped_intent_value( $settings_model );
|
||||||
|
|
||||||
|
case 'blocks_final_review_enabled':
|
||||||
|
return $this->mapped_pay_now_value( $settings_model );
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $settings_model[ $new_key ] ?? null;
|
return $settings_model[ $new_key ] ?? null;
|
||||||
}
|
}
|
||||||
|
@ -98,4 +108,37 @@ class SettingsTabMapHelper {
|
||||||
: ApplicationContext::LANDING_PAGE_NO_PREFERENCE
|
: ApplicationContext::LANDING_PAGE_NO_PREFERENCE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the mapped value for the order intent from the new settings.
|
||||||
|
*
|
||||||
|
* @param array<string, scalar|array> $settings_model The new settings model data as an array.
|
||||||
|
* @return 'AUTHORIZE'|'CAPTURE'|null The mapped 'intent' setting value.
|
||||||
|
*/
|
||||||
|
protected function mapped_intent_value( array $settings_model ): ?string {
|
||||||
|
$authorize_only = $settings_model['authorize_only'] ?? null;
|
||||||
|
$capture_virtual_orders = $settings_model['capture_virtual_orders'] ?? null;
|
||||||
|
|
||||||
|
if ( is_null( $authorize_only ) && is_null( $capture_virtual_orders ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $authorize_only ? 'AUTHORIZE' : 'CAPTURE';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the mapped value for the "Pay Now Experience" from the new settings.
|
||||||
|
*
|
||||||
|
* @param array<string, scalar|array> $settings_model The new settings model data as an array.
|
||||||
|
* @return bool|null The mapped 'Pay Now Experience' setting value.
|
||||||
|
*/
|
||||||
|
protected function mapped_pay_now_value( array $settings_model ): ?bool {
|
||||||
|
$enable_pay_now = $settings_model['enable_pay_now'] ?? null;
|
||||||
|
|
||||||
|
if ( is_null( $enable_pay_now ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ! $enable_pay_now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue