WooOrderBatchResponse class

WooCommerce Order Batch Response Model

This class represents the response from a batch order operation. It contains the results of create, update, and delete operations performed in a single batch request.

Key Features

  • Create Results: List of successfully created orders with server-assigned IDs
  • Update Results: List of successfully updated orders
  • Delete Results: List of successfully deleted orders
  • Comprehensive Response: All operations results in a single response object

Usage Examples

Processing Batch Response

final response = await wooCommerce.batchUpdateOrders(batchRequest);

// Process created orders
for (final order in response.create ?? []) {
  print('Created order: ${order.number} with ID: ${order.id}');
}

// Process updated orders
for (final order in response.update ?? []) {
  print('Updated order: ${order.number}');
}

// Process deleted orders
for (final order in response.delete ?? []) {
  print('Deleted order: ${order.number}');
}

Checking Batch Results

final response = await wooCommerce.batchUpdateOrders(batchRequest);

final createdCount = response.create?.length ?? 0;
final updatedCount = response.update?.length ?? 0;
final deletedCount = response.delete?.length ?? 0;

print('Batch operation completed:');
print('  Created: $createdCount');
print('  Updated: $updatedCount');
print('  Deleted: $deletedCount');

JSON Serialization

The class supports full JSON serialization for API communication:

// Create from JSON response
final batchResponse = WooOrderBatchResponse.fromJson(jsonData);

// Convert to JSON if needed
final json = batchResponse.toJson();

Constructors

WooOrderBatchResponse({List<WooOrder>? create, List<WooOrder>? update, List<WooOrder>? delete})
Creates a new WooOrderBatchResponse instance
WooOrderBatchResponse.fromJson(Map<String, dynamic> json)
Creates a WooOrderBatchResponse instance from JSON data
factory

Properties

create List<WooOrder>?
List of created orders
final
delete List<WooOrder>?
List of deleted orders
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
update List<WooOrder>?
List of updated orders
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts the WooOrderBatchResponse instance to JSON format
toString() String
Returns a string representation of the WooOrderBatchResponse instance
override

Operators

operator ==(Object other) bool
The equality operator.
inherited