diff --git a/modules/ppcp-settings/resources/js/data/common/reducer.js b/modules/ppcp-settings/resources/js/data/common/reducer.js index 445fe7aef..672d006b9 100644 --- a/modules/ppcp-settings/resources/js/data/common/reducer.js +++ b/modules/ppcp-settings/resources/js/data/common/reducer.js @@ -32,7 +32,16 @@ const defaultTransient = Object.freeze( { wooSettings: Object.freeze( { storeCountry: '', storeCurrency: '', - installationPath: '', + + /** + * The "branded-only" experience is determined on server-side, based on the installation path. + * + * When true, the plugin must only display "PayPal's own brand" payment options + * i.e. no card payments or Apple Pay/Google Pay. + * + * @type {boolean} + */ + ownBrandOnly: false, } ), features: Object.freeze( { diff --git a/modules/ppcp-settings/resources/js/data/common/selectors.js b/modules/ppcp-settings/resources/js/data/common/selectors.js index d239f89f3..77848ff26 100644 --- a/modules/ppcp-settings/resources/js/data/common/selectors.js +++ b/modules/ppcp-settings/resources/js/data/common/selectors.js @@ -43,10 +43,11 @@ export const features = ( state ) => { export const wooSettings = ( state ) => { const settings = getState( state ).wooSettings || EMPTY_OBJ; + // For development and testing. Remove this eventually! const simulateBrandedOnly = localStorage.getItem( 'simulate-branded-only' ); /** - * The "branded only experience" is determined based on the installation path. + * The "own-brand-only" experience is determined on server-side, based on the installation path. * * When true, the plugin must only display "PayPal's own brand" payment options * i.e. no card payments or Apple Pay/Google Pay. @@ -54,9 +55,7 @@ export const wooSettings = ( state ) => { * @type {boolean} */ const ownBrandOnly = - 'true' === simulateBrandedOnly || // For development and testing. Remove this eventually! - settings.installationPath === 'core-profile' || - settings.installationPath === 'payment-settings'; + 'true' === simulateBrandedOnly || settings.ownBrandOnly; return { ...settings, ownBrandOnly }; }; diff --git a/modules/ppcp-settings/src/Data/GeneralSettings.php b/modules/ppcp-settings/src/Data/GeneralSettings.php index 19c84a20a..a26703c30 100644 --- a/modules/ppcp-settings/src/Data/GeneralSettings.php +++ b/modules/ppcp-settings/src/Data/GeneralSettings.php @@ -131,7 +131,7 @@ class GeneralSettings extends AbstractDataModel { public function get_woo_settings() : array { $settings = $this->woo_settings; - $settings['installation_path'] = $this->get_installation_path(); + $settings['own_brand_only'] = $this->own_brand_only(); return $settings; } diff --git a/modules/ppcp-settings/src/Endpoint/CommonRestEndpoint.php b/modules/ppcp-settings/src/Endpoint/CommonRestEndpoint.php index dfe06a27e..ab4fcba1e 100644 --- a/modules/ppcp-settings/src/Endpoint/CommonRestEndpoint.php +++ b/modules/ppcp-settings/src/Endpoint/CommonRestEndpoint.php @@ -108,12 +108,15 @@ class CommonRestEndpoint extends RestEndpoint { * @var array */ private array $woo_settings_map = array( - 'country' => array( + 'country' => array( 'js_name' => 'storeCountry', ), - 'currency' => array( + 'currency' => array( 'js_name' => 'storeCurrency', ), + 'own_brand_only' => array( + 'js_name' => 'ownBrandOnly', + ), ); /**