updateTaxRate method
Updates an existing tax rate in the WooCommerce store.
This method updates an existing tax rate with new configuration. The tax rate must have a valid ID to be updated.
Parameters
taxRate- The tax rate object with updated informationuseFaker- When true, returns the input tax rate without API call
Returns
A Future<WooTaxRate> containing the updated tax rate object.
Throws
WooCommerceExceptionif the request fails or access is denied
Example Usage
final updatedTaxRate = WooTaxRate(
id: 123,
country: 'US',
state: 'CA',
rate: '9.25', // Updated rate
name: 'California Sales Tax',
);
final result = await wooCommerce.updateTaxRate(updatedTaxRate);
Implementation
Future<WooTaxRate> updateTaxRate(WooTaxRate taxRate, {bool? useFaker}) async {
final isUsingFaker = useFaker ?? this.useFaker;
if (isUsingFaker) {
return taxRate;
}
final response = await dio.put(
_TaxRateEndpoints.singleTax(taxRate.id!),
data: taxRate.toJson(),
);
return WooTaxRate.fromJson(response.data);
}