Shipping tests: after the purchase
What this covers
The shopper completes the order, and the confirmation, the email and the stored order have to agree with what the checkout showed. PHP and client.
Expected behaviour
- A pickup order says where to collect from
- The delivery address block is hidden for it
- The email carries the same information
- The collection details are written onto the order permanently
Where it breaks
- The tax the cart quoted must be the tax the order charges. Confirmed broken and filed on woocommerce/woocommerce#47060. Pin the equality, not the current behaviour
- The same must hold on every later recalculation, including the pay-for-order address update and admin's Recalculate
- The method used is later deleted or disabled, which changes the tax status of an order that already exists
- The location is deleted and an old order is viewed
- An older order carries no collection meta at all
Already covered
ShippingControllerTest's four filter_order_tax_location() tests are the only well-guarded part of this area.
Not covered
WC_Order_Item_Shipping::get_tax_status()is never asserted. It is called bycalculate_taxes()on every order tax calculation, so it is exercised constantly without ever being the subject, andclass-wc-order-item-shipping-test.phpholds 10 tests and every one is aboutset_taxes()formats and legacy conversion. Running without being asserted is exactly how the bug below survived- The tax the cart quoted equalling the tax the order charges, on creation and on every later recalculation
show_local_pickup_details()has no PHP test; the only coverage is E2E- The collection meta being written onto the order permanently
- The confirmation grouping pickup as collection rather than delivery, and hiding the delivery address block
- The email carrying the same information
- The method or location being deleted or disabled after the order exists
The bug this issue must not pin
A non-taxable local pickup line is taxed anyway, and the shopper is charged more than the checkout quoted.
WC_Order_Item_Shipping::get_tax_status() (includes/class-wc-order-item-shipping.php:314) does not store the status on the line. It resolves it live through WC_Shipping_Zones::get_shipping_method( $this->get_instance_id() ) and falls back to taxable when that finds nothing. set_tax_status() has been a no-op since 9.7.0, so nothing can correct it afterwards. PickupLocation is registered outside zones and never receives an instance id, so the lookup always fails.
Reproduced end to end through the UI: the checkout block shows a total of 38.00 with pickup_location:0 carrying "taxes": "0", and pressing Place Order creates the order at 38.50. The trigger on an ordinary purchase is OrderController::update_order_from_cart() (src/StoreApi/Utilities/OrderController.php:92), which builds the order from the cart and then calls $order->calculate_totals(). The same happens on the order-pay route (CheckoutOrder.php:242) and on admin's Recalculate. A zone flat rate with the identical tax_status = none stays untaxed, so the missing instance id is what makes the difference.
Filed as woocommerce/woocommerce#47060 / woocommerce#47060, where it is recorded as metadata loss at priority Low.
Note when reproducing: the admin order screen cannot isolate this. Its shipping row posts no instance id, so every line added there carries instance id 0 and is taxed regardless of method.
Conventions
Integration and unit tests only, no E2E.
Source: woocommerce/woocommerce