array( 'description' => __( 'Item ID.', 'woocommerce' ), 'type' => 'integer', 'context' => self::VIEW_EDIT_EMBED_CONTEXT, 'readonly' => true, ), 'rate_code' => array( 'description' => __( 'Tax rate code.', 'woocommerce' ), 'type' => 'string', 'context' => self::VIEW_EDIT_EMBED_CONTEXT, 'readonly' => true, ), 'rate_id' => array( 'description' => __( 'Tax rate ID.', 'woocommerce' ), 'type' => 'integer', 'context' => self::VIEW_EDIT_EMBED_CONTEXT, 'readonly' => true, ), 'label' => array( 'description' => __( 'Tax rate label.', 'woocommerce' ), 'type' => 'string', 'context' => self::VIEW_EDIT_EMBED_CONTEXT, 'readonly' => true, ), 'compound' => array( 'description' => __( 'Show if is a compound tax rate.', 'woocommerce' ), 'type' => 'boolean', 'context' => self::VIEW_EDIT_EMBED_CONTEXT, 'readonly' => true, ), 'tax_total' => array( 'description' => __( 'Tax total (not including shipping taxes).', 'woocommerce' ), 'type' => 'string', 'context' => self::VIEW_EDIT_EMBED_CONTEXT, 'readonly' => true, ), 'shipping_tax_total' => array( 'description' => __( 'Shipping tax total.', 'woocommerce' ), 'type' => 'string', 'context' => self::VIEW_EDIT_EMBED_CONTEXT, 'readonly' => true, ), 'meta_data' => $this->get_meta_data_schema(), ); return $schema; } /** * Get an item response. * * @param WC_Order_Item_Tax $order_item Order item instance. * @param WP_REST_Request $request Request object. * @param array $include_fields Fields to include in the response. * @return array */ public function get_item_response( $order_item, WP_REST_Request $request, array $include_fields = array() ): array { $dp = is_null( $request['num_decimals'] ) ? wc_get_price_decimals() : absint( $request['num_decimals'] ); $data = array( 'id' => $order_item->get_id(), 'rate_code' => $order_item->get_rate_code(), 'rate_id' => $order_item->get_rate_id(), 'label' => $order_item->get_label(), 'compound' => $order_item->get_compound(), 'tax_total' => wc_format_decimal( $order_item->get_tax_total(), $dp ), 'shipping_tax_total' => wc_format_decimal( $order_item->get_shipping_tax_total(), $dp ), 'meta_data' => $this->prepare_meta_data( $order_item ), ); return $data; } }