Skip to content

Commit

Permalink
feat(ras): add checkout success text settings
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed Nov 7, 2024
1 parent 065c2da commit 1d89e9e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
40 changes: 40 additions & 0 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ private static function get_settings_config() {
'contact_email_address' => Emails::get_reply_to_email(),
'woocommerce_registration_required' => false,
'woocommerce_checkout_privacy_policy_text' => self::get_checkout_privacy_policy_text(),
'woocommerce_post_checkout_success_text' => self::get_post_checkout_success_text(),
'woocommerce_post_checkout_registration_success_text' => self::get_post_checkout_registration_success_text(),
];

/**
Expand Down Expand Up @@ -2401,5 +2403,43 @@ public static function get_checkout_privacy_policy_text() {
)
);
}

/**
* Modal checkout success text.
*
* @return string Post checkout success text.
*/
public static function get_post_checkout_success_text() {
return \get_option(
self::OPTIONS_PREFIX . 'woocommerce_post_checkout_success_text',
sprintf(
// Translators: %s is the name of the site.
__(
'Thank you for supporting %s. Your transaction was successful.',
'newspack-plugin'
),
html_entity_decode( get_bloginfo( 'name' ) )
)
);
}

/**
* Modal checkout registration success text.
*
* @return string Post checkout registration success text.
*/
public static function get_post_checkout_registration_success_text() {
return \get_option(
self::OPTIONS_PREFIX . 'woocommerce_post_checkout_registration_success_text',
sprintf(
// Translators: %s is the name of the site.
__(
'Thank you for supporting %s. Your transaction was successful. An account has been created for you.',
'newspack-plugin'
),
html_entity_decode( get_bloginfo( 'name' ) )
)
);
}
}
Reader_Activation::init();
19 changes: 18 additions & 1 deletion src/wizards/engagement/views/reader-activation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,22 @@ export default withWizardScreen( ( { wizardApiFetch } ) => {
) }
{ ...getSharedProps( 'woocommerce_checkout_privacy_policy_text', 'text' ) }
/>

<TextControl
label={ __( 'Post-checkout success message', 'newspack-plugin' ) }
help={ __(
'The success message to display to readers after completing checkout.',
'newspack-plugin'
) }
{ ...getSharedProps( 'woocommerce_post_checkout_success_text', 'text' ) }
/>
<TextControl
label={ __( 'Post-checkout registration success message', 'newspack-plugin' ) }
help={ __(
'The success message to display to readers that have created a new account during checkout.',
'newspack-plugin'
) }
{ ...getSharedProps( 'woocommerce_post_checkout_registration_success_text', 'text' ) }
/>
<div className="newspack-buttons-card">
<Button
isPrimary
Expand Down Expand Up @@ -482,6 +497,8 @@ export default withWizardScreen( ( { wizardApiFetch } ) => {
metadata_prefix: config.metadata_prefix,
woocommerce_registration_required: config.woocommerce_registration_required,
woocommerce_checkout_privacy_policy_text: config.woocommerce_checkout_privacy_policy_text,
woocommerce_post_checkout_success_text: config.woocommerce_post_checkout_success_text,
woocommerce_post_checkout_registration_success_text: config.woocommerce_post_checkout_registration_success_text,
} );
} }
disabled={ inFlight }
Expand Down

0 comments on commit 1d89e9e

Please sign in to comment.