Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ia): audience checkout/payment and donations wizard #3564

Merged
merged 27 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dda3a11
feat(ia): audience checkout/payment and donations wizard
miguelpeixe Nov 21, 2024
832b88d
feat: improve billing fields section integration
miguelpeixe Nov 21, 2024
8419faf
fix: remove "Emails" and start "Revenue " tab
miguelpeixe Nov 21, 2024
4b02093
chore: remove unused import
miguelpeixe Nov 21, 2024
3244a02
feat: move "cover fees"
miguelpeixe Nov 21, 2024
bcdb00b
fix: improve NRH settings wizard ui
miguelpeixe Nov 21, 2024
c0751d6
chore: move donate block rendering block filter
miguelpeixe Nov 21, 2024
e04818b
chore: remove RR wizard
miguelpeixe Nov 21, 2024
bc8994d
chore: remove RR wizard
miguelpeixe Nov 21, 2024
bac1ac8
chore: update and standardize wizard slugs
miguelpeixe Nov 21, 2024
8bd413e
fix: css selector
miguelpeixe Nov 21, 2024
818c2cf
Merge branch 'epic/ia' into feat/ia-audience-donations-2
miguelpeixe Nov 22, 2024
5749aaa
fix: decouple methods and tweak wizard store
miguelpeixe Nov 25, 2024
620dd67
fix: billing fields api endpoint
miguelpeixe Nov 26, 2024
3509fb7
fix: donations configuration wizard
miguelpeixe Nov 26, 2024
e3d1a66
fix: salesforce settings
miguelpeixe Nov 26, 2024
02b79d8
fix: payment gatways endpoints
miguelpeixe Nov 26, 2024
33e6fa8
chore: update constant
miguelpeixe Nov 26, 2024
8a933f1
chore: update donation wizard data type
miguelpeixe Nov 26, 2024
0a88421
feat: revenue tab
miguelpeixe Nov 26, 2024
7d21b9a
test: change wizard to test
miguelpeixe Nov 26, 2024
835e0cc
fix: campaign wizard regressions
miguelpeixe Nov 26, 2024
10a45f4
fix: typo
miguelpeixe Nov 26, 2024
136b27e
fix: handle wizard loading on wizard tab
miguelpeixe Nov 26, 2024
9c9c1c8
Merge branch 'epic/ia' into feat/ia-audience-donations-2
miguelpeixe Nov 27, 2024
c1e5ae7
fix: deprecate Salesforce
miguelpeixe Nov 27, 2024
8b92d15
fix: remove unused code and minor tweaks
miguelpeixe Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions includes/class-donations.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static function init() {
add_filter( 'newspack_blocks_donate_billing_fields_keys', [ __CLASS__, 'get_billing_fields' ] );
add_action( 'woocommerce_checkout_create_order_line_item', [ __CLASS__, 'checkout_create_order_line_item' ], 10, 4 );
add_action( 'woocommerce_coupons_enabled', [ __CLASS__, 'disable_coupons' ] );
add_filter( 'render_block', [ __CLASS__, 'prevent_rendering_donate_block' ], 10, 2 );
}
}

Expand Down Expand Up @@ -429,8 +430,7 @@ public static function get_donation_settings() {
$parsed_settings['amounts'][ $frequency ] = array_map( 'floatval', $amounts );
}

$parsed_settings['platform'] = self::get_platform_slug();
$parsed_settings['billingFields'] = self::get_billing_fields();
$parsed_settings['platform'] = self::get_platform_slug();

// If NYP isn't available, force untiered config.
if ( ! self::can_use_name_your_price() ) {
Expand Down Expand Up @@ -461,13 +461,6 @@ public static function set_donation_settings( $args ) {
if ( isset( $args['saveDonationProduct'] ) && $args['saveDonationProduct'] === true ) {
self::update_donation_product( $configuration );
}

// Update the billing fields.
$billing_fields = isset( $args['billingFields'] ) ? $args['billingFields'] : [];
if ( ! empty( $billing_fields ) ) {
$billing_fields = array_map( 'sanitize_text_field', $billing_fields );
self::update_billing_fields( $billing_fields );
}
}

Logger::log( 'Save donation settings' );
Expand Down Expand Up @@ -619,7 +612,6 @@ public static function get_platform_slug() {
* @param string $platform Platform slug.
*/
public static function set_platform_slug( $platform ) {
delete_option( self::NEWSPACK_READER_REVENUE_PLATFORM );
update_option( self::NEWSPACK_READER_REVENUE_PLATFORM, $platform, true );
}

Expand Down Expand Up @@ -1094,5 +1086,22 @@ public static function disable_coupons( $enabled ) {
}
return false;
}

/**
* Prevent rendering of Donate block if Reader Revenue platform is set to 'other.
*
* @param string $block_content The block content about to be rendered.
* @param array $block The data of the block about to be rendered.
*/
public static function prevent_rendering_donate_block( $block_content, $block ) {
if (
isset( $block['blockName'] )
&& 'newspack-blocks/donate' === $block['blockName']
&& self::is_platform_other()
) {
return '';
}
return $block_content;
}
Comment on lines +1089 to +1105
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this from the wizard class because it's not relevant for the wizard, it makes more sense to live in the more general Donations class.

}
Donations::init();
2 changes: 1 addition & 1 deletion includes/class-newspack.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ private function includes() {
// Audience Wizard.
include_once NEWSPACK_ABSPATH . 'includes/wizards/audience/class-audience-wizard.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/audience/class-audience-campaigns.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/audience/class-audience-donations.php';

// Network Wizard.
include_once NEWSPACK_ABSPATH . 'includes/wizards/class-network-wizard.php';
Expand All @@ -159,7 +160,6 @@ private function includes() {
include_once NEWSPACK_ABSPATH . 'includes/wizards/class-settings.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/class-analytics-wizard.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/class-engagement-wizard.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/class-reader-revenue-wizard.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/class-site-design-wizard.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/class-syndication-wizard.php';
include_once NEWSPACK_ABSPATH . 'includes/wizards/class-health-check-wizard.php';
Expand Down
2 changes: 1 addition & 1 deletion includes/class-salesforce.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ private static function sync_salesforce( $order ) {
* @return string Redirect URL.
*/
public static function get_redirect_url() {
return get_admin_url( null, 'admin.php?page=newspack-reader-revenue-wizard#/salesforce' );
return get_admin_url( null, 'admin.php?page=newspack-audience' );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wizards.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public static function init() {
self::$wizards = [
'setup' => new Setup_Wizard(),
'site-design' => new Site_Design_Wizard(),
'reader-revenue' => new Reader_Revenue_Wizard(),
'syndication' => new Syndication_Wizard(),
'analytics' => new Analytics_Wizard(),
'components-demo' => new Components_Demo(),
Expand All @@ -55,6 +54,7 @@ public static function init() {
'advertising-sponsors' => new Advertising_Sponsors(),
'audience' => new Audience_Wizard(),
'audience-campaigns' => new Audience_Campaigns(),
'audience-donations' => new Audience_Donations(),
'listings' => new Listings_Wizard(),
'network' => new Network_Wizard(),
'newsletters' => new Newsletters_Wizard(),
Expand Down
3 changes: 1 addition & 2 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,7 @@ public static function get_prerequisites_status() {
'description' => __( 'Setting suggested donation amounts is required for enabling a streamlined donation experience.', 'newspack-plugin' ),
'instructions' => __( 'Set platform to "Newspack" or "News Revenue Hub" and configure your default donation settings. If using News Revenue Hub, set an Organization ID and a Donor Landing Page in News Revenue Hub Settings.', 'newspack-plugin' ),
'help_url' => 'https://help.newspack.com/engagement/reader-activation-system',
// @TODO: Update when platform is added.
'href' => \admin_url( '/admin.php?page=newspack-reader-revenue-wizard' ),
'href' => \admin_url( '/admin.php?page=newspack-audience#/payment' ),
'action_text' => __( 'Reader Revenue settings' ),
],
'ras_campaign' => [
Expand Down
Loading