Example 3

Example 3 #

fn getFolderId() {
  if (
    src("status") == "draft" || 
    src("status") == "archived"
  ) {
    return "999998";
  } else if (number(src("variant: inventory quantity")) < 1) {
    return "55667788";
  } else {
    return "99887744";
  }
}

fn isActive() {
  if (
    src("status") == "draft" ||
    src("status") == "archived" ||
    contains(src("vendor"), "ubrukt")
  ) {
    return "0";
  } else {
    return "1";
  }
}

fn getShippingClass() {
  let w = number(src("variant: weight"));

  if (w > 151) {
    return "A";
  } else if (w > 100) {
    return "B";
  } else if (w > 50) {
    return "C";
  } else if (w > 0) {
    return "D";
  } else {
    return "E";
  }
}

fn getName() {
  return replace(src("title"), src("variant: sku"), "")
}

fn getDescription() {
  return replace(src("body html"), "<br><br><br><br><br><br>", "<br>");
}

sello "brand" = regexFirstMatch(src("tags"), "Märke_(.+?),");
sello "calculate price" = "0";
sello "elkjop active #778899" = isActive();
sello "elkjop price #778899" = src("variant: price") || src("variant: compare at price");
sello "elkjop shipping class" = getShippingClass();
sello "folder id" = getFolderId();
sello "images" = src("images");
sello "industry price" = src("variant: compare at price");
sello "manufacturer name": regexFirstMatch(src("tags"), "Märke_(.+?)");
sello "manufacturer no" = src("variant: sku");
sello "private name" = getName();
sello "property ColorText" = regexFirstMatch(src("tags"), "Farge_(.+?),");
sello "property ElkjopOfferState" = src("vendor");
sello "property M_138_0_Weight_KG" = src("variant: weight");
sello "property M_138_10063_31590" = src("metadata: type_t_rketrommel");
sello "property M_88_10013_30290" = regexFirstMatch(src("tags"), "Farge_(.+?),");
sello "property M_88_10055_30290" = regexFirstMatch(src("tags"), "Farge_(.+?),");
sello "property M_88_10064_31654" = replace(regexFirstMatch(src("tags"), "Kg_(.+?),"), "kg", "");
sello "property M_88_12047_30290" = regexFirstMatch(src("tags"), "Farge_(.+?),");
sello "property Model" = src("variant: option1") || src("variant: option2") || src("variant: option3");
sello "property Tags" = src("tags");
sello "quantity" = src("variant: inventory quantity");
sello "sku" = src("variant: sku");
sello "source category" = src("product type");
sello "standard description da" = getDescription();
sello "standard description en" = getDescription();
sello "standard name da" = getName();
sello "standard name en" = getName();