/** * Check the cart currency for ePay support * * @return bool */ public function isAvailable() { if (!static::supportsCurrency(Isotope::getConfig()->currency)) { return false; } return parent::isAvailable(); }
/** * Check the cart currency for ePay support * * @return bool */ public function isAvailable() { if (!Currency::isSupported(Isotope::getConfig()->currency)) { return false; } return parent::isAvailable(); }
/** * Generate the module */ protected function compile() { $objCart = Isotope::getCart(); $objAddress = $objCart->getShippingAddress(); $this->Template->showResults = false; $this->Template->requiresShipping = false; // There is no address if (!$objAddress->id) { return; } $this->Template->showResults = true; $arrMethods = array(); // Get the shipping methods if ($objAddress->id && $objCart->requiresShipping()) { $this->Template->requiresShipping = true; $objShippingMethods = Shipping::findMultipleByIds($this->arrShippingMethods); /* @var Shipping $objShipping */ foreach ($objShippingMethods as $objShipping) { if ($objShipping->isAvailable()) { $fltPrice = $objShipping->getPrice(); $arrMethods[] = array('label' => $objShipping->getLabel(), 'price' => $fltPrice, 'formatted_price' => Isotope::formatPriceWithCurrency($fltPrice), 'shipping' => $objShipping); } } RowClass::withKey('rowClass')->addCount('row_')->addFirstLast('row_')->addEvenOdd('row_')->applyTo($arrMethods); } $this->Template->shippingMethods = $arrMethods; }
/** * Generate the checkout step * * @return string */ public function generate() { $objTemplate = new Template($this->objModule->iso_collectionTpl); $objOrder = Isotope::getCart()->getDraftOrder(); $objOrder->addToTemplate($objTemplate, array('gallery' => $this->objModule->iso_gallery, 'sorting' => $objOrder->getItemsSortingCallable($this->objModule->iso_orderCollectionBy))); return $objTemplate->parse(); }
/** * Fill the object's arrProducts array * * @param array|null $arrCacheIds * * @return array */ protected function findProducts($arrCacheIds = null) { $t = Product::getTable(); $arrColumns = array(); $arrCategories = $this->findCategories(); $arrProductIds = \Database::getInstance()->query("\n SELECT pid\n FROM tl_iso_product_category\n WHERE page_id IN (" . implode(',', $arrCategories) . ")\n ")->fetchEach('pid'); $arrTypes = \Database::getInstance()->query("SELECT id FROM tl_iso_producttype WHERE variants='1'")->fetchEach('id'); if (empty($arrProductIds)) { return array(); } $queryBuilder = new FilterQueryBuilder(Isotope::getRequestCache()->getFiltersForModules($this->iso_filterModules)); $arrColumns[] = "(\n ({$t}.id IN (" . implode(',', $arrProductIds) . ") AND {$t}.type NOT IN (" . implode(',', $arrTypes) . "))\n OR {$t}.pid IN (" . implode(',', $arrProductIds) . ")\n )"; if (!empty($arrCacheIds) && is_array($arrCacheIds)) { $arrColumns[] = Product::getTable() . ".id IN (" . implode(',', $arrCacheIds) . ")"; } // Apply new/old product filter if ($this->iso_newFilter == 'show_new') { $arrColumns[] = Product::getTable() . ".dateAdded>=" . Isotope::getConfig()->getNewProductLimit(); } elseif ($this->iso_newFilter == 'show_old') { $arrColumns[] = Product::getTable() . ".dateAdded<" . Isotope::getConfig()->getNewProductLimit(); } if ($this->iso_list_where != '') { $arrColumns[] = $this->iso_list_where; } if ($queryBuilder->hasSqlCondition()) { $arrColumns[] = $queryBuilder->getSqlWhere(); } $arrSorting = Isotope::getRequestCache()->getSortingsForModules($this->iso_filterModules); if (empty($arrSorting) && $this->iso_listingSortField != '') { $direction = $this->iso_listingSortDirection == 'DESC' ? Sort::descending() : Sort::ascending(); $arrSorting[$this->iso_listingSortField] = $direction; } $objProducts = Product::findAvailableBy($arrColumns, $queryBuilder->getSqlValues(), array('order' => 'c.sorting', 'filters' => $queryBuilder->getFilters(), 'sorting' => $arrSorting)); return null === $objProducts ? array() : $objProducts->getModels(); }
/** * Generate the checkout step * @return string */ public function generate() { // Make sure field data is available \Controller::loadDataContainer('tl_iso_product_collection'); \System::loadLanguageFile('tl_iso_product_collection'); $objTemplate = new Template($this->strTemplate); $varValue = null; $objWidget = new FormTextArea(FormTextArea::getAttributesFromDca($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField], $this->strField, $varValue, $this->strField, $this->strTable, $this)); $objWidget->storeValues = true; if (\Input::post('FORM_SUBMIT') == $this->strFormId) { $objWidget->validate(); $varValue = $objWidget->value; // Do not submit the field if there are errors if ($objWidget->hasErrors()) { $doNotSubmit = true; } elseif ($objWidget->submitInput()) { $objOrder = Isotope::getCart()->getDraftOrder(); // Store the form data $_SESSION['FORM_DATA'][$this->strField] = $varValue; // Set the correct empty value (see #6284, #6373) if ($varValue === '') { $varValue = $objWidget->getEmptyValue(); } // Set the new value if ($varValue !== $objOrder->{$this->strField}) { $objOrder->{$this->strField}; } } } $objTemplate->headline = $GLOBALS['TL_LANG'][$this->strTable][$this->strField][0]; $objTemplate->customerNotes = $objWidget->parse(); return $objTemplate->parse(); }
/** * sofortueberweisung.de only supports these currencies * @return true */ public function isAvailable() { if (!in_array(Isotope::getConfig()->currency, array('EUR', 'CHF', 'GBP'))) { return false; } return parent::isAvailable(); }
/** * Generate the module */ protected function compile() { // Also check owner (see #126) if (($objOrder = Order::findOneBy('uniqid', (string) \Input::get('uid'))) === null || FE_USER_LOGGED_IN === true && $objOrder->member > 0 && \FrontendUser::getInstance()->id != $objOrder->member) { $this->Template = new \Isotope\Template('mod_message'); $this->Template->type = 'error'; $this->Template->message = $GLOBALS['TL_LANG']['ERR']['orderNotFound']; return; } // Order belongs to a member but not logged in if (TL_MODE == 'FE' && $this->iso_loginRequired && $objOrder->member > 0 && FE_USER_LOGGED_IN !== true) { global $objPage; $objHandler = new $GLOBALS['TL_PTY']['error_403'](); $objHandler->generate($objPage->id); exit; } Isotope::setConfig($objOrder->getRelated('config_id')); $objTemplate = new \Isotope\Template($this->iso_collectionTpl); $objTemplate->linkProducts = true; $objOrder->addToTemplate($objTemplate, array('gallery' => $this->iso_gallery, 'sorting' => $objOrder->getItemsSortingCallable($this->iso_orderCollectionBy))); $this->Template->collection = $objOrder; $this->Template->products = $objTemplate->parse(); $this->Template->info = deserialize($objOrder->checkout_info, true); $this->Template->date = Format::date($objOrder->locked); $this->Template->time = Format::time($objOrder->locked); $this->Template->datim = Format::datim($objOrder->locked); $this->Template->orderDetailsHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['orderDetailsHeadline'], $objOrder->document_number, $this->Template->datim); $this->Template->orderStatus = sprintf($GLOBALS['TL_LANG']['MSC']['orderStatusHeadline'], $objOrder->getStatusLabel()); $this->Template->orderStatusKey = $objOrder->getStatusAlias(); }
/** * Paybyway only supports EUR currency * @return bool */ public function isAvailable() { $objConfig = Isotope::getConfig(); if (null === $objConfig || $objConfig->currency != 'EUR') { return false; } return parent::isAvailable(); }
/** * Automatically add Billpay conditions to checkout form * * @param Form $objForm * @param \Module $objModule */ public static function addOrderCondition(Form $objForm, \Module $objModule) { if (Isotope::getCart()->hasPayment() && Isotope::getCart()->getPaymentMethod() instanceof BillpayWithSaferpay) { $strLabel = $GLOBALS['TL_LANG']['MSC']['billpay_agb_' . Isotope::getCart()->getBillingAddress()->country]; if ($strLabel == '') { throw new \LogicException('Missing BillPay AGB for country "' . Isotope::getCart()->getBillingAddress()->country . '" and language "' . $GLOBALS['TL_LANGUAGE'] . '"'); } $objForm->addFormField('billpay_confirmation', array('label' => array('', $strLabel), 'inputType' => 'checkbox', 'eval' => array('mandatory' => true))); } }
public function generate(IsotopeProduct $objProduct, array $arrOptions = array()) { $arrData = deserialize($objProduct->{$this->field_name}); if (is_array($arrData) && $arrData['unit'] > 0 && $arrData['value'] != '') { $objBasePrice = \Isotope\Model\BasePrice::findByPk((int) $arrData['unit']); if (null !== $objBasePrice && null !== $objProduct->getPrice()) { return sprintf($objBasePrice->getLabel(), Isotope::formatPriceWithCurrency($objProduct->getPrice()->getAmount() / $arrData['value'] * $objBasePrice->amount), $arrData['value']); } } return ''; }
/** * Compile the module * @return void */ protected function compile() { $arrConfigs = array(); $objConfigs = Config::findMultipleByIds($this->iso_config_ids); if (null !== $objConfigs) { while ($objConfigs->next()) { $arrConfigs[] = array('config' => $objConfigs->current(), 'label' => $objConfigs->current()->getLabel(), 'active' => Isotope::getConfig()->id == $objConfigs->id ? true : false, 'href' => \Environment::get('request') . (strpos(\Environment::get('request'), '?') === false ? '?' : '&') . 'config=' . $objConfigs->id); } } \Haste\Generator\RowClass::withKey('class')->addFirstLast()->applyTo($arrConfigs); $this->Template->configs = $arrConfigs; }
/** * Actually execute the GoogleAnalytics tracking * @param Database_Result * @param IsotopeProductCollection */ protected function trackGATransaction($objConfig, $objOrder) { // Initilize GA Tracker $tracker = new \UnitedPrototype\GoogleAnalytics\Tracker($objConfig->ga_account, \Environment::get('base')); // Assemble Visitor information // (could also get unserialized from database) $visitor = new \UnitedPrototype\GoogleAnalytics\Visitor(); $visitor->setIpAddress(\Environment::get('ip')); $visitor->setUserAgent(\Environment::get('httpUserAgent')); $transaction = new \UnitedPrototype\GoogleAnalytics\Transaction(); $transaction->setOrderId($objOrder->order_id); $transaction->setAffiliation($objConfig->name); $transaction->setTotal($objOrder->getTotal()); $transaction->setTax($objOrder->getTotal() - $objOrder->getTaxFreeTotal()); // $transaction->setShipping($objOrder->shippingTotal); $objAddress = $objOrder->getBillingAddress(); $transaction->setCity($objAddress->city); if ($objAddress->subdivision) { $arrSub = explode("-", $objAddress->subdivision, 2); $transaction->setRegion($arrSub[1]); } $transaction->setCountry($objAddress->country); /** @var \Isotope\Model\ProductCollectionItem $objItem */ foreach ($objOrder->getItems() as $objItem) { $item = new \UnitedPrototype\GoogleAnalytics\Item(); if ($objItem->getSku()) { $item->setSku($objItem->getSku()); } else { $item->setSku('product' . $objItem->product_id); } $item->setName($objItem->getName()); $item->setPrice($objItem->getPrice()); $item->setQuantity($objItem->quantity); $arrOptionValues = array(); foreach (Isotope::formatOptions($objItem->getOptions()) as $option) { $arrOptionValues[] = $option['value']; } if (!empty($arrOptionValues)) { $item->setVariation(implode(', ', $arrOptionValues)); } $transaction->addItem($item); } // Track logged-in member as custom variable if ($objConfig->ga_member != '' && $objOrder->member > 0 && ($objMember = \MemberModel::findByPk($objOrder->member)) !== null) { $customVar = new \UnitedPrototype\GoogleAnalytics\CustomVariable(1, 'Member', $this->parseSimpleTokens($objConfig->ga_member, $objMember->row()), \UnitedPrototype\GoogleAnalytics\CustomVariable::SCOPE_VISITOR); $tracker->addCustomVariable($customVar); } // Assemble Session information // (could also get unserialized from PHP session) $session = new \UnitedPrototype\GoogleAnalytics\Session(); $tracker->trackTransaction($transaction, $session, $visitor); }
/** * Limit the member countries to the selection in store config * @param string */ public function limitCountries($strTable) { if ($strTable != 'tl_member' || !Isotope::getConfig()->limitMemberCountries) { return; } $arrCountries = array_unique(array_merge(Isotope::getConfig()->getBillingCountries(), Isotope::getConfig()->getShippingCountries())); $arrCountries = array_intersect_key($GLOBALS['TL_DCA']['tl_member']['fields']['country']['options'], array_flip($arrCountries)); $GLOBALS['TL_DCA']['tl_member']['fields']['country']['options'] = $arrCountries; if (count($arrCountries) == 1) { $arrCountryCodes = array_keys($arrCountries); $GLOBALS['TL_DCA']['tl_member']['fields']['country']['default'] = $arrCountryCodes[0]; } }
/** * SEPA only supports these currencies * @return true */ public function isAvailable() { if (!in_array(Isotope::getConfig()->currency, array('EUR'))) { return false; } if (!FE_USER_LOGGED_IN) { return false; } else { $user = \FrontendUser::getInstance(); if (!isset($user->iso_sepa_active) || $user->iso_sepa_active != "1") { return false; } } return parent::isAvailable(); }
/** * HTML form for checkout * @param IsotopeProductCollection The order being places * @param Module The checkout module instance * @return mixed */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { $i = 0; $arrData = array('aid' => $this->payone_aid, 'portalid' => $this->payone_portalid, 'mode' => $this->debug ? 'test' : 'live', 'request' => $this->trans_type == 'auth' ? 'preauthorization' : 'authorization', 'encoding' => 'UTF-8', 'clearingtype' => $this->payone_clearingtype, 'reference' => $objOrder->id, 'display_name' => 'no', 'display_address' => 'no', 'successurl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'backurl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'amount' => $objOrder->getTotal() * 100, 'currency' => $objOrder->currency, 'param' => 'paymentMethodPayone' . $this->id); foreach ($objOrder->getItems() as $objItem) { // Set the active product for insert tags replacement if ($objItem->hasProduct()) { Product::setActive($objItem->getProduct()); } $strOptions = ''; $arrOptions = Isotope::formatOptions($objItem->getOptions()); Product::unsetActive(); if (!empty($arrOptions)) { array_walk($arrOptions, function (&$option) { $option = $option['label'] . ': ' . $option['value']; }); $strOptions = ' (' . implode(', ', $arrOptions) . ')'; } $arrData['id[' . ++$i . ']'] = $objItem->getSku(); $arrData['pr[' . $i . ']'] = round($objItem->getPrice(), 2) * 100; $arrData['no[' . $i . ']'] = $objItem->quantity; $arrData['de[' . $i . ']'] = specialchars($objItem->getName() . $strOptions); } foreach ($objOrder->getSurcharges() as $k => $objSurcharge) { if (!$objSurcharge->addToTotal) { continue; } $arrData['id[' . ++$i . ']'] = 'surcharge' . $k; $arrData['pr[' . $i . ']'] = $objSurcharge->total_price * 100; $arrData['no[' . $i . ']'] = '1'; $arrData['de[' . $i . ']'] = $objSurcharge->label; } ksort($arrData); // Do not urlencode values because Payone does not properly decode POST values (whatever...) $strHash = md5(implode('', $arrData) . $this->payone_key); $objTemplate = new \Isotope\Template('iso_payment_payone'); $objTemplate->id = $this->id; $objTemplate->data = $arrData; $objTemplate->hash = $strHash; $objTemplate->billing_address = $objOrder->getBillingAddress()->row(); $objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]; $objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]); return $objTemplate->parse(); }
/** * Load libraries and scripts * @param object * @param string * @return void */ public function __construct($objModule, $strColumn = 'main') { parent::__construct($objModule, $strColumn); Isotope::initialize(); if (TL_MODE == 'FE') { // Load Isotope javascript and css $GLOBALS['TL_JAVASCRIPT'][] = \Haste\Util\Debug::uncompressedFile('system/modules/isotope/assets/js/isotope.min.js'); $GLOBALS['TL_CSS'][] = \Haste\Util\Debug::uncompressedFile('system/modules/isotope/assets/css/isotope.min.css'); // Disable caching for pages with certain modules (eg. Cart) if ($this->blnDisableCache) { try { global $objPage; $objPage->cache = 0; } catch (\Exception $e) { } } } }
/** * Generate the module * @return void */ protected function compile() { $arrOrders = array(); $objOrders = Order::findBy(array('order_status>0', 'member=?', 'config_id IN (?)'), array(\FrontendUser::getInstance()->id, implode("','", $this->iso_config_ids)), array('order' => 'locked DESC')); // No orders found, just display an "empty" message if (null === $objOrders) { $this->Template = new \Isotope\Template('mod_message'); $this->Template->type = 'empty'; $this->Template->message = $GLOBALS['TL_LANG']['ERR']['emptyOrderHistory']; return; } while ($objOrders->next()) { Isotope::setConfig($objOrders->current()->getRelated('config_id')); $arrOrders[] = array('collection' => $objOrders->current(), 'raw' => $objOrders->current()->row(), 'date' => Format::date($objOrders->current()->locked), 'time' => Format::time($objOrders->current()->locked), 'datime' => Format::datim($objOrders->current()->locked), 'grandTotal' => Isotope::formatPriceWithCurrency($objOrders->current()->getTotal()), 'status' => $objOrders->current()->getStatusLabel(), 'link' => $this->jumpTo ? \Haste\Util\Url::addQueryString('uid=' . $objOrders->current()->uniqid, $this->jumpTo) : '', 'class' => $objOrders->current()->getStatusAlias()); } RowClass::withKey('class')->addFirstLast()->addEvenOdd()->applyTo($arrOrders); $this->Template->orders = $arrOrders; }
/** * Generate a daily summary for the overview page * @return array */ protected function getDailySummary() { $strBuffer = ' <div class="tl_formbody_edit be_iso_overview"> <fieldset class="tl_tbox"> <legend style="cursor: default;">' . $GLOBALS['TL_LANG']['ISO_REPORT']['24h_summary'] . '</legend>'; $arrAllowedProducts = \Isotope\Backend\Product\Permission::getAllowedIds(); $objOrders = \Database::getInstance()->prepare("\n SELECT\n c.id AS config_id,\n c.name AS config_name,\n c.currency,\n COUNT(DISTINCT o.id) AS total_orders,\n SUM(i.tax_free_price * i.quantity) AS total_sales,\n SUM(i.quantity) AS total_items\n FROM tl_iso_product_collection o\n LEFT JOIN tl_iso_product_collection_item i ON o.id=i.pid\n LEFT OUTER JOIN tl_iso_config c ON o.config_id=c.id\n WHERE o.type='order' AND o.order_status>0 AND o.locked>=?\n " . Report::getProductProcedure('i', 'product_id') . "\n " . Report::getConfigProcedure('o', 'config_id') . "\n GROUP BY config_id\n ")->execute(strtotime('-24 hours')); if (!$objOrders->numRows) { $strBuffer .= ' <p class="tl_info" style="margin-top:10px">' . $GLOBALS['TL_LANG']['ISO_REPORT']['24h_empty'] . '</p>'; } else { $i = -1; $strBuffer .= ' <br> <table class="tl_listing"> <tr> <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['shop_config'] . '</th> <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['currency'] . '</th> <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['orders#'] . '</th> <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['products#'] . '</th> <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['sales#'] . '</th> </tr>'; while ($objOrders->next()) { $strBuffer .= ' <tr class="row_' . ++$i . ($i % 2 ? 'odd' : 'even') . '"> <td class="tl_file_list">' . $objOrders->config_name . '</td> <td class="tl_file_list">' . $objOrders->currency . '</td> <td class="tl_file_list">' . $objOrders->total_orders . '</td> <td class="tl_file_list">' . $objOrders->total_items . '</td> <td class="tl_file_list">' . Isotope::formatPrice($objOrders->total_sales) . '</td> </tr>'; } $strBuffer .= ' </table>'; } $strBuffer .= ' </fieldset> </div>'; return $strBuffer; }
/** * Generate the checkout step * @return string */ public function generate() { $objTemplate = new Template($this->strTemplate); $arrAttributes = ['dateDirection' => 'gtToday', 'inputType' => 'calendar', 'eval' => ['required' => true, 'rgxp' => 'date', 'datepicker' => true]]; $varValue = null; $objWidget = new FormCalendarField(FormCalendarField::getAttributesFromDca($arrAttributes, $this->strField, $varValue, $this->strField, $this->strTable, $this)); $objWidget->storeValues = true; if (\Input::post('FORM_SUBMIT') == $this->strFormId) { $objWidget->validate(); $varValue = $objWidget->value; $rgxp = $arrAttributes['eval']['rgxp']; // Convert date formats into timestamps (check the eval setting first -> #3063) if ($varValue != '' && in_array($rgxp, array('date', 'time', 'datim'))) { try { $objDate = new \Date($varValue, \Date::getFormatFromRgxp($rgxp)); $varValue = $objDate->tstamp; } catch (\OutOfBoundsException $e) { $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue)); } } // Do not submit the field if there are errors if ($objWidget->hasErrors()) { $doNotSubmit = true; } elseif ($objWidget->submitInput()) { $objOrder = Isotope::getCart()->getDraftOrder(); // Store the form data $_SESSION['FORM_DATA'][$this->strField] = $varValue; // Set the correct empty value (see #6284, #6373) if ($varValue === '') { $varValue = $objWidget->getEmptyValue(); } // Set the new value if ($varValue !== $objOrder->{$this->strField}) { $objOrder->{$this->strField}; } } } $objTemplate->headline = $GLOBALS['TL_LANG'][$this->strTable]['date_picker'][0]; $objTemplate->datePicker = $objWidget->parse(); return $objTemplate->parse(); }
/** * Calculate a price, add all applicable taxes * @param float * @param array|null * @return float */ public function calculateGrossPrice($fltPrice, $arrAddresses = null) { if (!is_array($arrAddresses)) { $arrAddresses = array('billing' => Isotope::getCart()->getBillingAddress(), 'shipping' => Isotope::getCart()->getShippingAddress()); } /** @var \Isotope\Model\TaxRate $objIncludes */ if (($objIncludes = $this->getRelated('includes')) !== null && !$objIncludes->isApplicable($fltPrice, $arrAddresses)) { $fltPrice -= $objIncludes->calculateAmountIncludedInPrice($fltPrice); } if (($objRates = $this->getRelated('rates')) !== null) { /** @var \Isotope\Model\TaxRate $objTaxRate */ foreach ($objRates as $objTaxRate) { if ($objTaxRate->isApplicable($fltPrice, $arrAddresses)) { $fltPrice += $objTaxRate->calculateAmountAddedToPrice($fltPrice); if ($objTaxRate->stop) { break; } } } } return $fltPrice; }
/** * Return calculated price for this shipping method * @return float */ public function getPrice(IsotopeProductCollection $objCollection = null) { if (null === $objCollection) { $objCollection = Isotope::getCart(); } if ($this->or_pricing == '1') { $fltAltPrice = $objCollection->subTotal - $objCollection->subTotal / (1 + floatval($this->alternative_price) / 100); switch ($this->alternative_price_logic) { case '1': //less $fltPrice = $this->arrData['price'] < $fltAltPrice ? $this->arrData['price'] : $fltAltPrice; break; case '2': //greater $fltPrice = $this->arrData['price'] > $fltAltPrice ? $this->arrData['price'] : $fltAltPrice; break; } return $fltPrice; } else { return $this->arrData['price']; } return Isotope::calculatePrice($fltPrice, $this, 'price', $this->arrData['tax_class']); }
/** * Return calculated price for this shipping method * @return float */ public function getPrice(IsotopeProductCollection $objCollection = null) { if (null === $objCollection) { $objCollection = Isotope::getCart(); } if ($this->isPercentage()) { $fltPrice = $objCollection->getSubtotal() / 100 * $this->getPercentage(); } else { $fltPrice = (double) $this->arrData['price']; } if ($this->flatCalculation == 'perProduct' || $this->flatCalculation == 'perItem') { $arrItems = $objCollection->getItems(); $intMultiplier = 0; foreach ($arrItems as $objItem) { if (!$objItem->hasProduct() || $objItem->getProduct()->isExemptFromShipping()) { continue; } $intMultiplier += $this->flatCalculation == 'perProduct' ? 1 : $objItem->quantity; } $fltPrice = $fltPrice * $intMultiplier; } return Isotope::calculatePrice($fltPrice, $this, 'price', $this->arrData['tax_class']); }
/** * Generate the order label and return it as string * * @param array $row * @param string $label * @param \DataContainer $dc * @param array $args * * @return string */ public function getOrderLabel($row, $label, \DataContainer $dc, $args) { /** @var Order $objOrder */ $objOrder = Order::findByPk($row['id']); if (null === $objOrder) { return $args; } // Override system to correctly format currencies etc Isotope::setConfig($objOrder->getRelated('config_id')); $objAddress = $objOrder->getBillingAddress(); if (null !== $objAddress) { $arrTokens = $objAddress->getTokens(Isotope::getConfig()->getBillingFieldsConfig()); $args[2] = $arrTokens['hcard_fn']; } $args[3] = Isotope::formatPriceWithCurrency($row['total']); /** @var \Isotope\Model\OrderStatus $objStatus */ if (($objStatus = $objOrder->getRelated('order_status')) !== null) { $args[4] = '<span style="' . $objStatus->getColorStyles() . '">' . $objOrder->getStatusLabel() . '</span>'; } else { $args[4] = '<span>' . $objOrder->getStatusLabel() . '</span>'; } return $args; }
/** * Load libraries and scripts * * @param \ModuleModel $objModule * @param string $strColumn */ public function __construct($objModule, $strColumn = 'main') { parent::__construct($objModule, $strColumn); if ($this->iso_list_where != '') { $this->iso_list_where = Haste::getInstance()->call('replaceInsertTags', $this->iso_list_where); } $this->iso_buttons = deserialize($this->iso_buttons); if (!is_array($this->iso_buttons)) { $this->iso_buttons = array(); } Isotope::initialize(); // Load Isotope JavaScript and style sheet if (TL_MODE == 'FE') { $version = RepositoryVersion::encode(Isotope::VERSION); $GLOBALS['TL_JAVASCRIPT'][] = Debug::uncompressedFile('system/modules/isotope/assets/js/isotope.min.js|static|' . $version); $GLOBALS['TL_CSS'][] = Debug::uncompressedFile('system/modules/isotope/assets/css/isotope.min.css|screen|static|' . $version); // Disable caching for pages with certain modules (eg. Cart) if ($this->blnDisableCache) { global $objPage; $objPage->cache = 0; } } }
/** * Prepare FIS params * @param Order * @return array */ private function prepareFISParams($objOrder) { $objBillingAddress = $objOrder->getBillingAddress(); $objShippingAddress = $objOrder->getShippingAddress(); $arrInvoice = array('ECOM_BILLTO_POSTAL_NAME_FIRST' => substr($objBillingAddress->firstname, 0, 50), 'ECOM_BILLTO_POSTAL_NAME_LAST' => substr($objBillingAddress->lastname, 0, 50), 'ECOM_SHIPTO_POSTAL_STREET_LINE1' => $objShippingAddress->street_1, 'ECOM_SHIPTO_POSTAL_POSTALCODE' => $objShippingAddress->postal, 'ECOM_SHIPTO_POSTAL_CITY' => $objShippingAddress->city, 'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => strtoupper($objShippingAddress->country), 'ECOM_SHIPTO_DOB' => date('d/m/Y', $objShippingAddress->dateOfBirth), 'REF_CUSTOMERID' => substr('psp_' . $this->id . '_' . $objOrder->id . '_' . $objOrder->uniqid, 0, 17), 'ECOM_CONSUMER_GENDER' => $objBillingAddress->gender == 'male' ? 'M' : 'F'); $arrOrder = array(); $i = 1; // Need to take the items from the cart as they're not transferred to the order here yet foreach (Isotope::getCart()->getItems() as $objItem) { $objPrice = $objItem->getProduct()->getPrice(); $fltVat = Isotope::roundPrice(100 / $objPrice->getNetAmount() * $objPrice->getGrossAmount() - 100, false); $arrOrder['ITEMID' . $i] = $objItem->id; $arrOrder['ITEMNAME' . $i] = substr($objItem->getName(), 40); $arrOrder['ITEMPRICE' . $i] = $objPrice->getNetAmount(); $arrOrder['ITEMQUANT' . $i] = $objItem->quantity; $arrOrder['ITEMVATCODE' . $i] = $fltVat . '%'; $arrOrder['ITEMVAT' . $i] = Isotope::roundPrice($objPrice->getGrossAmount() - $objPrice->getNetAmount(), false); $arrOrder['FACEXCL' . $i] = $objPrice->getNetAmount(); $arrOrder['FACTOTAL' . $i] = $objPrice->getGrossAmount(); ++$i; } return array_merge($arrInvoice, $arrOrder); }
/** * Set new address in cart * @param Isotope\Model\Address */ protected function setAddress(AddressModel $objAddress) { Isotope::getCart()->setShippingAddress($objAddress); }
/** * Get product configuration * * @return array */ public function getConfiguration() { $arrConfig = deserialize($this->configuration); if (empty($arrConfig) || !is_array($arrConfig)) { return array(); } if ($this->hasProduct()) { return Isotope::formatProductConfiguration($arrConfig, $this->getProduct()); } else { foreach ($arrConfig as $k => $v) { $arrConfig[$k] = new Plain($v, $k); } return $arrConfig; } }
/** * Return a widget object based on a product attribute's properties * @param string * @param boolean * @return string */ protected function generateProductOptionWidget($strField, &$arrVariantOptions, &$arrAjaxOptions) { \Controller::loadDataContainer(ProductModel::getTable()); $GLOBALS['TL_DCA'][ProductModel::getTable()]['fields']['gift_amount']['default'] = $GLOBALS['TL_DCA'][ProductModel::getTable()]['fields']['gift_amount']['default'] ?: Isotope::formatPrice($this->getPrice()->getAmount()); return parent::generateProductOptionWidget($strField, $arrVariantOptions, $arrAjaxOptions); }
/** * Generates the filter */ protected function generateFilter() { $blnShowClear = false; $arrFilters = array(); foreach ($this->iso_filterFields as $strField) { $blnTrail = false; $arrItems = array(); $arrWidget = \Widget::getAttributesFromDca($GLOBALS['TL_DCA']['tl_iso_product']['fields'][$strField], $strField); // Use the default routine to initialize options data foreach ($arrWidget['options'] as $option) { $varValue = $option['value']; // skip zero values (includeBlankOption) // @deprecated drop "-" when we only have the database table as options source if ($varValue === '' || $varValue === '-') { continue; } $strFilterKey = $strField . '=' . $varValue; $blnActive = Isotope::getRequestCache()->getFilterForModule($strFilterKey, $this->id) !== null; $blnTrail = $blnActive ? true : $blnTrail; $arrItems[] = array('href' => \Haste\Util\Url::addQueryString('cumulativefilter=' . base64_encode($this->id . ';' . ($blnActive ? 'del' : 'add') . ';' . $strField . ';' . $varValue)), 'class' => $blnActive ? 'active' : '', 'title' => specialchars($option['label']), 'link' => $option['label']); } if (!empty($arrItems) || $this->iso_iso_filterHideSingle && count($arrItems) < 2) { $objClass = RowClass::withKey('class')->addFirstLast(); if ($blnTrail) { $objClass->addCustom('sibling'); } $objClass->applyTo($arrItems); $objTemplate = new \Isotope\Template($this->navigationTpl); $objTemplate->level = 'level_2'; $objTemplate->items = $arrItems; $arrFilters[$strField] = array('label' => $arrWidget['label'], 'subitems' => $objTemplate->parse(), 'isActive' => $blnTrail); $blnShowClear = $blnTrail ? true : $blnShowClear; } } $this->Template->filters = $arrFilters; $this->Template->showClear = $blnShowClear; }