/** * used to determine weather something should be shown on a template or not * * @return bool * @author Roland Lehmann <*****@*****.**> * @since 19.3.2011 */ public function showPricesGross() { $pricetype = SilvercartConfig::Pricetype(); if ($pricetype == "gross") { return true; } else { return false; } }
/** * Returns the active products for this page. * * @return DataObject * * @author Sebastian Diel <*****@*****.**>, * Sascha Koehler <*****@*****.**> * @since 27.07.2015 */ public function ActiveSilvercartProducts() { if (!array_key_exists($this->ID, self::$activeSilvercartProducts)) { $requiredAttributes = SilvercartProduct::getRequiredAttributes(); $activeProducts = array(); $productGroupIDs = self::getFlatChildPageIDsForPage($this->ID); $translations = $this->getTranslations(); if ($translations && $translations->count() > 0) { foreach ($translations as $translation) { $productGroupIDs = array_merge($productGroupIDs, self::getFlatChildPageIDsForPage($translation->ID)); } } $filter = array(''); if (!empty($requiredAttributes)) { foreach ($requiredAttributes as $requiredAttribute) { //find out if we are dealing with a real attribute or a multilingual field if (array_key_exists($requiredAttribute, DataObject::custom_database_fields('SilvercartProduct')) || $requiredAttribute == "Price") { if ($requiredAttribute == "Price") { // Gross price as default if not defined if (SilvercartConfig::Pricetype() == "net") { $filter[] = sprintf('("PriceNetAmount" != 0.0)'); } else { $filter[] = sprintf('("PriceGrossAmount" != 0.0)'); } } else { $filter[] = sprintf('"%s" != \'\'', $requiredAttribute); } } else { // if its a multilingual attribute it comes from a relational class $filter[] = sprintf("SilvercartProductLanguage.%s != ''", $requiredAttribute); } } } if (count($filter) == 1) { $filter = array(); } $filterString = sprintf("isActive = 1\n AND (SilvercartProductGroupID IN (%s)\n OR ID IN (\n SELECT\n SilvercartProductID\n FROM\n SilvercartProduct_SilvercartProductGroupMirrorPages\n WHERE\n SilvercartProductGroupPageID IN (%s)))\n %s", implode(',', $productGroupIDs), implode(',', $productGroupIDs), implode(' AND ', $filter)); $this->extend('updateActiveSilvercartProductsFilter', $filterString); $records = DB::query(sprintf("SELECT\n ID\n FROM\n SilvercartProduct\n WHERE\n %s", $filterString)); foreach ($records as $record) { $activeProducts[] = $record['ID']; } self::$activeSilvercartProducts[$this->ID] = $activeProducts; } $result = new DataObject(); $result->ID = count(self::$activeSilvercartProducts[$this->ID]); $result->Count = count(self::$activeSilvercartProducts[$this->ID]); $result->IDs = self::$activeSilvercartProducts[$this->ID]; return $result; }
/** * Returns the end sum of the cart without fees based on shop settings for net or gross price type * * @param array $excludeModules An array of registered modules that shall not * be taken into account. * @param array $excludeShoppingCartPositions Positions that shall not be counted * @param boolean $excludeCharges Indicates wether to exlude charges and discounts * * @return Money money object with amount * * @author Patrick Schneider <*****@*****.**> * @since 26.03.2012 */ public function getAmountTotalWithoutFees($excludeModules = array(), $excludeShoppingCartPositions = false, $excludeCharges = false) { if (SilvercartConfig::Pricetype() == 'gross') { $amountObj = $this->getAmountTotalGrossWithoutFees($excludeModules, $excludeShoppingCartPositions, $excludeCharges); } else { $amountObj = $this->getAmountTotalNetWithoutFees($excludeModules, $excludeShoppingCartPositions, $excludeCharges); } return $amountObj; }
/** * used to determine weather something should be shown on a template or not * * @param bool $ignoreTaxExemption Determines whether to ignore tax exemption or not. * * @return bool * * @author Roland Lehmann <*****@*****.**>, * Sebastian Diel <*****@*****.**> * @since 18.07.2013 */ public function showPricesGross($ignoreTaxExemption = false) { $pricetype = SilvercartConfig::Pricetype(); if (!$ignoreTaxExemption && $this->doesNotHaveToPayTaxes()) { $pricetype = 'net'; } if ($pricetype == "gross") { return true; } else { return false; } }
/** * Returns a number of bargain products. * * @return SS_List * * @author Sebastian Diel <*****@*****.**> * @since 27.03.2012 */ public function Elements() { if (is_null($this->elements)) { if (!$this->numberOfProductsToFetch) { $this->numberOfProductsToFetch = SilvercartBargainProductsWidget::$defaults['numberOfProductsToFetch']; } if (SilvercartConfig::Pricetype() == 'net') { $priceField = 'PriceNetAmount'; } else { $priceField = 'PriceGrossAmount'; } switch ($this->fetchMethod) { case 'sortOrderAsc': $sort = "\"SilvercartProduct\".\"MSRPriceAmount\" - \"SilvercartProduct\".\"PriceGrossAmount\" ASC"; break; case 'sortOrderDesc': $sort = "\"SilvercartProduct\".\"MSRPriceAmount\" - \"SilvercartProduct\".\"PriceGrossAmount\" DESC"; break; case 'random': default: $sort = "RAND()"; } $this->listFilters = array(); if (count(self::$registeredFilterPlugins) > 0) { foreach (self::$registeredFilterPlugins as $registeredPlugin) { $pluginFilters = $registeredPlugin->filter(); if (is_array($pluginFilters)) { $this->listFilters = array_merge($this->listFilters, $pluginFilters); } } } $filter = sprintf("\"SilvercartProduct\".\"MSRPriceAmount\" IS NOT NULL \n AND \"SilvercartProduct\".\"MSRPriceAmount\" > 0\n AND \"SilvercartProduct\".\"%s\" < \"SilvercartProduct\".\"MSRPriceAmount\"", $priceField); foreach ($this->listFilters as $listFilterIdentifier => $listFilter) { $filter .= ' ' . $listFilter; } $products = SilvercartProduct::getProducts($filter, $sort, null, "0," . $this->numberOfProductsToFetch); $this->elements = $products; foreach ($this->elements as $element) { $element->addCartFormIdentifier = $this->ID . '_' . $element->ID; } } return $this->elements; }
/** * used to determine weather something should be shown on a template or not * * @return bool * * @author Roland Lehmann <*****@*****.**>, * Sebastian Diel <*****@*****.**> * @since 15.11.2014 */ public function showPricesNet() { $pricetype = SilvercartConfig::Pricetype(); $member = SilvercartCustomer::currentUser(); if ($member instanceof Member && $member->doesNotHaveToPayTaxes()) { $pricetype = 'net'; } if ($pricetype == "net") { return true; } else { return false; } }