createJSProduct function

dynamic createJSProduct(
  1. dynamic mpCommerce,
  2. dynamic rawProduct
)

Implementation

createJSProduct(mpCommerce, rawProduct) {
  JsObject? getAttributes(attributes) {
    if (attributes != null) {
      return JsObject.jsify(attributes);
    } else {
      return null;
    }
  }

  var product = mpCommerce.callMethod('createProduct', [
    rawProduct['name'],
    rawProduct['sku'],
    rawProduct['price'],
    rawProduct['quantity'],
    rawProduct['variant'],
    rawProduct['category'],
    rawProduct['brand'],
    rawProduct['position'],
    rawProduct['couponCode'],
    getAttributes(rawProduct['attributes'])
  ]);
  return product;
}