Skip to content

Commit

Permalink
Decide when to set the purchase token
Browse files Browse the repository at this point in the history
  • Loading branch information
IanRamosC committed Nov 1, 2024
1 parent 8cba9c8 commit 25866ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ConnectionStep = ( {
const redirectUri = `?redirect_uri=${ encodeURIComponent( window.location.href ) }`;
const connectAfterCheckoutUrl = `&connect_after_checkout=true&from_site_slug=${ siteUrl }&admin_url=${ adminUrl }`;
const query = `${ redirectUri }${ purchaseToken }${ connectAfterCheckoutUrl }`;
const jetpackPlansPath = getRedirectUrl( 'jetpack-plans', { query } );
const jetpackPlansPath = getRedirectUrl( 'jetpack-nav-plans-no-site', { query } );

const activationButtonLabel = __( 'Activate Jetpack in one click', 'jetpack-my-jetpack' );
const { refetch: refetchOwnershipData } = useProductsByOwnership();
Expand Down
10 changes: 1 addition & 9 deletions projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,19 +1001,11 @@ protected static function generate_purchase_token() {
}

/**
* Determine if the current user is allowed to make Jetpack purchases without
* a WordPress.com account
* Determine if the current user is allowed to make Jetpack purchases.
*
* @return boolean True if the user can make purchases, false if not
*/
public static function current_user_can_purchase() {
// The site must be site-connected to Jetpack (no users connected).
$connection_manager = new Connection_Manager();

if ( ! $connection_manager->is_site_connection() ) {
return false;
}

// Make sure only administrators can make purchases.
if ( ! current_user_can( 'manage_options' ) ) {
return false;
Expand Down

0 comments on commit 25866ca

Please sign in to comment.