#69183·woocommerce

Shipping tests: free shipping threshold

Author: linear[bot]Created Sep 29, 2026Updated Sep 29, 2026
LabelsShippingplugin: woocommercefocus: unit testsRubikblock: cartblock: checkout

What this covers

The merchant offers free shipping above an amount or with a coupon, and the shopper should cross that line at exactly the right moment in the Cart and Checkout blocks.

Server-only. The threshold is evaluated in WC_Shipping_Free_Shipping::is_available(); the blocks render whatever survives it.

Expected behaviour

  • No requirement; coupon only; amount only; either; both
  • The threshold is inclusive, so an exact match qualifies
  • A discount counts against the threshold by default
  • The pre-discount total is used when the merchant asks for it
  • With tax-inclusive display, the discount's tax is also subtracted
  • Applying a free shipping coupon moves the selection onto that method

Where it breaks

  • A valid coupon that does not actually grant free shipping
  • An expired coupon, or one past its usage limit
  • Several coupons where only one grants free shipping
  • A total one cent below the threshold
  • A discount larger than the cart
  • Removing the coupon withdraws free shipping again

Already covered

Almost nothing, but not quite nothing. is_available() does execute: class-wc-shipping-test.php builds a real WC_Shipping_Free_Shipping( 1 ) and expects free_shipping:1 among the surviving rates, which only happens if availability returned true. That exercises the default requires = '' case as a precondition, without asserting anything about it. Otherwise requires and min_amount appear only in REST CRUD tests that assert persistence (ShippingZoneMethod v4 schema tests, ShippingZones v4 controller tests), and ignore_discounts appears nowhere in the test tree.

Not covered

is_available() in full:

  • The five requires values
  • A coupon having to be both is_valid() and get_free_shipping()
  • The >= comparison, which makes an exact match qualify
  • get_displayed_subtotal() feeding the amount test, so the tax display setting changes the answer
  • ignore_discounts = no subtracting get_discount_total(), plus get_discount_tax() when prices display including tax

Worth stating rather than testing, since the branches are never reached: with requires = '' neither branch is computed, with coupon the amount inputs are never read, with min_amount the coupon state is never read, and with no discount applied ignore_discounts makes no observable difference.

Conventions

Pin outcomes for core rules. Where core deliberately leaves an extension point open, pin that the seam is honoured rather than freezing the outcome.

Where a test replaces or overlaps existing coverage, show it is equivalent by mutation: break the rule in the source, confirm the new test fails, restore.

Integration and unit tests only, no E2E.