create_product method
dynamic
create_product({
- String? name,
- String? type,
- String? status,
- dynamic tags,
- dynamic images,
- dynamic attributes,
- dynamic default_attributes,
- String? description,
- String? short_description,
- String? price,
- String? salePrice,
- dynamic date_on_sale_from,
- dynamic date_on_sale_from_gmt,
- dynamic date_on_sale_to,
- dynamic date_on_sale_to_gmt,
- bool? virtual,
- bool? downloadable,
- dynamic downloads,
- int? downloads_limit,
- int? downloads_expiry,
- String? external_url,
- String? button_text,
- String? tax_status,
- String? tax_class,
- bool? manage_stock,
- dynamic stock_quantity,
- String? stock_status,
- bool? backorders,
- bool? sold_individually,
- String? weight,
- String? dimensions,
- dynamic length,
- dynamic width,
- dynamic height,
- dynamic upsell_ids,
- dynamic cross_sell_ids,
- int? parent_id,
- String? purchase_note,
- dynamic featured,
- dynamic grouped_products,
- String? meta_data,
- String? id,
Implementation
create_product(
{String? name,
String? type,
String? status,
tags,
images,
attributes,
default_attributes,
String? description,
String? short_description,
String? price,
String? salePrice,
date_on_sale_from,
date_on_sale_from_gmt,
date_on_sale_to,
date_on_sale_to_gmt,
bool? virtual,
bool? downloadable,
downloads,
int? downloads_limit,
int? downloads_expiry,
String? external_url,
String? button_text,
String? tax_status,
String? tax_class,
bool? manage_stock,
stock_quantity,
String? stock_status,
bool? backorders,
bool? sold_individually,
String? weight,
String? dimensions,
length,
width,
height,
upsell_ids,
cross_sell_ids,
int? parent_id,
String? purchase_note,
featured,
grouped_products,
int? menu_order,
String? meta_data,
String? id}) async {
var data = {
'name': name,
'type': type,
'status': status,
'tags': [],
'images': [],
'attributes': [],
'default_attributes': [],
'description': description,
'short_description': short_description,
'regular_price': price,
'sale_price': salePrice,
'date_on_sale_from': date_on_sale_from,
'date_on_sale_from_gmt': date_on_sale_from_gmt,
'date_on_sale_to': date_on_sale_to,
'date_on_sale_to_gmt': date_on_sale_to_gmt,
'virtual': virtual,
'downloadable': downloadable,
'downloads': [],
'downloads_lomit': downloads_limit,
'downloads_expiry': downloads_expiry,
'external_url': external_url,
'button_text': button_text,
'tax_status': tax_status,
'tax_class': tax_class,
'manage_stock': manage_stock,
'stock_quantity': stock_quantity,
'stock_status': stock_status,
'backorders': backorders,
'sold_individually': sold_individually,
'weight': weight,
'dimensions': {},
'upsell_ids': [],
'cross_sell_ids': [],
'parent_id': parent_id,
'purchase_note': purchase_note,
// 'featured': featured,
'grouped_products': [],
'menu_order': menu_order,
'meta_data': [],
'categories': [],
};
var encodedData = jsonEncode(data);
var response = await ApiServices().postRequest(
body: encodedData,
request: 'products',
baseUrl: baseUrl,
consumerKey: consumerKey,
consumerSecret: consumerSecret);
var decodedData = jsonDecode(response.body);
// Product parsedData = Product.fromJson(decodedData);
// return parsedData;
return decodedData;
}