Skip to content

Commit

Permalink
feat(ras): add toggle to force checkout registration (#3509)
Browse files Browse the repository at this point in the history
This PR adds a toggle to disable/enable forced checkout auth.
  • Loading branch information
chickenn00dle authored Oct 30, 2024
1 parent 6a78988 commit d50bb78
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 21 deletions.
53 changes: 32 additions & 21 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,27 +320,29 @@ private static function get_reader_activation_labels( $key = null ) {
* @return mixed[] Settings default values keyed by their name.
*/
private static function get_settings_config() {
$label = self::get_reader_activation_labels( 'newsletters_cta' );
$settings_config = [
'enabled' => false,
'enabled_account_link' => true,
'account_link_menu_locations' => [ 'tertiary-menu' ],
'newsletters_label' => $label,
'use_custom_lists' => false,
'newsletter_lists' => [],
'terms_text' => '',
'terms_url' => '',
'sync_esp' => true,
'metadata_prefix' => Sync\Metadata::get_prefix(),
'metadata_fields' => Sync\Metadata::get_fields(),
'sync_esp_delete' => true,
'active_campaign_master_list' => '',
'mailchimp_audience_id' => '',
'mailchimp_reader_default_status' => 'transactional',
'emails' => Emails::get_emails( array_values( Reader_Activation_Emails::EMAIL_TYPES ), false ),
'sender_name' => Emails::get_from_name(),
'sender_email_address' => Emails::get_from_email(),
'contact_email_address' => Emails::get_reply_to_email(),
$woocommerce_configuration_manager = Configuration_Managers::configuration_manager_class_for_plugin_slug( 'woocommerce' );
$label = self::get_reader_activation_labels( 'newsletters_cta' );
$settings_config = [
'enabled' => false,
'enabled_account_link' => true,
'account_link_menu_locations' => [ 'tertiary-menu' ],
'newsletters_label' => $label,
'use_custom_lists' => false,
'newsletter_lists' => [],
'terms_text' => '',
'terms_url' => '',
'sync_esp' => true,
'metadata_prefix' => Sync\Metadata::get_prefix(),
'metadata_fields' => Sync\Metadata::get_fields(),
'sync_esp_delete' => true,
'active_campaign_master_list' => '',
'mailchimp_audience_id' => '',
'mailchimp_reader_default_status' => 'transactional',
'emails' => Emails::get_emails( array_values( Reader_Activation_Emails::EMAIL_TYPES ), false ),
'sender_name' => Emails::get_from_name(),
'sender_email_address' => Emails::get_from_email(),
'contact_email_address' => Emails::get_reply_to_email(),
'woocommerce_registration_required' => false,
];

/**
Expand Down Expand Up @@ -2370,5 +2372,14 @@ public static function login_after_password_reset( $user ) {
}
set_current_reader( $user );
}

/**
* Whether forced registration at checkout is enabled.
*
* @return bool True if forced registration at checkout is enabled.
*/
public static function is_woocommerce_registration_required() {
return (bool) \get_option( self::OPTIONS_PREFIX . 'woocommerce_registration_required', false );
}
}
Reader_Activation::init();
19 changes: 19 additions & 0 deletions src/wizards/engagement/views/reader-activation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,24 @@ export default withWizardScreen( ( { wizardApiFetch } ) => {
</>
) }
</ActionCard>

<hr />

<SectionHeader title={ __( 'Modal Checkout Login and Registration', 'newspack-plugin' ) } />

<ActionCard
title={ __(
'Prompt logged out readers to sign in or register a new account before checkout',
'newspack-plugin'
) }
description={ __(
'Present logged out readers with the option to sign in or register a new account before proceeding to checkout.',
'newspack-plugin'
) }
toggleChecked={ config.woocommerce_registration_required }
toggleOnChange={ value => updateConfig( 'woocommerce_registration_required', value ) }
/>

<div className="newspack-buttons-card">
<Button
isPrimary
Expand Down Expand Up @@ -454,6 +472,7 @@ export default withWizardScreen( ( { wizardApiFetch } ) => {
sync_esp: config.sync_esp,
metadata_fields: config.metadata_fields,
metadata_prefix: config.metadata_prefix,
woocommerce_registration_required: config.woocommerce_registration_required,
} );
} }
disabled={ inFlight }
Expand Down

0 comments on commit d50bb78

Please sign in to comment.