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

ECE buttons not rendered for variable subscription products on the product details page #9771

Open
pierorocca opened this issue Nov 20, 2024 · 26 comments · Fixed by #9917 · May be fixed by Automattic/woocommerce-subscriptions-core#746
Assignees
Labels
focus: checkout payments priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.

Comments

@pierorocca
Copy link
Contributor

Describe the bug

ECE buttons not rendered for variable subscription products on the product details page.

To Reproduce

  1. Create a variable subscription product, virtual type, with a non zero product price.
  2. Shop the product
  3. Note that on the Product Details Page the buttons are absent while present on the cart and checkout.

Actual behavior

  • For non $0 products, the express checkout buttons are rendered.
  • If the variable selection is not made, as is done for a variable product, an alert is displayed for the shopper to first select the variable option.

Screenshots

Image

Image

@pierorocca pierorocca added focus: checkout payments type: bug The issue is a confirmed bug. labels Nov 20, 2024
@pierorocca
Copy link
Contributor Author

Noting that the product shown in the screenshot actually has a $1 signup fee. I didn't intend that but the behavior is the same if it's $0 signup fee. The button doesn't render on PDP.

@pierorocca pierorocca added the priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. label Nov 22, 2024
@bborman22
Copy link
Contributor

@asumaran asumaran self-assigned this Dec 3, 2024
@asumaran
Copy link
Contributor

asumaran commented Dec 3, 2024

@pierorocca On which site can the product described in the issue be viewed? Locally, it works for me with the same type of product. I’d like to see if there’s any different configuration on your site.

@pierorocca
Copy link
Contributor Author

Proccaatomic.wpcomstaging.com

@asumaran
Copy link
Contributor

asumaran commented Dec 3, 2024

@pierorocca I see; in this case, it’s due to the free trial. Here’s the check which disables ECE on the product page for subscriptions with free trial.

|| ( class_exists( 'WC_Subscriptions_Product' ) && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $product ) > 0 ) // Trial subscriptions with shipping are not supported.

@pierorocca
Copy link
Contributor Author

A couple of things to consider.

With the sign-up fees, even with the free trial it's not a $0 purchase.

For free trials in general where a payment will happen, if there are no technical limitations, they should be supported by express checkout as a payment will happen.

The question is by using Apple or Google Pay do we still get a card on file and are able to process the future payment when it comes due?

@asumaran
Copy link
Contributor

asumaran commented Dec 3, 2024

The $product->needs_shipping() part seems odd since it checks against the variable subscription ($product) rather than the variations, which are virtual. By default, variable subscriptions do require shipping. However, even if that condition is removed, the outcome remains unchanged because ECE is being disabled due to the product being a subscription with a free trial.

@asumaran
Copy link
Contributor

asumaran commented Dec 3, 2024

The question is by using Apple or Google Pay do we still get a card on file and are able to process the future payment when it comes due?

I'll see the Stripe documentation to see if we can add support for free trials. The checks we currently have in place seem a bit outdated.

@pierorocca
Copy link
Contributor Author

By default, variable subscriptions do require shipping.

Is that true? The product can be virtual and a variation - e.g. 3 Month, 6 Month, 1 Year digital subscriptions.

@asumaran
Copy link
Contributor

asumaran commented Dec 3, 2024

Is that true? The product can be virtual and a variation - e.g. 3 Month, 6 Month, 1 Year digital subscriptions.

@pierorocca Yes, I was referring to the current check we have in place. For regular subscriptions $product->needs_shipping() works as expected wether the product is virtual or not. The problem is with variable subscriptions $product->needs_shipping() returns true even though the variations are virtual.

We need to update the check to not use needs_shipping() for Variable subscriptions. Nevertheless, we still face a UX issue with variable subscriptions because the product page does not have a variation selected when it loads. This means we can’t determine which variation to use to calculate ECE availability. In this case, I believe ECE should not be displayed initially and should only appear after a variation has been selected.

With the sign-up fees, even with the free trial it's not a $0 purchase.

Correct, it looks like we have a bug—we’re not retrieving the correct amount for subscription variations with free trials. I’ll keep investigating.

@pierorocca
Copy link
Contributor Author

Got it thank you.

@asumaran
Copy link
Contributor

asumaran commented Dec 3, 2024

@pierorocca, I’m encountering issues with getting subscriptions with free trials to work with ECE, and it seems this has been a long-standing problem (see p1623899346401100/1623869290.383200-slack-C01BZUL57SQ).

The issue appears to stem from the WC Subscriptions core. Subscriptions don’t have packages defined, which prevents us from retrieving shipping options, ultimately resulting in an error on the payment sheet. This also makes it impossible to calculate the total amount.

@diegocurbelo, do you have any insights on this?

@pierorocca
Copy link
Contributor Author

Nice find. Fixing core gaps if it can be done adds value well beyond WooPayments.

@bborman22
Copy link
Contributor

Wow nice digging on this @asumaran! There's a lot of variables at play here (pun intended 😆), so I'd just want to narrow it down a bit on what we're actually trying to solve here. In the original issue title this would be for ECE buttons missing on variable subscription products which would definitely be a high priority bug to fix. But if I'm reading this correctly the issue is actually only with variable subscription products with a free trial is that right? I mention this because we also have this issue about ECE and subscriptions with free trials, but also a sign up fee and I don't want things to get too tangled. I was wondering if it would be helpful to break down a list like the following:

Subscription Variations Free Trial Sign Up Fee Expected Actual
Yes Yes Yes Yes
Yes Yes Yes No
Yes Yes No Yes
Yes Yes No No
Yes No Yes Yes
Yes No Yes No
Yes No No Yes
Yes No No No

You can just edit my comment to mark the expected and actual results with Yes for display ECE and No for don't display ECE. This could help us narrow down which cases we actually need to solve for. @asumaran would you be able to start by filling in the Actual column by running through some quick tests in each scenario?

@asumaran
Copy link
Contributor

asumaran commented Dec 5, 2024

@bborman22 I tested sixteen combinations of simple and variable subscriptions. The case this issue aims to address is case 16.

In general, since we have a check for subscriptions with shipping and a free trial, all free trial subscriptions with shipping are currently unsupported. Please review the observations column for additional info.

The question is, should I focus only on case 16? Judging by the quick debugging I’ve done, this doesn’t seem straightforward to fix—at least not on WooPayments scope. It seems we need to address the following issues:

  1. Fix the incorrect shipping check for variable subscriptions. The shipping status of the variation should be checked instead of the parent subscription product. Additionally, ECE should be rendered on the frontend, allowing the user to select a variation and refresh the values, such as quantity, accordingly.
  2. Fix ECE for subscriptions (both simple and variable, with or without shipping) with a free trial. As mentioned earlier, this doesn’t seem straightforward to fix. Should I perhaps focus on Case 16 only instead?
Case is Variable subscrition is virtual Free Trial Sign Up Fee Expected Actual Observations
1 No no No No  
2 No no No Yes  
3 No no Yes No currently we don’t support subscriptions that need shipping with free trials. ref
4 No no Yes Yes ❌ (we should though) we don’t support subscriptions with free trial, even though we should as the sign up fee makes it a non-zero purchase.
5 no yes No No  
6 no yes No Yes  
7 no yes Yes No Uses Stripe Setup Intents API, charges $0, this is great.
8 no yes Yes Yes ❌ Product Page: amount in payment sheet is incorrect. Although the final charged amount is correct. ✅ Cart and Checkout pages show correct and amount and charges accordingly.
9 yes no no No Product Page: ECE appears on page load while no variation is selected. Alerts to choose a variation on click.
10 yes no no Yes  
11 yes no Yes No ❌ (should we?) Similar to simple subscriptions (case3) we don’t support subscriptions with free trials.
12 yes no Yes Yes ❌ (we should) Similar to case4, I think we should support this case since we are setting up a sign up fee which makes it a non-zero purchase.
13 yes Yes No No  
14 yes Yes No Yes  
15 yes Yes Yes No ❌ (should we?) ❌ This is a bug it seems. We don’t support subscriptions with free trial that require shipping. Although the product (variation) in this case is a virtual product. We are wrongly checking shipping status with the (variable) subscription instead of the variation. In theory we should support virtual variations with free trials.
16 yes Yes Yes Yes ❌ (we should) ❌ Seems like a bug. Similar to the previous one, we are checking against the subscription instead of the variation. But also, we should support this case since we have a sign up fee which makes it a non-zero purchase.

@asumaran
Copy link
Contributor

asumaran commented Dec 5, 2024

I forgot to mention that to support $0 purchases for subscriptions (free trials without signup fees), it seems we need to use Stripe’s Setup Intents API, as we currently do in case 7.

@pierorocca
Copy link
Contributor Author

I forgot to mention that to support $0 purchases for subscriptions (free trials without signup fees), it seems we need to use Stripe’s Setup Intents API, as we currently do in case 7.

That makes sense since it's getting the payment information for a future charge that's merchant not shopper initiated.

@pierorocca
Copy link
Contributor Author

Thanks so much for putting this together @asumaran @bborman22 ! My notes are below:

Case 3. The physical product requires shipping and once the free trial ends, the shopper will be billed. I'd expect ECE to be an option and show, so the shopper doesn't have to provide both shipping and card information through the checkout form. There is a future payment once the trial ends so the setup intent for a future payment can be created.

Case 4. The physical product that requires shipping and has a payable immediate signup fee, agree it should show. The signup fee is billed immediately and the setup intent created for the future payment once the free trial ends.

Case 5: For this virtual product that does not require shipping, if the product is $0 and on an ongoing basis it's free, I'd expect the button to not show. There's no shipping, no payment, and no future payment. If it's >$0, as marked it should show.

Case 7: Perfect.

Cases 11 & 12: Like 3 & 4 above.

Case 15: Agree.

Case 16: Agree.

@pierorocca
Copy link
Contributor Author

pierorocca commented Dec 5, 2024

FYI there were many tickets opened as a result of my p4ya8V-bv0-p2 related to ECE and subscriptions. #9776 covers case 16 and #9771 covers case 15. Solving for these two should also address cases 3, 4, 11 & 12?

Subscriptions are hugely important. More than a 1/3rd of the use cases identified here plus #9806 and #9799 issues, there's a really good opportunity to improve the product quality, and increase share of express checkouts.

@bborman22
Copy link
Contributor

Thanks so much for putting this together @asumaran this really helps me understand the problem better. Somewhat repeating @pierorocca's comments tying issues to cases here, but I was thinking of solving in this order / granularity:

Let me know if this breakdown makes sense and what a good next step might be. To me addressing 15 and 16 seems the most straight forward for fixing a bug and fixing 4 and 12 seems like the lightest lift by just modifying a conditional to take sign up fees into account.

@asumaran
Copy link
Contributor

asumaran commented Dec 6, 2024

After discussing this issue internally with @bborman22, I’m going to focus on cases 15 and 16, which should work similarly to cases 7 and 8, respectively, with the only difference being the variable subscription.

To address the issue gradually, I’ll first fix the incorrect check here, which is being done against the subscription instead of the variation. After that, I’ll focus on enabling ECE for cases 15 and 16. FYI: @pierorocca @bborman22

@pierorocca
Copy link
Contributor Author

Thanks @asumaran and @bborman22. Nice work dissecting this into smaller deliverables.

@asumaran
Copy link
Contributor

asumaran commented Dec 6, 2024

@pierorocca @bborman22 I just realized that adjusting the check enables ECE for variable subscriptions of virtual products with free trials, whether or not they include a sign-up fee—and it works!

The only thing to note is that the amount displayed in the payment sheet is either the subscription price (in the case of free trials) (Case 15) or the subscription price plus the sign-up fee (if a sign-up fee was added to the variation) (Case 16). I believe @cesarcosta99 is already addressing this in #9799?

It’s worth noting that in Case 15, the amount displayed in the payment sheet is the subscription price, but the charged amount is $0, as it uses Setup Intents for $0 charges 🎉.

In case 16, the displayed amount is the subscription price + the sign-up fee, but the charged amount is only the sign-up fee, which is the expected behavior. The only adjustment needed is to fix the amount displayed in the payment sheet, which César is currently working on.

@asumaran
Copy link
Contributor

asumaran commented Dec 6, 2024

I’ll stick to the plan and create a PR to refine the check. Then, I’ll work on another PR to enable ECE for cases 15 and 16, as leaving the condition open would enable ECE for cases 11 and 12, which don’t work and are not my current focus to resolve.

@asumaran
Copy link
Contributor

@bborman22 @pierorocca I managed to get ECE working for Case 4, but the fix needs to be applied in the WC Subscription Core repository. As expected, the payment sheet shows incorrect amounts; however, the charged amount is accurate.

We need to remove this block of code, which specifically excludes packages for subscriptions with free trials that require shipping. I'll run more tests and will submit a PR in their repository.

@pierorocca
Copy link
Contributor Author

Nice work and ownership of the fix @asumaran

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: checkout payments priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue is a confirmed bug.
Projects
None yet
3 participants