8000 Tags · woocommerce/woocommerce · GitHub
[go: up one dir, main page]

Skip to content

Tags

Tags

nightly

Toggle nightly's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Add shipping zone and tax rate query abilities (#70597)

* Add shipping-zones-query and tax-rates-query abilities

Core had no shipping or tax abilities. Woo AI's REST-bridge zone reads
return only id, name and order, with locations and methods as links.

- shipping-zones-query lists the zones in matching order, plus the
  catch-all zone 0, each with its locations and its methods. Methods
  are plain nested data with their scalar settings, without secrets;
  whether they become their own extensible resource is still open.
  Zones are a new extensible resource, shipping_zone.
- tax-rates-query lists the rates of every tax class, with postcodes
  and cities, filtered by country and class. Tax rates are table rows
  with no object an extension could read or change, so they take no
  extension fields.

Secrets are kept out of method settings by detection, in a SecretFields
class the settings abilities can reuse: password-type fields, and any
field whose ID or option name has a credential word (api_key, secret,
token, ...). A secret in a text field under a harmless name still gets
through.

* Make shipping methods extensible and page tax rates in SQL

Shipping methods become their own `shipping_method` resource, since
extensions like table rate shipping keep their data on the method, not
the zone. Each method now also returns its order within the zone.

Tax rates were loaded for every class and sliced in PHP, which pulls a
whole imported postcode table into memory on each call. The query now
filters and pages in SQL and loads the postcodes and cities of a page in
one query.

* Take include and return total from tax-rates-query

List abilities take the IDs to return in `include` and report the number
of matches across all pages in `total`, as product-terms-query does.
tax-rates-query had neither, so a caller could not fetch one rate by ID
or tell how many rates matched without paging through all of them.

* Read shipping method settings through the method's getters

The settings and their field types came from the instance_settings and
instance_form_fields properties. A method that overrides
get_instance_form_fields(), or gains fields through the
woocommerce_shipping_instance_form_fields_{id} filter, never puts them
in that property, so a password field there was only caught by its name.
A method that does not load its settings in the constructor returned
none at all.

Load the settings with init_instance_settings() and list the fields of
get_instance_form_fields(), as the shipping zone methods REST endpoint
does. Stored values without a declared field are left out.

* Load shipping zones once in shipping-zones-query

get_zones() read every zone and its methods, and execute() then built
each zone again and loaded its methods a second time. Read the zones
with get_shipping_zones(), which loads them in one batch without their
methods.

* Order tax rates by the store's tax class order

tax-rates-query sorted rates by class slug, while the tax settings list
the standard rates first and then the classes by name. A class whose
slug does not follow its name, such as one created with its own slug,
came out of place. Sort by the class order the settings use, with rates
of a deleted class last.

* Test shop manager access and the tax class filter

The PR says shop managers can use both abilities, but only an editor's
refusal was tested, and the class filter only with an unknown class.

* Fix the shipping and tax ability tests for the current field API

The registry reset reflected on ExtensibleAbilities::$reported, which no
longer exists, so every test errored in setUp. It now resets the same
registries as ExtensibleAbilitiesTest, including $syncs.

The test field declared its output type as array( 'string', 'null' ),
which register_field() refuses, so no extension field was added. It now
declares a single string type.

* Trust the input schema in the shipping and tax query abilities

Ability now converts the input to the schema types and validates it
before execute() runs, so the casts, intval maps and page clamps only
repeated what the schema guarantees.

* Recognize joined credential names and license keys as secrets

Names such as apikey, APIKey, accesskey or secretkey normalize to a
single word, so the whole-word match missed them and a shipping method
setting under such a name was returned. List the joined spellings of
the compound credential words too, and treat license keys as
credentials.

* Recognize the British spelling of licence keys as secrets

* Test the compound and shipping flags of tax rates

* Give each tax rate opposite compound and shipping flags in the test

With both flags equal on each rate, a formatter that read one flag for
both would still pass.

* Return settings only for Core shipping methods, without extension fields

Extensions keep carrier credentials in method settings under names such
as account_pass or meter_number, which no name list can tell from safe
ones, and a name list also dropped harmless fields like
require_signature. Settings now come back only for flat rate, free
shipping and local pickup, limited to the fields those classes declare,
so fields that extensions add through the form fields filter stay out.
SecretFields is no longer needed.

The shipping_zone and shipping_method resources are left out until the
abilities opt into extension fields together: shipping objects have no
get_type(), so a field with object_types would fail every zone query,
and the zone query applies no query filters.

* Read Core shipping method settings from a fresh instance

A woocommerce_shipping_zone_shipping_methods callback can add fields to
the method objects of a zone, so their instance_form_fields can hold
extension fields.

11.2.2

Toggle 11.2.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release: Prepare the changelog for 11.2.2 (#70661)

* Delete changelog files from 11.2.2 release

* Update the readme files for the 11.2.2 release

---------

Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>

11.3.0-beta.2

Toggle 11.3.0-beta.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release: Prepare the changelog for 11.3.0-beta.2 (#70554)

* Delete changelog files from 11.3.0-beta.2 release

* Update the readme files for the 11.3.0-beta.2 release

---------

Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>

11.3.0-beta.1

Toggle 11.3.0-beta.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release: Prepare the changelog for 11.3.0-beta.1 (#70234)

* Delete changelog files from 11.3.0-beta.1 release

* Update the readme files for the 11.3.0-beta.1 release

---------

Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>

11.3.0-dev

Toggle 11.3.0-dev's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
[tests] Reset the loaded shipping methods between tests (#69623)

* test: Reset the loaded shipping methods in WC_Unit_Test_Case

WC_Shipping keeps the methods it loaded on the singleton, and only
unregister_shipping_methods() drops them. A test that loads them under
its own filters or zones leaves that list for every later test: seven
classes, including Checkout, which leaves a lone pickup_location
method behind. #69117 reset it in ShippingControllerTest and the V4
shipping zone method tests after their leftovers broke other tests.

Drop the list in clear_wc_singleton_state(), with the other WC()
singleton state the rollback and hook restore miss. get_shipping_methods()
loads it again on next use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: Drop the per-class shipping method resets

WC_Unit_Test_Case now drops the loaded shipping methods after every
test, so the resets ShippingControllerTest and the V4 shipping zone
method tests ran in tearDown() are redundant. ShippingControllerTest
keeps unset( WC()->shipping ), which undoes a different leak: the
dynamic property one of its tests sets on the WC singleton.

The Totals and session pairs that the ShippingControllerTest reset
fixed in #69117 still pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(blocks): Run the Checkout block tests on WC_Unit_Test_Case

Blocks\Checkout extends WP_UnitTestCase, so the new shipping method
reset in WC_Unit_Test_Case doesn't reach it, and its local pickup test
still left a lone pickup_location method loaded on WC_Shipping. Move
it onto WC_Unit_Test_Case, as #69117 did for Totals and
RateLimitsTests, so its teardown drops the list too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: Drop cleanup the rollback and base teardown already cover

Review simplification. Now that Blocks\Checkout runs on
WC_Unit_Test_Case, its remove_filter() after parent::tearDown() and
the wp_delete_post() at the end of a test duplicate the hook restore
and the database rollback. The V4 shipping zone method tests tracked
every zone they created only to delete it in tearDown(), which the
rollback also does; drop the tracking and the override.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: Add testdox descriptions to shipping cleanup tests

Document the singleton cleanup and checkout pickup test outcomes using
the required testdox annotation. Address the missing annotations raised
in the PR review without changing test behavior.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

11.2.1

Toggle 11.2.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release: Prepare the changelog for 11.2.1 (#69666)

* Delete changelog files from 11.2.1 release

* Update the readme files for the 11.2.1 release

---------

Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>

11.2.0

Toggle 11.2.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release: Prepare the changelog for 11.2.0 (#69544)

* Delete changelog files from 11.2.0 release

* Update the readme files for the 11.2.0 release

---------

Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>

11.2.0-rc.1

Toggle 11.2.0-rc.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release: Prepare the changelog for 11.2.0-rc.1 (#69401)

* Delete changelog files from 11.2.0-rc.1 release

* Update the readme files for the 11.2.0-rc.1 release

---------

Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>

wc-beta-tester-4.0.0

Toggle wc-beta-tester-4.0.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Prepare 4.0.0 Beta Tester Release (#69410)

* Prepare 4.0.0 Beta Tester release

Require install_plugins for WCA Test Helper REST routes, the Test Helper admin script and the Live Branches page, matching the Test Helper admin page. Bump version to 4.0.0 and compile changelog.

11.2.0-beta.2

Toggle 11.2.0-beta.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release: Prepare the changelog for 11.2.0-beta.2 (#69157)

* Delete changelog files from 11.2.0-beta.2 release

* Update the readme files for the 11.2.0-beta.2 release

---------

Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
0