Пример #1
0
 /**
  * Generate module
  * @return void
  */
 protected function compile()
 {
     $arrProducts = $this->Isotope->Cart->getProducts();
     if (!count($arrProducts)) {
         $this->Template->empty = true;
         $this->Template->message = $this->iso_emptyMessage ? $this->iso_noProducts : $GLOBALS['TL_LANG']['MSC']['noItemsInCart'];
         return;
     }
     $objTemplate = new IsotopeTemplate($this->iso_cart_layout);
     global $objPage;
     $strUrl = $this->generateFrontendUrl($objPage->row());
     $blnReload = false;
     $arrQuantity = $this->Input->post('quantity');
     $arrProductData = array();
     // Surcharges must be initialized before getProducts() to apply tax_id to each product
     $arrSurcharges = $this->Isotope->Cart->getSurcharges();
     $arrProducts = $this->Isotope->Cart->getProducts();
     $lastAdded = $this->iso_continueShopping && count($_SESSION['ISO_CONFIRM']) ? $this->Isotope->Cart->lastAdded : 0;
     foreach ($arrProducts as $i => $objProduct) {
         // Remove product from cart
         if ($this->Input->get('remove') == $objProduct->cart_id && $this->Isotope->Cart->deleteProduct($objProduct)) {
             $this->redirect(strlen($this->Input->get('referer')) ? base64_decode($this->Input->get('referer', true)) : $strUrl);
         } elseif ($this->Input->post('FORM_SUBMIT') == 'iso_cart_update_' . $this->id && is_array($arrQuantity)) {
             $blnReload = true;
             $this->Isotope->Cart->updateProduct($objProduct, array('product_quantity' => $arrQuantity[$objProduct->cart_id]));
             continue;
             // no need to generate $arrProductData, we reload anyway
         }
         $arrProductData[] = array_merge($objProduct->getAttributes(), array('id' => $objProduct->id, 'image' => $objProduct->images->main_image, 'link' => $objProduct->href_reader, 'original_price' => $this->Isotope->formatPriceWithCurrency($objProduct->original_price), 'price' => $this->Isotope->formatPriceWithCurrency($objProduct->price), 'total_price' => $this->Isotope->formatPriceWithCurrency($objProduct->total_price), 'tax_id' => $objProduct->tax_id, 'quantity' => $objProduct->quantity_requested, 'cart_item_id' => $objProduct->cart_id, 'product_options' => $objProduct->getOptions(), 'remove_link' => ampersand($strUrl . ($GLOBALS['TL_CONFIG']['disableAlias'] ? '&' : '?') . 'remove=' . $objProduct->cart_id . '&referer=' . base64_encode($this->Environment->request)), 'remove_link_text' => $GLOBALS['TL_LANG']['MSC']['removeProductLinkText'], 'remove_link_title' => specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['removeProductLinkTitle'], $objProduct->name))));
         if ($lastAdded == $objProduct->cart_id) {
             $objTemplate->continueJumpTo = $objProduct->href_reader;
         }
     }
     $blnInsufficientSubtotal = $this->Isotope->Config->cartMinSubtotal > 0 && $this->Isotope->Config->cartMinSubtotal > $this->Isotope->Cart->subTotal ? true : false;
     // Redirect if the "checkout" button has been submitted and minimum order total is reached
     if ($blnReload && $this->Input->post('checkout') != '' && $this->iso_checkout_jumpTo && !$blnInsufficientSubtotal) {
         $this->redirect($this->generateFrontendUrl($this->Database->execute("SELECT * FROM tl_page WHERE id={$this->iso_checkout_jumpTo}")->fetchAssoc()));
     } elseif ($blnReload) {
         $this->reload();
     }
     // HOOK for adding additional forms into the template
     if (isset($GLOBALS['ISO_HOOKS']['compileCart']) && is_array($GLOBALS['ISO_HOOKS']['compileCart'])) {
         foreach ($GLOBALS['ISO_HOOKS']['compileCart'] as $name => $callback) {
             $this->import($callback[0]);
             $strForm = $this->{$callback}[0]->{$callback}[1]($this, $objTemplate, $arrProductData, $arrSurcharges);
             if ($strForm !== false) {
                 $arrForms[$name] = $strForm;
             }
         }
     }
     $objTemplate->hasError = $blnInsufficientSubtotal ? true : false;
     $objTemplate->minSubtotalError = sprintf($GLOBALS['TL_LANG']['ERR']['cartMinSubtotal'], $this->Isotope->formatPriceWithCurrency($this->Isotope->Config->cartMinSubtotal));
     $objTemplate->formId = 'iso_cart_update_' . $this->id;
     $objTemplate->formSubmit = 'iso_cart_update_' . $this->id;
     $objTemplate->summary = $GLOBALS['ISO_LANG']['MSC']['cartSummary'];
     $objTemplate->action = $this->Environment->request;
     $objTemplate->products = IsotopeFrontend::generateRowClass($arrProductData, 'row', 'rowClass', 0, ISO_CLASS_COUNT | ISO_CLASS_FIRSTLAST | ISO_CLASS_EVENODD);
     $objTemplate->cartJumpTo = $this->iso_cart_jumpTo ? $this->generateFrontendUrl($this->Database->execute("SELECT * FROM tl_page WHERE id={$this->iso_cart_jumpTo}")->fetchAssoc()) : '';
     $objTemplate->cartLabel = $GLOBALS['TL_LANG']['MSC']['cartBT'];
     $objTemplate->checkoutJumpToLabel = $GLOBALS['TL_LANG']['MSC']['checkoutBT'];
     $objTemplate->checkoutJumpTo = $this->iso_checkout_jumpTo && !$blnInsufficientSubtotal ? $this->generateFrontendUrl($this->Database->execute("SELECT * FROM tl_page WHERE id={$this->iso_checkout_jumpTo}")->fetchAssoc()) : '';
     $objTemplate->continueLabel = $GLOBALS['TL_LANG']['MSC']['continueShoppingBT'];
     $objTemplate->subTotalLabel = $GLOBALS['TL_LANG']['MSC']['subTotalLabel'];
     $objTemplate->grandTotalLabel = $GLOBALS['TL_LANG']['MSC']['grandTotalLabel'];
     $objTemplate->subTotalPrice = $this->Isotope->formatPriceWithCurrency($this->Isotope->Cart->subTotal);
     $objTemplate->grandTotalPrice = $this->Isotope->formatPriceWithCurrency($this->Isotope->Cart->grandTotal);
     // @todo make a module option.
     $objTemplate->showOptions = false;
     $objTemplate->surcharges = IsotopeFrontend::formatSurcharges($arrSurcharges);
     $objTemplate->forms = $arrForms;
     $this->Template->empty = false;
     $this->Template->cart = $objTemplate->parse();
 }
Пример #2
0
 /**
  * Generate order review interface and return it as HTML string
  * @param boolean
  * @return string
  */
 protected function getOrderReviewInterface($blnReview = false)
 {
     if ($blnReview) {
         return;
     }
     $objTemplate = new IsotopeTemplate('iso_checkout_order_review');
     $objTemplate->headline = $GLOBALS['TL_LANG']['ISO']['order_review'];
     $objTemplate->message = $GLOBALS['TL_LANG']['ISO']['order_review_message'];
     $objTemplate->summary = $GLOBALS['ISO_LANG']['MSC']['cartSummary'];
     // Surcharges must be initialized before getProducts() to apply tax_id to each product
     $arrSurcharges = $this->Isotope->Cart->getSurcharges();
     $arrProductData = array();
     $arrProducts = $this->Isotope->Cart->getProducts();
     foreach ($arrProducts as $objProduct) {
         $arrProductData[] = array_merge($objProduct->getAttributes(), array('id' => $objProduct->id, 'image' => $objProduct->images->main_image, 'link' => $objProduct->href_reader, 'price' => $this->Isotope->formatPriceWithCurrency($objProduct->price), 'total_price' => $this->Isotope->formatPriceWithCurrency($objProduct->total_price), 'quantity' => $objProduct->quantity_requested, 'tax_id' => $objProduct->tax_id, 'product_options' => $objProduct->getOptions()));
     }
     $objTemplate->info = $this->getCheckoutInfo();
     $objTemplate->products = IsotopeFrontend::generateRowClass($arrProductData, 'row', 'rowClass', 0, ISO_CLASS_COUNT | ISO_CLASS_FIRSTLAST | ISO_CLASS_EVENODD);
     $objTemplate->surcharges = IsotopeFrontend::formatSurcharges($arrSurcharges);
     $objTemplate->edit_info = $GLOBALS['TL_LANG']['ISO']['changeCheckoutInfo'];
     $objTemplate->subTotalLabel = $GLOBALS['TL_LANG']['MSC']['subTotalLabel'];
     $objTemplate->grandTotalLabel = $GLOBALS['TL_LANG']['MSC']['grandTotalLabel'];
     $objTemplate->subTotalPrice = $this->Isotope->formatPriceWithCurrency($this->Isotope->Cart->subTotal);
     $objTemplate->grandTotalPrice = $this->Isotope->formatPriceWithCurrency($this->Isotope->Cart->grandTotal);
     return $objTemplate->parse();
 }
Пример #3
0
 /**
  * Generate the module
  * @return void
  */
 protected function compile()
 {
     $objOrder = new IsotopeOrder();
     if (!$objOrder->findBy('uniqid', $this->Input->get('uid'))) {
         $this->Template = new FrontendTemplate('mod_message');
         $this->Template->type = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['ERR']['orderNotFound'];
         return;
     }
     $arrOrder = $objOrder->getData();
     $this->Template->setData($arrOrder);
     $this->import('Isotope');
     $this->Isotope->overrideConfig($objOrder->config_id);
     // Article reader
     $arrPage = $this->Database->prepare("SELECT * FROM tl_page WHERE id=?")->limit(1)->execute($this->jumpTo)->fetchAssoc();
     $arrAllDownloads = array();
     $arrItems = array();
     $arrProducts = $objOrder->getProducts();
     foreach ($arrProducts as $i => $objProduct) {
         $arrDownloads = array();
         $objDownloads = $this->Database->prepare("SELECT p.*, o.* FROM tl_iso_order_downloads o LEFT OUTER JOIN tl_iso_downloads p ON o.download_id=p.id WHERE o.pid=?")->execute($objProduct->cart_id);
         while ($objDownloads->next()) {
             $blnDownloadable = ($objOrder->status == 'complete' || intval($objOrder->date_paid) > 0 && intval($objOrder->date_paid) <= time()) && ($objDownloads->downloads_remaining === '' || $objDownloads->downloads_remaining > 0) ? true : false;
             // Send file to the browser
             if (strlen($this->Input->get('file')) && $this->Input->get('file') == $objDownloads->id && $blnDownloadable) {
                 if (!$this->backend && $objDownloads->downloads_remaining !== '') {
                     $this->Database->prepare("UPDATE tl_iso_order_downloads SET downloads_remaining=? WHERE id=?")->execute($objDownloads->downloads_remaining - 1, $objDownloads->id);
                 }
                 $this->sendFileToBrowser($objDownloads->singleSRC);
             }
             $arrDownload = array('raw' => $objDownloads->row(), 'title' => $objDownloads->title, 'href' => TL_MODE == 'FE' ? IsotopeFrontend::addQueryStringToUrl('file=' . $objDownloads->id) : '', 'remaining' => $objDownloads->downloads_allowed > 0 ? sprintf($GLOBALS['TL_LANG']['MSC']['downloadsRemaining'], intval($objDownloads->downloads_remaining)) : '', 'downloadable' => $blnDownloadable);
             $arrDownloads[] = $arrDownload;
             $arrAllDownloads[] = $arrDownload;
         }
         $arrItems[] = array('raw' => $objProduct->getData(), 'sku' => $objProduct->sku, 'name' => $objProduct->name, 'image' => $objProduct->images->main_image, 'product_options' => $objProduct->getOptions(), 'quantity' => $objProduct->quantity_requested, 'price' => $this->Isotope->formatPriceWithCurrency($objProduct->price), 'total' => $this->Isotope->formatPriceWithCurrency($objProduct->total_price), 'href' => $this->jumpTo ? $this->generateFrontendUrl($arrPage, '/product/' . $objProduct->alias) : '', 'tax_id' => $objProduct->tax_id, 'downloads' => $arrDownloads);
     }
     $this->Template->info = deserialize($objOrder->checkout_info, true);
     $this->Template->items = IsotopeFrontend::generateRowClass($arrItems, 'row', 'rowClass', 0, ISO_CLASS_COUNT | ISO_CLASS_FIRSTLAST | ISO_CLASS_EVENODD);
     $this->Template->downloads = $arrAllDownloads;
     $this->Template->downloadsLabel = $GLOBALS['TL_LANG']['MSC']['downloadsLabel'];
     $this->Template->raw = $arrOrder;
     $this->Template->date = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objOrder->date);
     $this->Template->time = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $objOrder->date);
     $this->Template->datim = $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $objOrder->date);
     $this->Template->orderDetailsHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['orderDetailsHeadline'], $objOrder->order_id, $this->Template->datim);
     $this->Template->orderStatus = sprintf($GLOBALS['TL_LANG']['MSC']['orderStatusHeadline'], $GLOBALS['TL_LANG']['ORDER'][$objOrder->status]);
     $this->Template->orderStatusKey = $objOrder->status;
     $this->Template->subTotalPrice = $this->Isotope->formatPriceWithCurrency($objOrder->subTotal);
     $this->Template->grandTotal = $this->Isotope->formatPriceWithCurrency($objOrder->grandTotal);
     $this->Template->subTotalLabel = $GLOBALS['TL_LANG']['MSC']['subTotalLabel'];
     $this->Template->grandTotalLabel = $GLOBALS['TL_LANG']['MSC']['grandTotalLabel'];
     $this->Template->surcharges = IsotopeFrontend::formatSurcharges($objOrder->getSurcharges());
     $this->Template->billing_label = $GLOBALS['TL_LANG']['ISO']['billing_address'];
     $this->Template->billing_address = $this->Isotope->generateAddressString($objOrder->billing_address, $this->Isotope->Config->billing_fields);
     if (strlen($objOrder->shipping_method)) {
         $arrShippingAddress = $objOrder->shipping_address;
         if (!is_array($arrShippingAddress) || $arrShippingAddress['id'] == -1) {
             $this->Template->has_shipping = false;
             $this->Template->billing_label = $GLOBALS['TL_LANG']['ISO']['billing_shipping_address'];
         } else {
             $this->Template->has_shipping = true;
             $this->Template->shipping_label = $GLOBALS['TL_LANG']['ISO']['shipping_address'];
             $this->Template->shipping_address = $this->Isotope->generateAddressString($arrShippingAddress, $this->Isotope->Config->shipping_fields);
         }
     }
 }
Пример #4
0
 /**
  * Generate the collection using a template. Useful for PDF output
  * @param string
  * @param boolean
  * @return string
  */
 public function generate($strTemplate = null, $blnResetConfig = true)
 {
     if ($strTemplate) {
         $this->strTemplate = $strTemplate;
     }
     $this->import('Isotope');
     // Set global config to this collection (if available)
     if ($this->config_id > 0) {
         $this->Isotope->overrideConfig($this->config_id);
     }
     $objTemplate = new BackendTemplate($this->strTemplate);
     $objTemplate->setData($this->arrData);
     $objTemplate->logoImage = '';
     if ($this->Isotope->Config->invoiceLogo != '' && is_file(TL_ROOT . '/' . $this->Isotope->Config->invoiceLogo)) {
         $objTemplate->logoImage = '<img src="' . $this->Environment->base . '/' . $this->Isotope->Config->invoiceLogo . '" alt="" />';
     }
     $objTemplate->invoiceTitle = $GLOBALS['TL_LANG']['MSC']['iso_invoice_title'] . ' ' . $this->order_id . ' – ' . date($GLOBALS['TL_CONFIG']['datimFormat'], $this->date);
     $arrItems = array();
     $arrProducts = $this->getProducts();
     foreach ($arrProducts as $objProduct) {
         $arrItems[] = array('raw' => $objProduct->getData(), 'product_options' => $objProduct->getOptions(), 'name' => $objProduct->name, 'quantity' => $objProduct->quantity_requested, 'price' => $objProduct->formatted_price, 'total' => $objProduct->formatted_total_price, 'tax_id' => $objProduct->tax_id);
     }
     $objTemplate->config = $this->Isotope->Config->getData();
     $objTemplate->info = deserialize($this->checkout_info);
     $objTemplate->items = $arrItems;
     $objTemplate->raw = $this->arrData;
     $objTemplate->date = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $this->date);
     $objTemplate->time = $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $this->date);
     $objTemplate->datim = $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $this->date);
     $objTemplate->datimLabel = $GLOBALS['TL_LANG']['MSC']['datimLabel'];
     $objTemplate->subTotalPrice = $this->Isotope->formatPriceWithCurrency($this->subTotal);
     $objTemplate->grandTotal = $this->Isotope->formatPriceWithCurrency($this->grandTotal);
     $objTemplate->subTotalLabel = $GLOBALS['TL_LANG']['MSC']['subTotalLabel'];
     $objTemplate->grandTotalLabel = $GLOBALS['TL_LANG']['MSC']['grandTotalLabel'];
     $objTemplate->surcharges = IsotopeFrontend::formatSurcharges($this->getSurcharges());
     $objTemplate->billing_label = $GLOBALS['TL_LANG']['ISO']['billing_address'];
     $objTemplate->billing_address = $this->Isotope->generateAddressString(deserialize($this->billing_address), $this->Isotope->Config->billing_fields);
     if (strlen($this->shipping_method)) {
         $arrShippingAddress = deserialize($this->shipping_address);
         if (!is_array($arrShippingAddress) || $arrShippingAddress['id'] == -1) {
             $objTemplate->has_shipping = false;
             $objTemplate->billing_label = $GLOBALS['TL_LANG']['ISO']['billing_shipping_address'];
         } else {
             $objTemplate->has_shipping = true;
             $objTemplate->shipping_label = $GLOBALS['TL_LANG']['ISO']['shipping_address'];
             $objTemplate->shipping_address = $this->Isotope->generateAddressString($arrShippingAddress, $this->Isotope->Config->shipping_fields);
         }
     }
     $strArticle = $this->Isotope->replaceInsertTags($objTemplate->parse());
     $strArticle = html_entity_decode($strArticle, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']);
     $strArticle = $this->Isotope->convertRelativeUrls($strArticle, '', true);
     // Remove form elements and JavaScript links
     $arrSearch = array('@<form.*</form>@Us', '@<a [^>]*href="[^"]*javascript:[^>]+>.*</a>@Us');
     $strArticle = preg_replace($arrSearch, '', $strArticle);
     // Handle line breaks in preformatted text
     $strArticle = preg_replace_callback('@(<pre.*</pre>)@Us', 'nl2br_callback', $strArticle);
     // Default PDF export using TCPDF
     $arrSearch = array('@<span style="text-decoration: ?underline;?">(.*)</span>@Us', '@(<img[^>]+>)@', '@(<div[^>]+block[^>]+>)@', '@[\\n\\r\\t]+@', '@<br /><div class="mod_article@', '@href="([^"]+)(pdf=[0-9]*(&|&amp;)?)([^"]*)"@');
     $arrReplace = array('<u>$1</u>', '<br />$1', '<br />$1', ' ', '<div class="mod_article', 'href="$1$4"');
     $strArticle = preg_replace($arrSearch, $arrReplace, $strArticle);
     // Set config back to default
     if ($blnResetConfig) {
         $this->Isotope->resetConfig(true);
     }
     return $strArticle;
 }