mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
🧑💻 Add a temporary branded-only simulation mode
This commit is contained in:
parent
62e9a5e4ec
commit
7652bc8fea
3 changed files with 23 additions and 1 deletions
|
@ -44,7 +44,10 @@ export const wooSettings = ( state ) => {
|
||||||
const settings = getState( state ).wooSettings || EMPTY_OBJ;
|
const settings = getState( state ).wooSettings || EMPTY_OBJ;
|
||||||
|
|
||||||
// For development and testing. Remove this eventually!
|
// For development and testing. Remove this eventually!
|
||||||
const simulateBrandedOnly = localStorage.getItem( 'simulate-branded-only' );
|
const simulateBrandedOnly = document.cookie
|
||||||
|
.split( '; ' )
|
||||||
|
.find( ( row ) => row.startsWith( 'simulate-branded-only=' ) )
|
||||||
|
?.split( '=' )[ 1 ];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "own-brand-only" experience is determined on server-side, based on the installation path.
|
* The "own-brand-only" experience is determined on server-side, based on the installation path.
|
||||||
|
|
|
@ -168,6 +168,16 @@ export const addDebugTools = ( context, modules ) => {
|
||||||
onboarding.persist();
|
onboarding.persist();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a cookie to simulate the branded-only experience.
|
||||||
|
* @param {boolean} value - Whether to simulate branded-only experience.
|
||||||
|
*/
|
||||||
|
debugApi.simulateBrandedOnly = ( value ) => {
|
||||||
|
const expirationDate = new Date( Date.now() + 3600000 ).toUTCString();
|
||||||
|
document.cookie = `simulate-branded-only=${ value }; expires=${ expirationDate }; path=/`;
|
||||||
|
window.location.reload();
|
||||||
|
};
|
||||||
|
|
||||||
// Expose original debug API.
|
// Expose original debug API.
|
||||||
Object.assign( context, debugApi );
|
Object.assign( context, debugApi );
|
||||||
};
|
};
|
||||||
|
|
|
@ -306,6 +306,15 @@ class GeneralSettings extends AbstractDataModel {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function own_brand_only() : bool {
|
public function own_brand_only() : bool {
|
||||||
|
// Temporary dev/test mode.
|
||||||
|
$simulate_cookie = sanitize_key( wp_unslash( $_COOKIE['simulate-branded-only'] ?? '' ) );
|
||||||
|
|
||||||
|
if ( $simulate_cookie === 'true' ) {
|
||||||
|
return true;
|
||||||
|
} elseif ( $simulate_cookie === 'false' ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$brand_only_paths = array(
|
$brand_only_paths = array(
|
||||||
InstallationPathEnum::CORE_PROFILER,
|
InstallationPathEnum::CORE_PROFILER,
|
||||||
InstallationPathEnum::PAYMENT_SETTINGS,
|
InstallationPathEnum::PAYMENT_SETTINGS,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue