/** * This method reads the e-mail body template and fills it * with the values from the cart and the given information * about the user. * @return HTML e-mail body */ private function createMailBody() { $engine = $this->getTemplateEngine(); // read the template for the e-mail body $msgTpl = $engine->readTemplate(Template::MAIL_ORDER); // create a new CartModel instance to get access to the cart's products $cart = new CartModel(); // write all ordered products in the cart into e-mail $rows = ""; $amount = 0; foreach ($cart->getProducts() as $product) { $rowTpl = $engine->readTemplate(Template::MAIL_ORDER_ROW); $rowTpl = $engine->replaceTag("name", $product->getName(), $rowTpl); $rowTpl = $engine->replaceTag("options", StringUtils::arrangeOptions($product->getProperties()), $rowTpl); $rowTpl = $engine->replaceTag("price", StringUtils::formatAmount($product->getPrice()), $rowTpl); $rows .= $rowTpl; $amount += $product->getPrice(); } // write the POST-ed values into e-mail $msgTpl = $engine->replaceTag("firstname", StringUtils::removeTags($_POST["name-firstname"]), $msgTpl); $msgTpl = $engine->replaceTag("lastname", StringUtils::removeTags($_POST["name-lastname"]), $msgTpl); $msgTpl = $engine->replaceTag("email", StringUtils::removeTags($_POST["name-email"]), $msgTpl); $msgTpl = $engine->replaceTag("address", StringUtils::removeTags($_POST["name-address"]), $msgTpl); $msgTpl = $engine->replaceTag("addressnr", StringUtils::removeTags($_POST["name-addressnr"]), $msgTpl); $msgTpl = $engine->replaceTag("zipcode", StringUtils::removeTags($_POST["name-zipcode"]), $msgTpl); $msgTpl = $engine->replaceTag("city", StringUtils::removeTags($_POST["name-city"]), $msgTpl); $msgTpl = $engine->replaceTag("country", StringUtils::removeTags($_POST["name-country"]), $msgTpl); $msgTpl = $engine->replaceTag("shippingmethod", StringUtils::removeTags($_POST["name-shippingmethod"]), $msgTpl); $msgTpl = $engine->replaceTag("paymentmethod", StringUtils::removeTags($_POST["name-paymentmethod"]), $msgTpl); $msgTpl = $engine->replaceTag("total", StringUtils::formatAmount($amount), $msgTpl); $giftboxYesNo = isset($_POST["name-giftbox"]) ? "yes" : "no"; $msgTpl = $engine->replaceTag("yesno", $giftboxYesNo, $msgTpl); // replace the placeholder in e-mail's template with the product rows $msgTpl = $engine->replaceTag("rows", $rows, $msgTpl); // translate all keys in the template $msgTpl = $this->handleTranslations($msgTpl); // set the table with all informations to the view for displaying it $this->getView()->setTable($msgTpl); return $msgTpl; }