Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

AvaTax causes a fatal error when renewing subscriptions #8473

Closed
opr opened this issue Feb 17, 2023 · 8 comments · Fixed by #8537
Closed

AvaTax causes a fatal error when renewing subscriptions #8473

opr opened this issue Feb 17, 2023 · 8 comments · Fixed by #8537
Assignees
Labels
priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: bug The issue/PR concerns a confirmed bug.

Comments

@opr
Copy link
Contributor

opr commented Feb 17, 2023

Describe the bug

Reported in p1676641499676679-slack-C01DT6U03HC

There is a fatal error when using AvaTax and WooCommerce 7.4.0 - this was introduced in 5c01299

To reproduce

Steps to reproduce the behavior:

  1. Install AvaTax (credentials in secret 7715) and set it up so taxes are applied to your orders. I used a store in the USA and used USA addresses.
  2. Install WooCommerce Subscriptions
  3. Create a Subscription product and add it to your cart. Then check out.
  4. Open the subscription in the WP dashboard and from the subscription actions box choose "Process renewal"
  5. image
  6. See the error.

Expected behavior

Subscription renewals should work even if AvaTax is enabled.

Additional context

See https://github.com/woocommerce/woocommerce-blocks/blob/trunk/src/Shipping/ShippingController.php#L292 for the line this error happens on.

Also cc @woocommerce/helix in case you want to take a look - the stack trace can be found in the slack message: p1676641499676679-slack-C01DT6U03HC

@opr opr added the type: bug The issue/PR concerns a confirmed bug. label Feb 17, 2023
@neilmccreadie
Copy link

5975104-zen

@rossviviano
Copy link

32138782-hc

@maxlaf
Copy link
Member

maxlaf commented Feb 20, 2023

37663405-hc
For searchability, this is the main error that's thrown:

Uncaught Error: Call to a member function get() on null in /wordpress/plugins/woocommerce/7.4.0/packages/woocommerce-blocks/src/Shipping/ShippingController.php:260

@nicdwilson
Copy link

5967453-zen

@rossviviano
Copy link

36019744- hc

@opr
Copy link
Contributor Author

opr commented Feb 22, 2023

We have a callback for the woocommerce_customer_taxable_address filter in

$chosen_method = current( WC()->session->get( 'chosen_shipping_methods', array() ) ) ?? '';
which uses the session to check which shipping method is chosen.

In the context of a subscription renewal, the session is not set up, and if it were, the chosen shipping method would not be there anyway.

We need a way to check what context we're filtering the address in if possible, if it is during a renewal, we should try to derive the shipping method from the order, and if it is from an ordinary checkout, we can continue as normal.

@ralucaStan ralucaStan added the priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. label Feb 22, 2023
@wavvves wavvves self-assigned this Feb 23, 2023
@thracefulton
Copy link

Another instance in 40423785-hc

@sverleis
Copy link

sverleis commented Mar 6, 2023

As seen in 41300601-hc

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