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

Jetpack AI: Use usage helper to set current tier value #33894

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
13 changes: 12 additions & 1 deletion projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,17 @@ public static function get_ai_assistance_feature() {

$usage_period_requests_count = WPCOM\Jetpack_AI\Usage\Helper::get_current_period_requests_count( $blog_id );

/*
* Get current tier value, a number representing
* the current tier of the site.
*
* - 0 represents a site with the free plan.
* - 1 represents a site with the current, unlimited plan.
* - 100, 200, 500 represents a site with the new plans,
* with the respective number of allowed requests.
*/
$current_tier_value = $has_ai_assistant_feature ? WPCOM\Jetpack_AI\Usage\Helper::get_tier_usage_quantity( $blog_id ) : 0;

// Check if the site requires an upgrade.
$require_upgrade = $is_over_limit && ! $has_ai_assistant_feature;

Expand All @@ -415,7 +426,7 @@ public static function get_ai_assistance_feature() {
'site-require-upgrade' => $require_upgrade,
'upgrade-type' => $upgrade_type,
'current-tier' => array(
'value' => $has_ai_assistant_feature ? 1 : 0,
'value' => $current_tier_value,
),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

Jetpack AI: Use Jetpack AI Usage Helper to set current plan tier information on feature endpoint.
Loading