Keep consistent

This commit is contained in:
Claudio Sanches 2016-05-05 13:58:28 -03:00
parent 1a1c336468
commit 02b74fc474
1 changed files with 4 additions and 3 deletions

View File

@ -392,12 +392,13 @@ class WC_REST_Taxes_Controller extends WP_REST_Controller {
*/
public function update_item( $request ) {
$id = (int) $request['id'];
$current = WC_Tax::_get_tax_rate( $id, OBJECT );
if ( empty( $id ) || empty( $current ) ) {
$tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT );
if ( empty( $id ) || empty( $tax_obj ) ) {
return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 404 ) );
}
$tax = $this->create_or_update_tax( $request, $current );
$tax = $this->create_or_update_tax( $request, $tax_obj );
$this->update_additional_fields_for_object( $tax, $request );