Fix checkout fatal when a cart line price is not numeric - #2997
Merged
ismaeldcom merged 4 commits intoAug 26, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents a PHP 8 checkout fatal in the TaxJar integration when a pricing extension (or other customization) makes a cart line’s unit price non-numeric after the item is already in the cart, by guarding get_line_items().
Changes:
- Skip building TaxJar line items when
unit_priceis non-numeric (while still allowing0). - Add unit tests covering non-numeric prices being skipped and zero prices being preserved.
- Add changelog/readme entries for the fix.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
classes/class-wc-connect-taxjar-integration.php |
Adds an is_numeric( $unit_price ) guard when building checkout line items to avoid PHP 8 arithmetic TypeErrors. |
tests/php/test-class-wc-connect-taxjar-integration.php |
Adds tests for skipping non-numeric prices and preserving $0 line items; extends teardown cleanup for the price filter. |
changelog.txt |
Documents the checkout fatal fix in the plugin changelog. |
readme.txt |
Documents the checkout fatal fix in the readme changelog section. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ismaeldcom
deleted the
wootax-339-checkout-fatal-when-a-cart-line-has-no-price
branch
August 26, 2026 13:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
get_line_items()withis_numeric( $unit_price ), so a malformed price never reaches the totals arithmetic.wc_format_decimal( $product->get_price() )reduces a malformed price to''or'-', andcalculate_totals()multiplies that by the quantity, which is aTypeErroron PHP 8 that takes the whole checkout page down. The way in is a pricing plugin filteringwoocommerce_product_get_priceafter the item is already in the cart, since WooCommerce will not let you add a product with no price.is_numeric()rather than a truthiness check because'-'is truthy and would still fatal, and'0'is falsy and must not be dropped, seetest_zero_amount_response_persists_real_itemized_rates()for what the response to a$0line carries.The skipped line gets no tax row. Nothing is lost by that, on
trunkit got none either because the page died and took the rest of the cart's tax with it.Related issue(s)
Closes WOOTAX-339
Steps to reproduce & screenshots/GIFs
trunkand enable automated taxes.1 Main St, Denver, CO 80202.Uncaught TypeError: Unsupported operand types: string * intinclass-wc-connect-taxjar-integration.php:614.A zero price must still be sent
debug_logging_enabledso theWCS Taxlog recordsRequesting: taxjar/v2/taxes.0in the cart.trunkand on this branch."unit_price":"0"on both, and the order totals should be identical.Checklist
changelog.txtentry addedreadme.txtentry added