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(membership-plans): improvements #110

Merged
merged 2 commits into from
Jul 17, 2024

Conversation

adekbadek
Copy link
Member

@adekbadek adekbadek commented Jul 8, 2024

All Submissions:

Changes proposed in this Pull Request:

Some tweaks to the Membership Plans table:

  1. Wording changes (e.g. "Active Members" -> "Active Memberships")
  2. Adds an "Active Subscriptions" column:
image
  1. Enables table sorting by Network ID
  2. Removes "Links" column in favour of linking with the plan name

(Note: this is a part of integrating the changes from the data-integrity-improvements branch (#89))

How to test the changes in this Pull Request:

  1. Set NEWSPACK_NETWORK_EXPERIMENTAL_AUDITING_FEATURES env variable to true
  2. Visit the "Membership Plans" view on the Hub site and observe the changes listed above

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Sorry, something went wrong.

@adekbadek adekbadek requested a review from a team as a code owner July 8, 2024 08:21
@adekbadek adekbadek changed the title feat(memberships-view): display discrepancies; UX improvements feat(membership-plans): improvements Jul 8, 2024
Copy link
Contributor

@chickenn00dle chickenn00dle left a comment

Choose a reason for hiding this comment

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

I tried following the testing steps but was only able to confirm the second two points. I am not seeing the Active Memberships or Active Subscriptions columns though:

Screenshot 2024-07-12 at 11 13 56

Am I missing a step to test this?

@adekbadek
Copy link
Member Author

Yes, sorry! I've update the testing step. What's missing is the NEWSPACK_NETWORK_EXPERIMENTAL_AUDITING_FEATURES env variable.

@adekbadek adekbadek requested a review from chickenn00dle July 15, 2024 06:56
Copy link
Contributor

@chickenn00dle chickenn00dle left a comment

Choose a reason for hiding this comment

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

Thanks @adekbadek!

Tested again and it looks to be working as expected 👍

I left a few small bits of feedback and questions, then this should be good to go.

public static function add_data_to_wc_user_membership_response( $response, $user, $request ) {
if ( $request && isset( $request->get_headers()['x_np_network_signature'] ) ) {
// Add network plan ID to the response.
$plan = wc_memberships_get_membership_plan( $response->data['plan_id'] );
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like wc_memberships_get_membership_plan can return false, so we will probably need to check the value of $plan before adding to response data.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in a4ab6df

if ( \Newspack_Network\Admin::use_experimental_auditing_features() ) {
$query_args['include_active_members_emails'] = 1;
}
$node_plans = self::fetch_collection_from_api( $node, 'wc/v2/memberships/plans', 'membership-plans', $query_args );
foreach ( $node_plans as $plan ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Getting the following warning on this line:

PHP Warning:  foreach() argument must be of type array|object, null given in /Users/raz/Sites/newspack/network/includes/hub/admin/class-membership-plans.php on line 129

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in a4ab6df

$response = wp_remote_get( // phpcs:ignore
$endpoint,
[
'headers' => $node->get_authorization_headers( 'get-woo-' . $collection_endpoint_id ),
'timeout' => 60, // phpcs:ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

nonblocking nit: Does the default not work here?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean? Default timeout is 5.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah. Whoops. For some reason I thought this was 30. Nevermind!

Comment on lines 57 to 58
$order = $_REQUEST['order'] ?? false; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$orderby = $_REQUEST['orderby'] ?? false; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we sanitize these to address the WordPress.Security.ValidatedSanitizedInput.InputNotSanitized warning?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in a4ab6df

@adekbadek adekbadek requested a review from chickenn00dle July 17, 2024 07:56
@adekbadek adekbadek merged commit f994478 into trunk Jul 17, 2024
4 checks passed
@adekbadek adekbadek deleted the feat/membership-discrepancies-tweaks branch July 17, 2024 17:44
matticbot pushed a commit that referenced this pull request Jul 19, 2024
# [1.10.0-alpha.1](v1.9.2...v1.10.0-alpha.1) (2024-07-19)

### Features

* **membership-plans:** improvements  ([#110](#110)) ([f994478](f994478))
* user discrepancies display ([#100](#100)) ([a054967](a054967))
* **users:** bulk user network sync ([d1e9533](d1e9533))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.10.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Jul 30, 2024
# [1.10.0](v1.9.2...v1.10.0) (2024-07-30)

### Features

* **membership-plans:** improvements  ([#110](#110)) ([f994478](f994478))
* user discrepancies display ([#100](#100)) ([a054967](a054967))
* **users:** bulk user network sync ([d1e9533](d1e9533))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.10.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants