-
Notifications
You must be signed in to change notification settings - Fork 794
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
Assistant: Add site discount endpoints #23574
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
Backup plugin:
Social plugin:
Starter Plugin plugin:
Protect plugin:
|
@@ -32,6 +32,9 @@ | |||
// Each of these is a class that will register its own routes on 'rest_api_init'. | |||
require_once JETPACK__PLUGIN_DIR . '_inc/lib/core-api/load-wpcom-endpoints.php'; | |||
|
|||
// Create discount after site has been successfully connected. | |||
add_action( 'jetpack_authorize_ending_authorized', array( 'Jetpack_Core_Json_Api_Endpoints', 'create_site_discount' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the best place to add that action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not actually using create_site_discount
as an endpoint, right? Instead it's used to make the call to the WPCOM API. If that's true then it seems like this and the function itself might fit better somewhere else. I'm not familiar enough with the code base to know where though. Maybe somewhere that gets executed after a successful connection is established?
My understanding is that create_site_discount
would be called after a successful connection and can be called directly rather than via an API request. Let me know if I'm mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @travisw!
We're not actually using
create_site_discount
as an endpoint, right? Instead it's used to make the call to the WPCOM API.
That's right, create_site_discount
is called directly by the hook, and calls the WPCOM API.
My understanding is that
create_site_discount
would be called after a successful connection and can be called directly rather than via an API request. Let me know if I'm mistaken.
True, that's the current implementation. Maybe I don't understand your statement correctly.
I'm not familiar enough with the code base to know where though. Maybe somewhere that gets executed after a successful connection is established?
Gotcha, I'll ask around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the hook for jetpack_site_registered
, as it was recommended to me. It's more appropriate as the coupon is site based.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still wondering if the code for creating a coupon should actually live in a different area (not in class.core-rest-api-endpoints.php
) since it's not really defining an endpoint, but rather just calling a wpcom endpoint. But maybe Crew can clarify that once they give it a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, the endpoint to create the discount was removed from this PR.
038334a
to
f5d7d0f
Compare
@monsieur-z - It looks like this PR has a lot of the same changes as the base branch. I'm not sure if some of the commits from the base branch are repeated here? Maybe rebasing against the base branch would resolve this? |
19d11a7
to
563e56a
Compare
@@ -32,6 +32,9 @@ | |||
// Each of these is a class that will register its own routes on 'rest_api_init'. | |||
require_once JETPACK__PLUGIN_DIR . '_inc/lib/core-api/load-wpcom-endpoints.php'; | |||
|
|||
// Create discount after site has been successfully connected. | |||
add_action( 'jetpack_authorize_ending_authorized', array( 'Jetpack_Core_Json_Api_Endpoints', 'create_site_discount' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not actually using create_site_discount
as an endpoint, right? Instead it's used to make the call to the WPCOM API. If that's true then it seems like this and the function itself might fit better somewhere else. I'm not familiar enough with the code base to know where though. Maybe somewhere that gets executed after a successful connection is established?
My understanding is that create_site_discount
would be called after a successful connection and can be called directly rather than via an API request. Let me know if I'm mistaken.
projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php
Outdated
Show resolved
Hide resolved
projects/plugins/jetpack/_inc/lib/class.core-rest-api-endpoints.php
Outdated
Show resolved
Hide resolved
1b7f7bf
to
8ef2c1d
Compare
683f339
to
9acf705
Compare
Changes proposed in this Pull Request:
This PR adds an endpoint to fetch a site specific discount.
Jetpack product discussion
Context: pbNhbs-1xX-p2
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
Prerequisites:
PR instructions:
projects/plugins/jetpack/_inc/client/recommendations/index.jsx
, add<QuerySiteDiscount />
to the fragment returned by the component/wp-admin/admin.php?page=jetpack#/recommendations
page/wp-json/jetpack/v4/site/discount