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

Themes: Restoration of previous theme isn't working #66500

Closed
markbiek opened this issue Aug 11, 2022 · 7 comments
Closed

Themes: Restoration of previous theme isn't working #66500

markbiek opened this issue Aug 11, 2022 · 7 comments
Labels
[Feature Group] Appearance & Themes Features related to the appearance of sites. [Pri] Normal Schedule for the next available opportuinity. [Type] Bug When a feature is broken and / or not performing as intended

Comments

@markbiek
Copy link
Contributor

Steps to reproduce

  1. Assign a free theme to your site.
  2. Purchase a premium theme for your site.
  3. Remove the premium theme purchase.
  4. Instead of your original free theme being restored, you'll be assigned a random theme.

Full discussion: p1659985142358919-slack-C0160HSMDQV

paYKcK-1V9-p2 has some comments outlining where the code for restoring the previous theme is.

@markbiek markbiek added [Type] Bug When a feature is broken and / or not performing as intended [Feature Group] Appearance & Themes Features related to the appearance of sites. labels Aug 11, 2022
@mreishus mreishus self-assigned this Aug 16, 2022
@DavidRothstein
Copy link
Contributor

I can't reproduce this as written -- when I cancel my premium theme via Calypso, it automatically switches me back to the previous theme that I was using beforehand.

I do think this behavior only works (and was probably only ever implemented) for users self-cancelling the theme via Calypso, though. If the premium theme gets removed any other way -- for example by a happiness engineer, or if the user had access to the theme via a WordPress.com plan but then the plan is removed -- in that case they probably do go back to a random theme. So it sounds like there's room for improvement there; would just need to be careful to make sure the code correctly handles the situation where the site on which the theme is being removed is not equal to the current active site returned by get_current_blog_id().

@mreishus
Copy link
Contributor

Two Linked Functions not always called in succession

I've found a Store Admin cancellation of a legacy purchase calls disable_premium_theme_purchase() without calling restore_previously_selected_theme_for_site() right after.
Locations: wpcom-store-admin-page.php around 220 or wpcom-store-admin.php 337

The canonical cancel_theme does run disable_premium_theme_purchase() then restore_previously_selected_theme_for_site().

One step for improvement could be either ensuring that every call to disable_premium_theme_purchase() is followed by a call to restore_previously_selected_theme_for_site(), or to make the first function call the second automatically.


Unable to cancel legacy purchases

I was not able to test by canceling a premium theme purchase in Calypso. It won't let me, and if I patch in the remove purchase button:

diff --git a/client/me/purchases/remove-purchase/index.jsx b/client/me/purchases/remove-purchase/index.jsx
index 789927b90c..a13ce6c56c 100644
--- a/client/me/purchases/remove-purchase/index.jsx
+++ b/client/me/purchases/remove-purchase/index.jsx
@@ -337,9 +337,11 @@ class RemovePurchase extends Component {
                const { className, purchase, translate, useVerticalNavItem } = this.props;
                const productName = getName( purchase );
 
+               /*
                if ( ! isRemovable( purchase ) ) {
                        return null;
                }
+               */
 
                const defaultContent = (
                        <>

The POST to /wpcom/v2/purchases/1234/delete fails:
2022-08-16_15-33

I suppose I need to apply some of the new subscription based patches to try that out.

@markbiek
Copy link
Contributor Author

@mreishus Not sure if it applies to this case but I ran into an issue with restore_previously_selected_theme_for_site while working on the new theme subscription stuff.

Basically, restore_previously_selected_theme_for_site was restoring the theme from the subscription I was cancelling.

D85191-code has an attempt at a fix if it's useful. See line 792 of store-subscription-cancellations.php in that diff.

@DavidRothstein
Copy link
Contributor

Unable to cancel legacy purchases

It should be possible to cancel as long as the purchase is within the refund window -- there will be a "Cancel and Refund" link on the purchase management page in Calypso. (If it's no longer refundable, I guess it doesn't let you cancel at all, based on the theory that it's a one-time purchase which you can keep forever without paying more money...)

To test that you probably need to purchase the theme in store sandbox mode, e.g. with a fake credit card.

@mreishus
Copy link
Contributor

To fix [Two Linked Functions not always called in succession] in store admin, I have D86514-code, which is waiting for D86160-code first, to help prevent another p58i-cXE-p2 from happening.

@mreishus
Copy link
Contributor

mreishus commented Sep 7, 2022

D86160-code is complete and merged, so now D86514-code is waiting for review.

@cuemarie cuemarie added the [Pri] Normal Schedule for the next available opportuinity. label Apr 13, 2023
@sixhours
Copy link
Contributor

The proposed fix PR is well out of date and since this hasn't seemed to come up on the user end, I'm closing. Please reopen if it's still a user-facing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature Group] Appearance & Themes Features related to the appearance of sites. [Pri] Normal Schedule for the next available opportuinity. [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

No branches or pull requests

5 participants