/** * Fill the object's arrProducts array * @param array|null * @return array */ protected function findProducts($arrCacheIds = null) { $time = time(); $arrCategories = $this->findCategories($this->iso_category_scope); list($arrFilters, $arrSorting, $strWhere, $arrValues) = $this->getFiltersAndSorting(); $objProductData = $this->Database->prepare(IsotopeProduct::getSelectStatement() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p1.language=''" . (BE_USER_LOGGED_IN === true ? '' : " AND p1.published='1' AND (p1.start='' OR p1.start<{$time}) AND (p1.stop='' OR p1.stop>{$time})") . "AND (p1.id IN (SELECT pid FROM tl_iso_product_categories WHERE page_id IN (" . implode(',', $arrCategories) . "))\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR p1.pid IN (SELECT pid FROM tl_iso_product_categories WHERE page_id IN (" . implode(',', $arrCategories) . ")))" . (is_array($arrCacheIds) ? "AND (p1.id IN (" . implode(',', $arrCacheIds) . ") OR p1.pid IN (" . implode(',', $arrCacheIds) . "))" : '') . ($this->iso_list_where == '' ? '' : " AND {$this->iso_list_where}") . "{$strWhere} GROUP BY p1.id ORDER BY c.sorting")->execute($arrValues); return IsotopeFrontend::getProducts($objProductData, IsotopeFrontend::getReaderPageId(null, $this->iso_reader_jumpTo), true, $arrFilters, $arrSorting); }
/** * Find all products we need to list. * @return array */ protected function findProducts() { $strAlias = $this->Input->get('product'); $arrIds = array(0); $arrJumpTo = array(); $objCategories = $this->Database->prepare("SELECT *, (SELECT jumpTo FROM tl_iso_related_categories WHERE id=category) AS jumpTo FROM tl_iso_related_products WHERE pid IN (SELECT id FROM tl_iso_products WHERE " . (is_numeric($strAlias) ? 'id' : 'alias') . "=?" . ($this->iso_list_where != '' ? ' AND ' . $this->iso_list_where : '') . ") AND category IN (" . implode(',', $this->iso_related_categories) . ") ORDER BY id=" . implode(' DESC, id=', $this->iso_related_categories) . " DESC")->execute($strAlias); while ($objCategories->next()) { $ids = deserialize($objCategories->products); if (is_array($ids) && count($ids)) { $arrIds = array_unique(array_merge($arrIds, $ids)); if ($objCategories->jumpTo) { $arrJumpTo = array_fill_keys($ids, $objCategories->jumpTo) + $arrJumpTo; } } } return IsotopeFrontend::getProducts($arrIds, IsotopeFrontend::getReaderPageId(null, $this->iso_reader_jumpTo)); }
/** * Generate module * @return void */ protected function compile() { $objProduct = IsotopeFrontend::getProductByAlias($this->Input->get('product'), IsotopeFrontend::getReaderPageId()); if (!$objProduct) { $this->Template = new FrontendTemplate('mod_message'); $this->Template->type = 'empty'; $this->Template->message = $GLOBALS['TL_LANG']['MSC']['invalidProductInformation']; return; } $this->Template->product = $objProduct->generate(strlen($this->iso_reader_layout) ? $this->iso_reader_layout : $objProduct->reader_template, $this); $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; global $objPage; $objPage->pageTitle = strip_insert_tags($objProduct->name); $objPage->description = $this->prepareMetaDescription($objProduct->description_meta); $GLOBALS['TL_KEYWORDS'] .= (strlen($GLOBALS['TL_KEYWORDS']) ? ', ' : '') . $objProduct->keywords_meta; }
/** * Inject Ajax scripts */ protected function injectAjax() { list(, $startScript, $endScript) = IsotopeFrontend::getElementAndScriptTags(); $GLOBALS['TL_MOOTOOLS'][get_class($this) . '_ajax'] = "\n{$startScript}\nwindow.addEvent('ajaxready', function() {\n Mediabox ? Mediabox.scanPage() : Lightbox.scanPage();\n});\n{$endScript}\n"; }
/** * Get filter & sorting configuration * @param boolean * @return array */ protected function getFiltersAndSorting($blnNativeSQL = true) { $arrFilters = array(); $arrSorting = array(); if (is_array($this->iso_filterModules)) { $arrModules = array_reverse($this->iso_filterModules); foreach ($arrModules as $module) { if (is_array($GLOBALS['ISO_FILTERS'][$module])) { $arrFilters = array_merge($arrFilters, $GLOBALS['ISO_FILTERS'][$module]); } if (is_array($GLOBALS['ISO_SORTING'][$module])) { $arrSorting = array_merge($arrSorting, $GLOBALS['ISO_SORTING'][$module]); } if ($GLOBALS['ISO_LIMIT'][$module] > 0) { $this->perPage = $GLOBALS['ISO_LIMIT'][$module]; } } } if (empty($arrSorting) && $this->iso_listingSortField != '') { $arrSorting[$this->iso_listingSortField] = array($this->iso_listingSortDirection == 'DESC' ? SORT_DESC : SORT_ASC, SORT_REGULAR); } // Thanks to certo web & design for sponsoring this feature if ($blnNativeSQL) { $strWhere = ''; $arrWhere = array(); $arrValues = array(); // Initiate native SQL filtering foreach ($arrFilters as $k => $filter) { if ($filter['group'] == '' && !in_array($filter['attribute'], $GLOBALS['ISO_CONFIG']['dynamicAttributes'])) { $operator = IsotopeFrontend::convertFilterOperator($filter['operator'], 'SQL'); $arrWhere[] = "{$filter['attribute']} {$operator} ?"; $arrValues[] = $filter['value']; unset($arrFilters[$k]); } } if (count($arrWhere)) { $time = time(); $strWhere = " AND ((p1." . implode(' AND p1.', $arrWhere) . ") OR p1.id IN (SELECT pid FROM tl_iso_products WHERE language='' AND " . implode(' AND ', $arrWhere) . (BE_USER_LOGGED_IN === true ? '' : " AND published='1' AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time})") . "))"; $arrValues = array_merge($arrValues, $arrValues); } return array($arrFilters, $arrSorting, $strWhere, $arrValues); } return array($arrFilters, $arrSorting); }
/** * Return the PayPal form. * * @access public * @return string */ public function checkoutForm() { $objOrder = new IsotopeOrder(); if (!$objOrder->findBy('cart_id', $this->Isotope->Cart->id)) { $this->redirect($this->addToUrl('step=failed', true)); } list($endTag, $startScript, $endScript) = IsotopeFrontend::getElementAndScriptTags(); $strBuffer = ' <h2>' . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0] . '</h2> <p class="message">' . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1] . '</p> <form id="payment_form" action="https://www.' . ($this->debug ? 'sandbox.' : '') . 'paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"' . $endTag . ' <input type="hidden" name="upload" value="1"' . $endTag . ' <input type="hidden" name="charset" value="UTF-8"' . $endTag . ' <input type="hidden" name="business" value="' . $this->paypal_account . '"' . $endTag . ' <input type="hidden" name="lc" value="' . strtoupper($GLOBALS['TL_LANGUAGE']) . '"' . $endTag; foreach ($this->Isotope->Cart->getProducts() as $objProduct) { $strOptions = ''; $arrOptions = $objProduct->getOptions(); if (is_array($arrOptions) && count($arrOptions)) { $options = array(); foreach ($arrOptions as $option) { $options[] = $option['label'] . ': ' . $option['value']; } $strOptions = ' (' . implode(', ', $options) . ')'; } $strBuffer .= ' <input type="hidden" name="item_number_' . ++$i . '" value="' . $objProduct->sku . '"' . $endTag . ' <input type="hidden" name="item_name_' . $i . '" value="' . $objProduct->name . $strOptions . '"' . $endTag . ' <input type="hidden" name="amount_' . $i . '" value="' . $objProduct->price . '"/> <input type="hidden" name="quantity_' . $i . '" value="' . $objProduct->quantity_requested . '"' . $endTag; } $fltDiscount = 0; foreach ($this->Isotope->Cart->getSurcharges() as $arrSurcharge) { if ($arrSurcharge['add'] === false) { continue; } // PayPal does only support one single discount item if ($arrSurcharge['total_price'] < 0) { $fltDiscount -= $arrSurcharge['total_price']; continue; } $strBuffer .= ' <input type="hidden" name="item_name_' . ++$i . '" value="' . $arrSurcharge['label'] . '"' . $endTag . ' <input type="hidden" name="amount_' . $i . '" value="' . $arrSurcharge['total_price'] . '"' . $endTag; } if ($fltDiscount > 0) { $strBuffer .= ' <input type="hidden" name="discount_amount_cart" value="' . $fltDiscount . '"' . $endTag; } $strBuffer .= ' <input type="hidden" name="no_shipping" value="1"' . $endTag . ' <input type="hidden" name="no_note" value="1"' . $endTag . ' <input type="hidden" name="currency_code" value="' . $this->Isotope->Config->currency . '"' . $endTag . ' <input type="hidden" name="button_subtype" value="services"' . $endTag . ' <input type="hidden" name="return" value="' . $this->Environment->base . IsotopeFrontend::addQueryStringToUrl('uid=' . $objOrder->uniqid, $this->addToUrl('step=complete')) . '"' . $endTag . ' <input type="hidden" name="cancel_return" value="' . $this->Environment->base . $this->addToUrl('step=failed') . '"' . $endTag . ' <input type="hidden" name="rm" value="1"' . $endTag . ' <input type="hidden" name="invoice" value="' . $objOrder->id . '"' . $endTag . ' <input type="hidden" name="address_override" value="' . ($this->debug ? '0' : '1') . '"' . $endTag . ' <input type="hidden" name="first_name" value="' . $this->Isotope->Cart->billingAddress['firstname'] . '"' . $endTag . ' <input type="hidden" name="last_name" value="' . $this->Isotope->Cart->billingAddress['lastname'] . '"' . $endTag . ' <input type="hidden" name="address1" value="' . $this->Isotope->Cart->billingAddress['street_1'] . '"' . $endTag . ' <input type="hidden" name="address2" value="' . $this->Isotope->Cart->billingAddress['street_2'] . '"' . $endTag . ' <input type="hidden" name="zip" value="' . $this->Isotope->Cart->billingAddress['postal'] . '"' . $endTag . ' <input type="hidden" name="city" value="' . $this->Isotope->Cart->billingAddress['city'] . '"' . $endTag . ' <input type="hidden" name="country" value="' . strtoupper($this->Isotope->Cart->billingAddress['country']) . '"' . $endTag . ' <input type="hidden" name="email" value="' . $this->Isotope->Cart->billingAddress['email'] . '"' . $endTag . ' <input type="hidden" name="night_phone_b" value="' . $this->Isotope->Cart->billingAddress['phone'] . '"' . $endTag . ' <input type="hidden" name="notify_url" value="' . $this->Environment->base . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id . '"' . $endTag . ' <input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynowCC_LG.gif:NonHosted"' . $endTag . ' <input type="' . (strlen($this->button) ? 'image" src="' . $this->button . '" border="0"' : 'submit" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]) . '"') . ' alt="PayPal - The safer, easier way to pay online!"' . $endTag . ' </form> ' . $startScript . ' window.addEvent( \'domready\' , function() { $(\'payment_form\').submit(); }); ' . $endScript; return $strBuffer; }
/** * Generate a product template * @param string * @param object * @return string */ public function generate($strTemplate, &$objModule) { global $objPage; $this->formSubmit = ($objModule instanceof ContentElement ? 'cte' : 'fmd') . $objModule->id . '_product_' . ($this->pid ? $this->pid : $this->id); $this->validateVariant(); $objTemplate = new IsotopeTemplate($strTemplate); $arrProductOptions = array(); $arrAjaxOptions = array(); $arrAttributes = $this->getAttributes(); foreach ($arrAttributes as $attribute => $varValue) { if ($GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute]['attributes']['customer_defined'] || $GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute]['attributes']['variant_option']) { $objTemplate->hasOptions = true; $arrProductOptions[$attribute] = array_merge($GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute], array('name' => $attribute, 'html' => $this->generateProductOptionWidget($attribute))); if ($GLOBALS['TL_DCA']['tl_iso_products']['fields'][$attribute]['attributes']['variant_option']) { $arrAjaxOptions[] = $attribute; } } else { $objTemplate->{$attribute} = $this->generateAttribute($attribute, $varValue); } } $arrButtons = array(); // Buttons if (isset($GLOBALS['ISO_HOOKS']['buttons']) && is_array($GLOBALS['ISO_HOOKS']['buttons'])) { foreach ($GLOBALS['ISO_HOOKS']['buttons'] as $callback) { $this->import($callback[0]); $arrButtons = $this->{$callback}[0]->{$callback}[1]($arrButtons); } $arrButtons = array_intersect_key($arrButtons, array_flip(deserialize($objModule->iso_buttons, true))); } if ($this->Input->post('FORM_SUBMIT') == $this->formSubmit && !$this->doNotSubmit) { foreach ($arrButtons as $button => $data) { if (strlen($this->Input->post($button))) { if (is_array($data['callback']) && count($data['callback']) == 2) { $this->import($data['callback'][0]); $this->{$data['callback'][0]}->{$data['callback'][1]}($this, $objModule); } break; } } } $objTemplate->buttons = $arrButtons; $objTemplate->quantityLabel = $GLOBALS['TL_LANG']['MSC']['quantity']; $objTemplate->useQuantity = $objModule->iso_use_quantity; $objTemplate->quantity_requested = $this->quantity_requested; $objTemplate->raw = array_merge($this->arrData, $this->arrCache); $objTemplate->raw_options = $this->arrOptions; $objTemplate->href_reader = $this->href_reader; $objTemplate->label_detail = $GLOBALS['TL_LANG']['MSC']['detailLabel']; $objTemplate->options = IsotopeFrontend::generateRowClass($arrProductOptions, 'product_option'); $objTemplate->hasOptions = count($arrProductOptions) > 0 ? true : false; $objTemplate->enctype = $this->hasUpload ? 'multipart/form-data' : 'application/x-www-form-urlencoded'; $objTemplate->formId = $this->formSubmit; $objTemplate->action = ampersand($this->Environment->request, true); $objTemplate->formSubmit = $this->formSubmit; list(, $startScript, $endScript) = IsotopeFrontend::getElementAndScriptTags(); $GLOBALS['TL_MOOTOOLS'][] = $startScript . "\nnew {$this->ajaxClass}('{$objModule->id}', '" . ($this->pid ? $this->pid : $this->id) . "', '{$this->formSubmit}', ['ctrl_" . implode("_" . $this->formSubmit . "', 'ctrl_", $arrAjaxOptions) . "_" . $this->formSubmit . "'], {language: '{$GLOBALS['TL_LANGUAGE']}', action: '" . ($objModule instanceof Module ? 'fmd' : 'cte') . "', page: {$objPage->id}, loadMessage:'" . specialchars($GLOBALS['ISO_LANG']['MSC']['loadingProductData']) . "'});\n" . $endScript; // HOOK for altering product data before output if (isset($GLOBALS['ISO_HOOKS']['generateProduct']) && is_array($GLOBALS['ISO_HOOKS']['generateProduct'])) { foreach ($GLOBALS['ISO_HOOKS']['generateProduct'] as $callback) { $this->import($callback[0]); $objTemplate = $this->{$callback}[0]->{$callback}[1]($objTemplate, $this); } } return $objTemplate->parse(); }
/** * 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]*(&|&)?)([^"]*)"@'); $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; }
public function checkoutReview() { $type = $_SESSION['CHECKOUT_DATA']['payment'][$this->id]['cc_type']; $num = $_SESSION['CHECKOUT_DATA']['payment'][$this->id]['cc_num']; $strCard = implode(' ', str_split(substr($num, 0, 2) . str_repeat('*', strlen($num) - 6) . substr($num, -4), 4)); list($endTag) = IsotopeFrontend::getElementAndScriptTags(); return sprintf('%s<br' . $endTag . '%s: %s', $this->label, $GLOBALS['ISO_LANG']['CCT'][$type], $strCard); }
public function checkoutForm() { $this->import('Isotope'); $fields = ''; // Get the current order, review page will create the data $objOrder = $this->Database->prepare("SELECT * FROM tl_iso_orders WHERE cart_id=?")->limit(1)->execute($this->Isotope->Cart->id); $doNotSubmit = false; $strBuffer = ''; $arrPayment = $this->Input->post('payment'); $arrCCTypes = deserialize($this->allowed_cc_types); //standard keys foreach ($arrCCTypes as $type) { // numeric keys specific to Cybersource // @todo merchant bank makes a difference! $arrAllowedCCTypes[] = $this->arrCardTypes[$type]; } $intStartYear = (int) date('Y', time()); //4-digit year for ($i = 0; $i <= 7; $i++) { $arrYears[] = (string) $intStartYear + $i; } //card_accountNumber,card_cardType,card_expirationMonth,card_expirationYear,card_cvNumber $arrFields = array('card_accountNumber' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_num'], 'inputType' => 'text', 'eval' => array('mandatory' => true, 'rgxp' => 'digit', 'tableless' => true)), 'card_cardType' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_type'], 'inputType' => 'select', 'options' => $arrAllowedCCTypes, 'eval' => array('mandatory' => true, 'rgxp' => 'digit', 'tableless' => true), 'reference' => &$GLOBALS['ISO_LANG']['CCT']), 'card_expirationMonth' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_exp_month'], 'inputType' => 'select', 'options' => array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'), 'eval' => array('mandatory' => true, 'tableless' => true, 'includeBlankOption' => true)), 'card_expirationYear' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_exp_year'], 'inputType' => 'select', 'options' => $arrYears, 'eval' => array('mandatory' => true, 'tableless' => true, 'includeBlankOption' => true)), 'card_cvNumber' => array('label' => &$GLOBALS['TL_LANG']['ISO']['cc_ccv'], 'inputType' => 'text', 'eval' => array('mandatory' => true, 'tableless' => true))); foreach ($arrFields as $field => $arrData) { $strClass = $GLOBALS['TL_FFL'][$arrData['inputType']]; // Continue if the class is not defined if (!$this->classFileExists($strClass)) { continue; } $objWidget = new $strClass($this->prepareForWidget($arrData, 'payment[' . $field . ']')); // Validate input if ($this->Input->post('FORM_SUBMIT') == 'iso_mod_checkout_payment' && $arrPayment['module'] == $this->id) { $objWidget->validate(); if ($objWidget->hasErrors()) { $doNotSubmit = true; } } elseif ($objWidget->mandatory && !strlen($arrPayment[$field])) { $doNotSubmit = true; } $strBuffer .= $objWidget->parse(); } global $objPage; $objOrder = $this->Database->prepare("SELECT * FROM tl_iso_orders WHERE cart_id=?")->limit(1)->execute($this->Isotope->Cart->id); $intTotal = round($this->Isotope->Cart->grandTotal, 2); $arrSubdivision = explode('-', $this->Isotope->Cart->billingAddress['subdivision']); if (!$doNotSubmit && $this->Input->post('FORM_SUBMIT') == 'payment_form') { try { $objSoapClient = new CybersourceClient('https://ics2ws' . ($this->debug ? 'test' : '') . '.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.26.wsdl', array(), $this->cybersource_merchant_id, $this->cybersource_trans_key); $objRequest = new stdClass(); $objRequest->merchantID = $this->cybersource_merchant_id; // Before using this example, replace the generic value with your own. $objRequest->merchantReferenceCode = $objOrder->id; // To help us troubleshoot any problems that you may encounter, // please include the following information about your PHP application. $objRequest->clientLibrary = "PHP"; $objRequest->clientLibraryVersion = phpversion(); $objRequest->clientEnvironment = php_uname(); // This section builds the transaction information // service with complete billing, payment card, and purchase (two items) information. $objCCAuthService = new stdClass(); $objCCAuthService->run = "true"; $objRequest->ccAuthService = $objCCAuthService; $objBillTo = new stdClass(); $objBillTo->firstName = $this->Isotope->Cart->billingAddress['firstname']; $objBillTo->lastName = $this->Isotope->Cart->billingAddress['lastname']; $objBillTo->street1 = $this->Isotope->Cart->billingAddress['street_1']; $objBillTo->city = $this->Isotope->Cart->billingAddress['city']; $objBillTo->state = $arrSubdivision[1]; $objBillTo->postalCode = $this->Isotope->Cart->billingAddress['postal']; $objBillTo->country = $this->Isotope->Cart->billingAddress['country']; $objBillTo->email = $this->Isotope->Cart->billingAddress['email']; $objBillTo->ipAddress = $this->Environment->ip; $objRequest->billTo = $objBillTo; $objCard = new stdClass(); $objCard->accountNumber = $arrPayment['card_accountNumber']; $objCard->expirationMonth = $arrPayment['card_expirationMonth']; $objCard->expirationYear = $arrPayment['card_expirationYear']; //if($this->requireCardType) $objCard->cardType = $arrPayment['card_cardType']; if ($this->requireCCV) { $objCard->cvNumber = $arrPayment['card_cvNumber']; } $objRequest->card = $objCard; $objPurchaseTotals = new stdClass(); $objPurchaseTotals->currency = $this->Isotope->Config->currency; $objPurchaseTotals->grandTotalAmount = round($this->Isotope->Cart->grandTotal, 2); $objRequest->purchaseTotals = $objPurchaseTotals; /*$arrProducts = $this->Isotope->Cart->getProducts(); foreach($arrProducts as $i=>$objProduct) { $objItem = new stdClass(); $objItem->unitPrice = $objProduct->price; $objItem->quantity = $objProduct->quantity; $objItem->id = $objProduct->id; $arrItems[] = $objItem; } $objRequest->item = $arrItems;*/ //, $strLocation, $strAction, $strVersion, $strMerchantId, $strTransactionKey $objReply = $objSoapClient->runTransaction($objRequest); $arrPaymentData['transaction_response'] = $objReply->decision; $arrPaymentData['transaction_response_code'] = $objReply->reasonCode; $arrPaymentData['request_id'] = $objReply->requestID; $arrPaymentData['request_token'] = $objReply->requestToken; $arrSet['payment_data'] = serialize($arrPaymentData); switch ($objReply->decision) { case 'ACCEPT': $arrPaymentData['cc_last_four'] = substr($strCCNum, strlen($strCCNum) - 4, 4); break; default: $blnFail = true; break; } $this->Database->prepare("UPDATE tl_iso_orders %s WHERE id={$objOrder->id}")->set($arrSet)->executeUncached(); if ($blnFail) { $this->log('Invalid payment data received.', 'PaymentCybersource checkoutForm()', TL_ERROR); $this->redirect(IsotopeFrontend::addQueryStringToUrl('error=' . $objReply->reasonCode)); } $this->redirect($this->addToUrl('step=complete', true)); } catch (SoapFault $exception) { var_dump(get_class($exception)); var_dump($exception); } } list($endTag) = IsotopeFrontend::getElementAndScriptTags(); return ' <h2>' . $this->label . '</h2>' . ($this->Input->get('error') == '' ? '' : '<p class="error message">' . $GLOBALS['TL_LANG']['CYB'][$this->Input->get('error')] . '</p>') . '<form id="payment_form" action="' . $this->Environment->request . '" method="post"> <input type="hidden" name="FORM_SUBMIT" value="payment_form"' . $endTag . ' <input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '"' . $endTag . $strBuffer . ' <input type="submit" value="' . specialchars($GLOBALS['TL_LANG']['MSC']['confirmOrder']) . '"' . $endTag . ' </form>'; }
/** * Return an object property * @param string * @return mixed */ public function __get($strKey) { switch ($strKey) { case 'label': return $this->Isotope->translate($this->arrData['label'] ? $this->arrData['label'] : $this->arrData['name']); break; case 'available': if (!$this->enabled && BE_USER_LOGGED_IN !== true) { return false; } if ($this->guests && FE_USER_LOGGED_IN === true || $this->protected && FE_USER_LOGGED_IN !== true) { return false; } if ($this->protected) { $this->import('FrontendUser', 'User'); $arrGroups = deserialize($this->groups); if (!is_array($arrGroups) || !count($arrGroups) || !count(array_intersect($arrGroups, $this->User->groups))) { return false; } } if ($this->minimum_total > 0 && $this->minimum_total > $this->Isotope->Cart->subTotal || $this->maximum_total > 0 && $this->maximum_total < $this->Isotope->Cart->subTotal) { return false; } $arrCountries = deserialize($this->countries); if (is_array($arrCountries) && !empty($arrCountries) && !in_array($this->Isotope->Cart->shippingAddress['country'], $arrCountries)) { return false; } $arrSubdivisions = deserialize($this->subdivisions); if (is_array($arrSubdivisions) && !empty($arrSubdivisions) && !in_array($this->Isotope->Cart->shippingAddress['subdivision'], $arrSubdivisions)) { return false; } // Check if address has a valid postal code if ($this->postalCodes != '') { $arrCodes = IsotopeFrontend::parsePostalCodes($this->postalCodes); if (!in_array($this->Isotope->Cart->shippingAddress['postal'], $arrCodes)) { return false; } } $arrTypes = deserialize($this->product_types); if (is_array($arrTypes) && count($arrTypes)) { $arrProducts = $this->Isotope->Cart->getProducts(); foreach ($arrProducts as $objProduct) { if (!in_array($objProduct->type, $arrTypes)) { return false; } } } return true; break; case 'price': $strPrice = $this->arrData['price']; $blnPercentage = substr($strPrice, -1) == '%' ? true : false; if ($blnPercentage) { $fltSurcharge = (double) substr($strPrice, 0, -1); $fltPrice = $this->Isotope->Cart->subTotal / 100 * $fltSurcharge; } else { $fltPrice = (double) $strPrice; } return $this->Isotope->calculatePrice($fltPrice, $this, 'price', $this->arrData['tax_class']); break; case 'surcharge': return substr($this->arrData['price'], -1) == '%' ? $this->arrData['price'] : ''; break; } return $this->arrData[$strKey]; }
/** * 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(); }
/** * 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); } } }
/** * Return the payment form. * * @access public * @return string */ public function checkoutForm() { $objOrder = new IsotopeOrder(); if (!$objOrder->findBy('cart_id', $this->Isotope->Cart->id)) { $this->redirect($this->addToUrl('step=failed', true)); } $arrAddress = $this->Isotope->Cart->billingAddress; $strFailedUrl = $this->Environment->base . $this->addToUrl('step=failed'); $arrParam = array('PSPID' => $this->postfinance_pspid, 'orderID' => $objOrder->id, 'amount' => round($this->Isotope->Cart->grandTotal * 100), 'currency' => $this->Isotope->Config->currency, 'language' => $GLOBALS['TL_LANGUAGE'] . '_' . strtoupper($GLOBALS['TL_LANGUAGE']), 'CN' => $arrAddress['firstname'] . ' ' . $arrAddress['lastname'], 'EMAIL' => $arrAddress['email'], 'ownerZIP' => $arrAddress['postal'], 'owneraddress' => $arrAddress['street_1'], 'owneraddress2' => $arrAddress['street_2'], 'ownercty' => $arrAddress['country'], 'ownertown' => $arrAddress['city'], 'ownertelno' => $arrAddress['phone'], 'accepturl' => $this->Environment->base . IsotopeFrontend::addQueryStringToUrl('uid=' . $objOrder->uniqid, $this->addToUrl('step=complete')), 'declineurl' => $strFailedUrl, 'exceptionurl' => $strFailedUrl, 'paramplus' => 'mod=pay&id=' . $this->id); // SHA-1 must be generated on alphabetically sorted keys. Cant use ksort because it does not ignore key case. uksort($arrParam, 'strcasecmp'); $strSHASign = ''; foreach ($arrParam as $k => $v) { if ($v == '') { continue; } $strSHASign .= strtoupper($k) . '=' . $v . $this->postfinance_secret; } $arrParam['SHASign'] = sha1($strSHASign); $objTemplate = new FrontendTemplate('iso_payment_postfinance'); $objTemplate->action = 'https://e-payment.postfinance.ch/ncol/' . ($this->debug ? 'test' : 'prod') . '/orderstandard.asp'; $objTemplate->params = $arrParam; $objTemplate->slabel = $GLOBALS['TL_LANG']['MSC']['pay_with_cc'][2]; $objTemplate->id = $this->id; return $objTemplate->parse(); }
/** * Generate the current step widgets. * strResourceTable is used either to load a DCA or else to gather settings related to a given DCA. * * @todo <table...> was in a template, but I don't get why we need to define the table here? * @param string * @param integer * @return string */ protected function generateAddressWidgets($strAddressType, $intOptions) { $arrWidgets = array(); $this->loadLanguageFile('tl_iso_addresses'); $this->loadDataContainer('tl_iso_addresses'); $arrFields = $strAddressType == 'billing_address' ? $this->Isotope->Config->billing_fields : $this->Isotope->Config->shipping_fields; $arrDefault = $this->Isotope->Cart->{$strAddressType}; if ($arrDefault['id'] == -1) { $arrDefault = array(); } foreach ($arrFields as $field) { $arrData = $GLOBALS['TL_DCA']['tl_iso_addresses']['fields'][$field['value']]; if (!is_array($arrData) || !$arrData['eval']['feEditable'] || !$field['enabled'] || $arrData['eval']['membersOnly'] && FE_USER_LOGGED_IN !== true) { continue; } $strClass = $GLOBALS['TL_FFL'][$arrData['inputType']]; // Continue if the class is not defined if (!$this->classFileExists($strClass)) { continue; } // Special field "country" if ($field['value'] == 'country') { $arrCountries = $strAddressType == 'billing_address' ? $this->Isotope->Config->billing_countries : $this->Isotope->Config->shipping_countries; $arrData['options'] = array_values(array_intersect($arrData['options'], $arrCountries)); $arrDefault['country'] = $this->Isotope->Config->country; } elseif (strlen($arrData['eval']['conditionField'])) { $arrData['eval']['conditionField'] = $strAddressType . '_' . $arrData['eval']['conditionField']; } elseif ($field['value'] == 'isDefaultBilling' && $strAddressType == 'billing_address' && $intOptions < 2 || $field['value'] == 'isDefaultShipping' && $strAddressType == 'shipping_address' && $intOptions < 3) { $arrDefault[$field['value']] = '1'; } $objWidget = new $strClass($this->prepareForWidget($arrData, $strAddressType . '_' . $field['value'], strlen($_SESSION['CHECKOUT_DATA'][$strAddressType][$field['value']]) ? $_SESSION['CHECKOUT_DATA'][$strAddressType][$field['value']] : $arrDefault[$field['value']])); $objWidget->mandatory = $field['mandatory'] ? true : false; $objWidget->required = $objWidget->mandatory; $objWidget->tableless = $this->tableless; $objWidget->label = $field['label'] ? $this->Isotope->translate($field['label']) : $objWidget->label; $objWidget->storeValues = true; // Validate input if ($this->Input->post('FORM_SUBMIT') == $this->strFormId && ($this->Input->post($strAddressType) === '0' || $this->Input->post($strAddressType) == '')) { $objWidget->validate(); $varValue = $objWidget->value; // Convert date formats into timestamps if (strlen($varValue) && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim'))) { $objDate = new Date($varValue, $GLOBALS['TL_CONFIG'][$arrData['eval']['rgxp'] . 'Format']); $varValue = $objDate->tstamp; } // Do not submit if there are errors if ($objWidget->hasErrors()) { $this->doNotSubmit = true; } elseif ($objWidget->submitInput()) { $arrAddress[$field['value']] = $varValue; } } elseif ($this->Input->post($strAddressType) === '0' || $this->Input->post($strAddressType) == '') { $this->Input->setPost($objWidget->name, $objWidget->value); $objValidator = clone $objWidget; $objValidator->validate(); if ($objValidator->hasErrors()) { $this->doNotSubmit = true; } } $arrWidgets[] = $objWidget; } $arrWidgets = IsotopeFrontend::generateRowClass($arrWidgets, 'row', 'rowClass', 0, ISO_CLASS_COUNT | ISO_CLASS_FIRSTLAST | ISO_CLASS_EVENODD); // Validate input if ($this->Input->post('FORM_SUBMIT') == $this->strFormId && !$this->doNotSubmit && is_array($arrAddress) && count($arrAddress)) { $arrAddress['id'] = 0; $_SESSION['CHECKOUT_DATA'][$strAddressType] = $arrAddress; } if (is_array($_SESSION['CHECKOUT_DATA'][$strAddressType]) && $_SESSION['CHECKOUT_DATA'][$strAddressType]['id'] === 0) { $this->Isotope->Cart->{$strAddressType} = $_SESSION['CHECKOUT_DATA'][$strAddressType]; } $strBuffer = ''; foreach ($arrWidgets as $objWidget) { $strBuffer .= $objWidget->parse(); } if ($this->tableless) { return $strBuffer; } return ' <table> ' . $strBuffer . ' </table>'; }
/** * Generate the module * @return void */ protected function compile() { $objOrders = $this->Database->execute("SELECT *, (SELECT COUNT(*) FROM tl_iso_order_items WHERE pid=tl_iso_orders.id) AS items FROM tl_iso_orders WHERE status!='' AND pid=" . $this->User->id . " AND config_id IN (" . implode(',', $this->iso_config_ids) . ") ORDER BY date DESC"); // No orders found, just display an "empty" message if (!$objOrders->numRows) { $this->Template = new FrontendTemplate('mod_message'); $this->Template->type = 'empty'; $this->Template->message = $GLOBALS['TL_LANG']['ERR']['emptyOrderHistory']; return; } $this->import('Isotope'); $arrOrders = array(); while ($objOrders->next()) { if ($this->Isotope->Config->id != $objOrders->config_id) { $this->Isotope->overrideConfig($objOrders->config_id); } $arrOrders[] = array('raw' => $objOrders->row(), 'date' => $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objOrders->date), 'time' => $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $objOrders->date), 'datime' => $this->parseDate($GLOBALS['TL_CONFIG']['datimeFormat'], $objOrders->date), 'items' => $objOrders->items, 'grandTotal' => $this->Isotope->formatPriceWithCurrency($objOrders->grandTotal), 'status' => $GLOBALS['TL_LANG']['ORDER'][$objOrders->status], 'link' => $this->jumpTo ? IsotopeFrontend::addQueryStringToUrl('uid=' . $objOrders->uniqid, $this->jumpTo) : ''); } $this->Template->orders = $arrOrders; $this->Template->dateLabel = $GLOBALS['TL_LANG']['MSC']['iso_order_date']; $this->Template->statusLabel = $GLOBALS['TL_LANG']['MSC']['iso_order_status']; $this->Template->subTotalLabel = $GLOBALS['TL_LANG']['MSC']['subTotalLabel']; $this->Template->grandTotalLabel = $GLOBALS['TL_LANG']['MSC']['grandTotalLabel']; $this->Template->quantityLabel = $GLOBALS['TL_LANG']['MSC']['iso_quantity_header']; $this->Template->detailsLabel = $GLOBALS['TL_LANG']['MSC']['detailLabel']; }
/** * The ids of all pages we take care of. This is what should later be used eg. for filter data. * @param string * @return array */ protected function findCategories($strCategoryScope) { if ($this->defineRoot && $this->rootPage > 0) { $objPage = $this->getPageDetails($this->rootPage); } else { global $objPage; } switch ($strCategoryScope) { case 'global': $arrCategories = $this->getChildRecords($objPage->rootId, 'tl_page'); $arrCategories[] = $objPage->rootId; break; case 'current_and_first_child': $arrCategories = $this->Database->execute("SELECT id FROM tl_page WHERE pid={$objPage->id}")->fetchEach('id'); $arrCategories[] = $objPage->id; break; case 'current_and_all_children': $arrCategories = $this->getChildRecords($objPage->id, 'tl_page'); $arrCategories[] = $objPage->id; break; case 'parent': $arrCategories = array($objPage->pid); break; case 'product': $objProduct = IsotopeFrontend::getProductByAlias($this->Input->get('product')); if ($objProduct !== null) { $arrCategories = $objProduct->categories; } else { return array(0); } break; case 'current_category': default: $arrCategories = array($objPage->id); break; } return empty($arrCategories) ? array(0) : $arrCategories; }
/** * List all addresses for the current frontend user * @return void */ protected function show() { global $objPage; $arrAddresses = array(); $strUrl = $this->generateFrontendUrl($objPage->row()) . ($GLOBALS['TL_CONFIG']['disableAlias'] ? '&' : '?'); $objAddress = $this->Database->execute("SELECT * FROM tl_iso_addresses WHERE pid={$this->User->id} AND store_id={$this->Isotope->Config->store_id}"); while ($objAddress->next()) { $arrAddresses[] = array_merge($objAddress->row(), array('id' => $objAddress->id, 'class' => ($objAddress->isDefaultBilling ? 'default_billing' : '') . ($objAddress->isDefaultShipping ? ' default_shipping' : ''), 'text' => $this->Isotope->generateAddressString($objAddress->row()), 'edit_url' => ampersand($strUrl . 'act=edit&address=' . $objAddress->id), 'delete_url' => ampersand($strUrl . 'act=delete&address=' . $objAddress->id), 'default_billing' => $objAddress->isDefaultBilling ? true : false, 'default_shipping' => $objAddress->isDefaultShipping ? true : false)); } if (empty($arrAddresses)) { $this->Template->mtype = 'empty'; $this->Template->message = $GLOBALS['TL_LANG']['ERR']['noAddressBookEntries']; } $this->Template->addNewAddressLabel = $GLOBALS['TL_LANG']['MSC']['createNewAddressLabel']; $this->Template->editAddressLabel = $GLOBALS['TL_LANG']['MSC']['editAddressLabel']; $this->Template->deleteAddressLabel = $GLOBALS['TL_LANG']['MSC']['deleteAddressLabel']; $this->Template->deleteAddressConfirm = specialchars($GLOBALS['TL_LANG']['MSC']['deleteAddressConfirm']); $this->Template->addresses = IsotopeFrontend::generateRowClass($arrAddresses, '', 'class', 0, ISO_CLASS_FIRSTLAST | ISO_CLASS_EVENODD); $this->Template->addNewAddress = ampersand($strUrl . 'act=create'); }
/** * Gets the product reader of a certain page * @param Database_Result|int page object or page ID * @param int override setting from a module or content element * @return int reader page id */ public static function getReaderPageId($objOriginPage = null, $intOverride = 0) { if ($intOverride > 0) { return $intOverride; } if ($objOriginPage === null) { global $objPage; $objOriginPage = $objPage; } $intPage = is_object($objOriginPage) ? (int) $objOriginPage->id : (int) $objOriginPage; // return from cache if (isset(self::$arrReaderPageIds[$intPage])) { return self::$arrReaderPageIds[$intPage]; } $objDatabase = Database::getInstance(); if (!is_object($objOriginPage)) { $objOriginPage = $objDatabase->execute("SELECT * FROM tl_page WHERE id=" . $intPage); } // if the reader page is set on the current page id we return this one if ($objOriginPage->iso_setReaderJumpTo > 0) { self::$arrReaderPageIds[$intPage] = $objOriginPage->iso_readerJumpTo; return $objOriginPage->iso_readerJumpTo; } // now move up the page tree until we find a page where the reader is set $trail = array(); $pid = $objOriginPage->pid; do { $objParentPage = $objDatabase->execute("SELECT * FROM tl_page WHERE id=" . $pid); if ($objParentPage->numRows < 1) { break; } $trail[] = $objParentPage->id; if ($objParentPage->iso_setReaderJumpTo > 0) { // cache the reader page for all trail pages self::$arrReaderPageIds = array_merge(self::$arrReaderPageIds, array_fill_keys($trail, $objParentPage->iso_readerJumpTo)); return $objParentPage->iso_readerJumpTo; } $pid = $objParentPage->pid; } while ($pid > 0 && $objParentPage->type != 'root'); // if there is no reader page set at all, we take the current page object global $objPage; self::$arrReaderPageIds[$intPage] = $objPage->id; return $objPage->id; }
/** * Determine whether to use the tax rate or not * @param object * @param float * @param array * @return boolean */ public function useTaxRate($objRate, $fltPrice, $arrAddresses) { if ($objRate->config > 0 && $objRate->config != $this->Config->id) { return false; } $objRate->address = deserialize($objRate->address); // HOOK for altering taxes if (isset($GLOBALS['ISO_HOOKS']['useTaxRate']) && is_array($GLOBALS['ISO_HOOKS']['useTaxRate'])) { foreach ($GLOBALS['ISO_HOOKS']['useTaxRate'] as $callback) { $this->import($callback[0]); $varValue = $this->{$callback}[0]->{$callback}[1]($objRate, $fltPrice, $arrAddresses); if ($varValue !== true) { return false; } } } if (is_array($objRate->address) && count($objRate->address)) { foreach ($arrAddresses as $name => $arrAddress) { if (!in_array($name, $objRate->address)) { continue; } if (strlen($objRate->country) && $objRate->country != $arrAddress['country']) { continue; } if (strlen($objRate->subdivision) && $objRate->subdivision != $arrAddress['subdivision']) { continue; } // Check if address has a valid postal code if ($objRate->postalCodes != '') { $arrCodes = IsotopeFrontend::parsePostalCodes($objRate->postalCodes); if (!in_array($arrAddress['postal'], $arrCodes)) { continue; } } $arrPrice = deserialize($objRate->amount); if (is_array($arrPrice) && count($arrPrice) && strlen($arrPrice[0])) { if (strlen($arrPrice[1])) { if ($arrPrice[0] > $fltPrice || $arrPrice[1] < $fltPrice) { continue; } } else { if ($arrPrice[0] != $fltPrice) { continue; } } } // This address is valid, otherwise one of the check would have skipped this (continue) return true; } // No address has passed all checks and returned true return false; } // Addresses are not checked at all, return true return true; }
/** * Generate products from database result or array of IDs * @deprecated * @see IsotopeFrontend::getProducts() */ protected function getProducts($objProductData, $blnCheckAvailability = true, array $arrFilters = array(), array $arrSorting = array()) { trigger_error('Using ContentIsotope::getProducts() is deprecated. Please use IsotopeFrontend::getProducts()', E_USER_NOTICE); return IsotopeFrontend::getProducts($objProductData, IsotopeFrontend::getReaderPageId(null, $this->iso_reader_jumpTo), $blnCheckAvailability, $arrFilters, $arrSorting); }