packages/js/data/src/shipping-zones/README.md
This data store provides functions to interact with the Shipping Zones REST endpoints. Under the hood this data store makes use of the CRUD data store.
Note: This data store is listed as experimental still as it is still in active development.
This data store can be accessed under the experimental/wc/admin/shipping/zones name. It is recommended you make use of the export store experimentalShippingZonesStore.
Example:
import {
experimentalShippingZonesStore,
} from '@woocommerce/data';
import { useDispatch } from '@wordpress/data';
function Component() {
const actions = useDispatch(
experimentalShippingZonesStore
);
actions.createShippingZone( { name: 'test' } );
}
| Selector | Description |
|---|---|
getShippingZone( id: number ) | Gets a Shipping Zone by ID |
getShippingZoneError( id ) | Get the error for a failing GET shipping zone request. |
getShippingZones( query = {} ) | Get all shipping zones, query object is empty. |
getShippingZoneesError( query = {} ) | Get the error for a GET request for all shipping zones. |
Example usage: wp.data.select( experimentalShippingZonesStore ).getShippingZone( 3 );
| Actions | Method | Description |
|---|---|---|
createShippingZone( shippingZoneObject ) | POST | Creates shipping zone, see ShippingZone here for values |
deleteShippingZone( id ) | DELETE | Deletes a shipping class by ID |
updatetShippingZone( id, shippingZoneObject ) | PUT | Updates a shipping zone, see ShippingZone here for values |
Example usage: wp.data.dispatch( experimentalShippingZonesStore ).updateShippingZone( 3, { name: 'New name' } );