create_product method

dynamic create_product({
  1. String? name,
  2. String? type,
  3. String? status,
  4. dynamic tags,
  5. dynamic images,
  6. dynamic attributes,
  7. dynamic default_attributes,
  8. String? description,
  9. String? short_description,
  10. String? price,
  11. String? salePrice,
  12. dynamic date_on_sale_from,
  13. dynamic date_on_sale_from_gmt,
  14. dynamic date_on_sale_to,
  15. dynamic date_on_sale_to_gmt,
  16. bool? virtual,
  17. bool? downloadable,
  18. dynamic downloads,
  19. int? downloads_limit,
  20. int? downloads_expiry,
  21. String? external_url,
  22. String? button_text,
  23. String? tax_status,
  24. String? tax_class,
  25. bool? manage_stock,
  26. dynamic stock_quantity,
  27. String? stock_status,
  28. bool? backorders,
  29. bool? sold_individually,
  30. String? weight,
  31. String? dimensions,
  32. dynamic length,
  33. dynamic width,
  34. dynamic height,
  35. dynamic upsell_ids,
  36. dynamic cross_sell_ids,
  37. int? parent_id,
  38. String? purchase_note,
  39. dynamic featured,
  40. dynamic grouped_products,
  41. int? menu_order,
  42. String? meta_data,
  43. 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;
  }