woocommerce / woocommerce-blocks

(Deprecated) This plugin has been merged into woocommerce/woocommerce
https://wordpress.org/plugins/woo-gutenberg-products-block/
GNU General Public License v3.0
404 stars 218 forks source link

Wrong 'Tax' value when using the 'Local pickup' shipping method #6480

Closed waclawjacek closed 2 years ago

waclawjacek commented 2 years ago

Describe the bug

Check the comment below for the correct bug description and steps to reproduce TL;DR: This isn't a bug related to the WCS&T plugin. It's related to calculating the tax when selecting the local pickup shipping method.

Note: The taxes should be based on the base store location by default and not the customer's address when selecting the local pickup shipping method.

The current behavior in C&C Blocks:

Selecting the local pickup shipping method displays the correct tax value. After placing an order from the Checkout Block, the tax is not calculated (or the tax related to the customer address is used instead if it was set up) on the Order received page and in WP admin under Edit Order. So, on the C&C blocks, we are displaying the correct tax (i.e., based on the store address) when using the local pickup shipping method. But, after placing an order through the Checkout Block, we are sending the wrong tax (i.e., The tax based on the customer address).

When using the following setup, there is an issue with calculating tax for an order. The issue is that the tax is displayed throughout the checkout until the "Order received" page it is missing from.

When visiting the Edit Order page, the tax name is there but the tax is not applied to the order.

This issue is not present when using the shortcode.

To reproduce

  1. Set up a site using WC 6.5.1 and WC Blocks 7.6.0.
  2. Add the Cart block and Checkout block to the respective pages (this is essential) and remove the shortcode.
  3. In shipping options, add "Flat rate" for $10 and "Local pickup" for free.
  4. Enable automated taxes in settings.
  5. Payment options: add Cash on delivery.
  6. Set store address to: 123 Test Street, 90210 Beverly Hills, CA, USA.
  7. Add a physical product to the cart.
  8. Check out using the following address: 60 29th Street #343, 94110 San Francisco, CA, USA.
  9. Select Local pickup.
  10. Note how on the cart and checkout pages the tax rate is present.
  11. Complete the order.
  12. See tax rate of $0.00 applied on the Order received page and in WP admin under Edit Order.

Expected behavior

Tax rate is applied to the created order and displayed on the Order received page.

tarhi-saad commented 2 years ago

Hi @waclawjacek! 👋 Thank you for reporting this bug.

I followed the instructions to reproduce it. But I've got the expected behavior with a minor bug:

Using the C&C Blocks

  1. I selected local pickup
  2. The tax isn't present in C&C Blocks (i.e., Cart & Checkout blocks). That is the bug I found! The tax should be displayed.
  3. Complete Order
  4. See a tax rate applied (e.g., $3.88 — related to the product's price) on the Order received page and in WP admin under Edit Order. And this is the expected behavior.

On the other hand, I'm getting the mentioned bug above on the C&C shortcode instead:

Using the C&C shortcodes

  1. I selected local pickup
  2. The tax is present in C&C shortcodes with a value of $0.00 (We should have a tax of $3.88 — related to the product's price)
  3. Complete Order
  4. See a tax rate applied of $0.00 on the Order received page and in WP admin under Edit Order. (The tax rate applied should be $3.88 instead of $0.00)

I did the test using:

Please let me know if I'm missing something, and if there’s something additional about your environment that could help with reproducing the bug. (testing again using a fresh install can be helpful)

hollywoodeas commented 2 years ago

Hi, I'm the store owner that reported this issue. I just did a retest and got the exact opposite results stated above. The shortcode is correctly adding the tax to the final invoice, the block is not. Here is my setup with WC blocks:

1.) Store location set to Los Angeles, CA 90031 2.) Standard tax rate for Los Angeles = 9.5%. Automated taxes enabled. 3.) Create account. Use out of state address for shipping and billing. Key is shipping address. 4.) Add items to cart. 5.) Choose local pickup. Tax is displayed and added to total. 6.) Choose checkout. Make sure shipping address is out of state. 7.) Tax is displayed and added to total. Shipping is zero. 8.) Choose payment. I select cash. 9.) Place order. 10.) Order received page shows tax removed. Order received total does not match checkout page total.

If you change the block out to the old shortcode, the order received page includes the tax, as it should for local pickup regardless of the shipping address. This should give you the same result as stated above in "to reproduce". The "minor bug" you found, I have not seen. But good on finding it. Good luck.

tarhi-saad commented 2 years ago

Thank you, @hollywoodeas, for the detailed explanation! I was able to reproduce the bug thanks to your instructions. 🙌

Describe the bug

TL;DR: This isn't a bug related to the WCS&T plugin. It's related to calculating the tax when selecting the local pickup shipping method.

Note: The taxes should be based on the base store location by default and not the customer's address when selecting the local pickup shipping method.

The current behavior in C&C Blocks:

So, on the C&C blocks, we are displaying the correct tax (i.e., based on the store address) when using the local pickup shipping method. But, after placing an order through the Checkout Block, we are sending the wrong tax (i.e., The tax based on the customer address).

To reproduce

Scenario 1

  1. Set up a site using WC 6.5.1 and WC Blocks 7.7.0 (No need for the WC Shipping & Tax plugin)
  2. Set store address to 123 Test Street, 90210 Beverly Hills, CA, USA
  3. Enable taxes
  4. Add a "Standard" tax rates related to the base store location. Set it to: 10%
  5. Add the following shipping methods: "Flat rate" for $10 and "Local pickup" for free.
  6. Add a payment option (e.g., Cash on delivery).
  7. Add a physical product to the cart.
  8. Use an outside state address on the front-end. (e.g., 60 29th Street #343, 35005 birmingham, AL, USA)
  9. Go to the Cart block and select the Local pickup shipping method. Check that we have a tax of 10% applied.
  10. Go to the Checkout block and select the Local pickup shipping method. Check that we have a tax of 10% applied.
  11. Place your order. Check on the Order received page that the displayed tax is not applied anymore.
  12. Go to Edit Order. Check that no taxes were applied there as well.

Scenario 2 (The steps from Scenario 1 are required)

  1. Add a "Standard" tax rates related to the customer address (e.g., 60 29th Street #343, 35005 birmingham, AL, USA). And set it to: 5%
  2. Add a physical product to the cart.
  3. Use the same customer address on the front-end. (i.e., 60 29th Street #343, 35005 birmingham, AL, USA)
  4. Place your order. Check on the Order received page that a 5% tax is applied this time.
  5. Go to Edit Order. Check that a 5% tax is applied (You can see the name of the newly added tax that was applied).
hollywoodeas commented 2 years ago

Soooo, what's happening, if anything? I would think a bug that is generating a wrong invoice total would be a somewhat high priority for an e-commerce platform. Am I the only Woocommerce store experiencing this issue (on an almost weekly basis I might add)? Is anything going on behind the scenes?

tarhi-saad commented 2 years ago

Thank you, @hollywoodeas, for reaching out and asking for updates about the local pickup tax calculation bug. We fixed the bug, and the fix will be included in next week's release (WC Blocks 8.0.0).