You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
maybe_override_taxjar_tax() assumed the TaxJar tax response was always
well-formed and assigned properties on breakdown, breakdown->shipping and
each line item unconditionally. When TaxJar returns an incomplete response
(a null/non-object line item, or a missing breakdown/shipping member) this
fataled with "Attempt to assign property ... on null" during cart/checkout
tax calculation.
Guard each access: skip non-object line items, only touch breakdown and
shipping when present and object-typed, and default missing taxable amounts
to 0. Behavior is unchanged for well-formed responses.
Adds unit tests covering the well-formed override path plus regressions for
the null line item, missing breakdown and missing shipping cases.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: tests/php/test-class-wc-connect-taxjar-integration.php
+113Lines changed: 113 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1865,4 +1865,117 @@ public function test_create_or_update_tax_rate_does_not_duplicate_rows_for_semic
1865
1865
$this->assertStringNotContainsString( ';', $city, 'Tax rate city stored with a semicolon — `_update_tax_rate_cities()` will split it and break find_rates() on subsequent lookups.' );
1866
1866
}
1867
1867
}
1868
+
1869
+
/**
1870
+
* Build a well-formed TaxJar tax response object (as returned under
1871
+
* $taxjar_response->tax) with a base rate of 0.08.
1872
+
*
1873
+
* @return object
1874
+
*/
1875
+
privatefunctionbuild_taxjar_tax_response() {
1876
+
return (object) array(
1877
+
'rate' => 0.08,
1878
+
'breakdown' => (object) array(
1879
+
'combined_tax_rate' => 0.08,
1880
+
'country_tax_rate' => 0.0,
1881
+
'shipping' => (object) array(
1882
+
'combined_tax_rate' => 0.08,
1883
+
'country_tax_rate' => 0.0,
1884
+
),
1885
+
'line_items' => array(
1886
+
(object) array(
1887
+
'combined_tax_rate' => 0.08,
1888
+
'country_tax_rate' => 0.0,
1889
+
'country_taxable_amount' => 100.0,
1890
+
'taxable_amount' => 100.0,
1891
+
'country_tax_collectable' => 0.0,
1892
+
'tax_collectable' => 8.0,
1893
+
),
1894
+
),
1895
+
),
1896
+
);
1897
+
}
1898
+
1899
+
/**
1900
+
* The override filter should still rewrite every rate on a well-formed
0 commit comments