-
Notifications
You must be signed in to change notification settings - Fork 4
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
Disable launch your store on trial sites #1507
Conversation
Size Change: 0 B Total Size: 201 kB ℹ️ View Unchanged
|
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.
LGTM and tested well 👍 🚀
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.
@ilyasfoo I'm using wc_calypso_bridge_is_ecommerce_trial_plan() to check if the store is on a trial plan. I'm not sure if this is sufficient. Please let me know if there is a better way to check if the store is on any trial plan. 🙏
@chihsuan That's a good question! I tested in my business plan site and indeed this did not return true. I wrote a function that detects it, but it's only lightly tested with my business plan site:
public static function is_ecommerce_trial_plan() {
if ( ! function_exists( 'wpcom_get_site_purchases' ) ) {
return false;
}
if ( is_null( self::$is_wpcom_business_trial_plan ) ) {
self::$is_wpcom_business_trial_plan = false;
} else {
return self::$is_wpcom_business_trial_plan;
}
$all_site_purchases = wpcom_get_site_purchases();
$plan_purchases = array_filter(
$all_site_purchases,
function ( $purchase ) {
return 'bundle' === $purchase->product_type;
}
);
if ( 1 === count( $plan_purchases ) ) {
// We have exactly one plan
$plan_purchase = reset( $plan_purchases );
if ( 'wp-bundle-hosting-trial' === $plan_purchase->billing_product_slug ) {
self::$is_wpcom_business_trial_plan = true;
}
}
return self::$is_wpcom_business_trial_plan ?? false;
}
Thanks @ilyasfoo, I'll try that out and look into it more. 🙌 |
2025944
to
b524143
Compare
- Update trial plan checks
e4a48f7
to
5f5352d
Compare
@ilyasfoo 👋 I added a helper function I tested the code on a business plan site, and it worked as expected. Could you please take a look at the change and possibly review it? Thanks! 🙏 |
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 for working on this, @chihsuan! Apologies for missing this in the issue description, but we should also hide the admin bar badge 🙏
We should also revert the coming soon should_show_a8c_coming_soon_page
to use WPCOM's coming soon when it's a trial site.
} | ||
|
||
/** | ||
* Check if the site has a specific plan. |
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.
Duplicate comment here
* | ||
* @return bool True if the site has the specified plan, false otherwise. | ||
*/ | ||
private static function has_plan( $plan, $exact_one_plan = false ) { |
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.
Nit: Would it be better if we support passing array for $plan
? I'm unsure how performant is this check, and we have a prior art in checking for multiple plan string.
Also, I think it's better to have $exact_one_plan
check to true
since it's how it was done before in similar checks
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.
Sounds good! Updated it here 0ec8e66
@ilyasfoo @chihsuan is the concern here that free trial users could customize the Woo template too much? I suppose they could add a checkout block or something 🤔 I'm happy with this for now, but I think it would be worth returning to when we create a newsletter signup template. I think it would be good to allow free trial users to have access to that. Instead, perhaps in Core we need to place direct protections on the checkout when coming soon mode is active. |
@adrianduffell Good point, my original concern was that it was showing the live site since we were in live mode and WPCOM coming soon was bypassed. I think free trial users being able to add a checkout block is also a valid concern.
I agree, let's revisit this in the future 👍 |
@adrianduffell Yes, the state will be coming soon since the site is "Unlaunched" |
Hey @ilyasfoo, I've pushed the changes to hide the admin bar badge and to use WPCOM's coming soon page for trial sites. Could you take a look again? Thanks. 🙏 You will need to use WooCommerce trunk or 9.3 beta to test the admin badge. wp plugin install https://github.com/woocommerce/woocommerce/releases/download/nightly/woocommerce-trunk-nightly.zip --activate |
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.
Awesome, @chihsuan! This is testing well, LGTM! 🚢
Co-authored-by: Ilyas Foo <[email protected]>
Changes proposed in this Pull Request:
Closes #1504.
Apply all of the below for trial plans (both ecommerce and business trial plans)
@ilyasfoo I'm using
wc_calypso_bridge_is_ecommerce_trial_plan()
to check if the store is on a trial plan. I'm not sure if this is sufficient. Please let me know if there is a better way to check if the store is on any trial plan. 🙏Site visibility
settings tabsLaunch your store
taskHow to test the changes in this Pull Request:
Coming Soon
modeSite visibility
settings tabs are hiddenLaunch your store
task is hiddenOther information:
FOR PR REVIEWER ONLY: