/** * @param QueryBuilderFactory $queryBuilderFactory * @param \Shopware_Components_Snippet_Manager $snippetManager * @param QueryAliasMapper $queryAliasMapper */ public function __construct(QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper) { $this->queryBuilderFactory = $queryBuilderFactory; $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels'); if (!($this->fieldName = $queryAliasMapper->getShortAlias('shippingFree'))) { $this->fieldName = 'shippingFree'; } }
/** * @param ManufacturerServiceInterface $manufacturerService * @param QueryBuilderFactory $queryBuilderFactory * @param \Shopware_Components_Snippet_Manager $snippetManager * @param QueryAliasMapper $queryAliasMapper */ public function __construct(ManufacturerServiceInterface $manufacturerService, QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper) { $this->manufacturerService = $manufacturerService; $this->queryBuilderFactory = $queryBuilderFactory; $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels'); if (!($this->fieldName = $queryAliasMapper->getShortAlias('sSupplier'))) { $this->fieldName = 'sSupplier'; } }
/** * @param CategoryServiceInterface $categoryService * @param QueryBuilderFactory $queryBuilderFactory * @param \Shopware_Components_Snippet_Manager $snippetManager * @param QueryAliasMapper $queryAliasMapper * @param Connection $connection */ public function __construct(CategoryServiceInterface $categoryService, QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper, Connection $connection) { $this->categoryService = $categoryService; $this->queryBuilderFactory = $queryBuilderFactory; $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels'); $this->connection = $connection; if (!($this->fieldName = $queryAliasMapper->getShortAlias('sCategory'))) { $this->fieldName = 'sCategory'; } }
/** * @param PriceHelper $priceHelper * @param QueryBuilderFactory $queryBuilderFactory * @param \Shopware_Components_Snippet_Manager $snippetManager * @param QueryAliasMapper $queryAliasMapper */ public function __construct(PriceHelper $priceHelper, QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper) { $this->priceHelper = $priceHelper; $this->queryBuilderFactory = $queryBuilderFactory; $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels'); if (!($this->minFieldName = $queryAliasMapper->getShortAlias('priceMin'))) { $this->minFieldName = 'priceMin'; } if (!($this->maxFieldName = $queryAliasMapper->getShortAlias('priceMax'))) { $this->maxFieldName = 'priceMax'; } }
/** * @inheritdoc * @throws \Exception */ public function update() { try { $this->connection->executeQuery('ALTER TABLE s_import_export_profile ADD UNIQUE (`name`);'); $defaultProfileInstaller = new DefaultProfileInstaller($this->setupContext, $this->connection); $defaultProfileInstaller->install(); } catch (DBALException $exception) { if (!$this->isDuplicateNameError($exception)) { throw $exception; } throw new DuplicateNameException($this->snippetManager->getNamespace('backend/swag_importexport/default_profiles')->get('update/duplicate_names')); } }
/** * @param Criteria $criteria * @param $items * @return ValueListFacetResult */ private function createFacet(Criteria $criteria, $items) { if (!($fieldName = $this->queryAliasMapper->getShortAlias('sSupplier'))) { $fieldName = 'sSupplier'; } $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('manufacturer', 'Manufacturer'); return new ValueListFacetResult('manufacturer', $criteria->hasCondition('manufacturer'), $label, $items, $fieldName); }
/** * @param Criteria $criteria * @return BooleanFacetResult */ private function createFacet(Criteria $criteria) { $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('immediate_delivery', 'Immediate delivery'); if (!($fieldName = $this->queryAliasMapper->getShortAlias('immediateDelivery'))) { $fieldName = 'immediateDelivery'; } $criteriaPart = new BooleanFacetResult('immediate_delivery', $fieldName, $criteria->hasCondition('immediate_delivery'), $label); return $criteriaPart; }
/** * @inheritdoc */ public function generateFacet(FacetInterface $facet, Criteria $criteria, Struct\ShopContextInterface $context) { //resets all conditions of the criteria to execute a facet query without user filters. $queryCriteria = clone $criteria; $queryCriteria->resetConditions(); $queryCriteria->resetSorting(); $query = $this->queryBuilderFactory->createQuery($queryCriteria, $context); $query->innerJoin('product', 's_articles_esd', 'esd', 'esd.articleID = product.id'); $query->select('product.id')->setMaxResults(1); /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */ $statement = $query->execute(); $total = $statement->fetch(\PDO::FETCH_COLUMN); //found some esd products? if ($total <= 0) { return null; } $snippetNamespace = $this->snippetManager->getNamespace('frontend/listing/facet_labels'); return new BooleanFacetResult($facet->getName(), 'esd', $criteria->hasCondition($facet->getName()), $snippetNamespace->get('swag_search_bundle_esd_only', 'Only downloads')); }
/** * @param StoreException $exception * @return \Exception */ private function translateExceptionMessage(StoreException $exception) { $namespace = $this->snippetManager->getNamespace('backend/plugin_manager/exceptions'); if ($namespace->offsetExists($exception->getMessage())) { $snippet = $namespace->get($exception->getMessage()); } else { $snippet = $exception->getMessage(); } $snippet .= '<br><br>Error code: ' . $exception->getSbpCode(); return new \Exception($snippet, $exception->getCode(), $exception); }
/** * @param Category[] $categories * @param int[] $active * @return TreeFacetResult */ private function createTreeFacet($categories, $active) { $items = $this->getCategoriesOfParent($categories, null); $values = []; foreach ($items as $item) { $values[] = $this->createTreeItem($categories, $item, $active); } $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('category', 'Categories'); if (!($fieldName = $this->queryAliasMapper->getShortAlias('sCategory'))) { $fieldName = 'sCategory'; } return new TreeFacetResult('category', $fieldName, empty($active), $label, $values, [], null); }
/** * @param Criteria $criteria * @return RadioFacetResult */ private function createFacet(Criteria $criteria) { $activeAverage = null; if ($criteria->hasCondition('vote_average')) { /**@var $condition VoteAverageCondition*/ $condition = $criteria->getCondition('vote_average'); $activeAverage = $condition->getAverage(); } $values = [new ValueListItem(1, '', $activeAverage == 1), new ValueListItem(2, '', $activeAverage == 2), new ValueListItem(3, '', $activeAverage == 3), new ValueListItem(4, '', $activeAverage == 4), new ValueListItem(5, '', $activeAverage == 5)]; $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('vote_average', 'Ranking'); if (!($fieldName = $this->queryAliasMapper->getShortAlias('rating'))) { $fieldName = 'rating'; } return new RadioFacetResult('vote_average', $criteria->hasCondition('vote_average'), $label, $values, $fieldName, [], 'frontend/listing/filter/facet-rating.tpl'); }
/** * Filter voucher by article id * * @param array $voucherDetails The voucher details * @return array Messages for detected errors */ private function filterSupplierVoucher($voucherDetails) { $sErrorMessages = array(); $allowedSupplierId = $voucherDetails["bindtosupplier"]; if ($allowedSupplierId) { $allowedBasketEntriesBySupplier = $this->db->fetchRow('SELECT s_order_basket.id FROM s_order_basket, s_articles, s_articles_supplier WHERE s_order_basket.articleID = s_articles.id AND s_articles.supplierID = ? AND s_order_basket.sessionID = ?', array($allowedSupplierId, $this->session->get('sessionId'))); if (!$allowedBasketEntriesBySupplier) { $allowedSupplierName = $this->db->fetchRow('SELECT name FROM s_articles_supplier WHERE id = ?', array($allowedSupplierId)); $sErrorMessages[] = str_replace("{sSupplier}", $allowedSupplierName["name"], $this->snippetManager->getNamespace('frontend/basket/internalMessages')->get('VoucherFailureSupplier', 'This voucher is only available for products from {sSupplier}')); } } return $sErrorMessages; }
/** * @param Criteria $criteria * @param float $min * @param float $max * @return RangeFacetResult */ private function createFacet(Criteria $criteria, $min, $max) { $activeMin = $min; $activeMax = $max; /**@var $condition PriceCondition */ if ($condition = $criteria->getCondition('price')) { $activeMin = $condition->getMinPrice(); $activeMax = $condition->getMaxPrice(); } $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('price', 'Price'); if (!($minFieldName = $this->queryAliasMapper->getShortAlias('priceMin'))) { $minFieldName = 'priceMin'; } if (!($maxFieldName = $this->queryAliasMapper->getShortAlias('priceMax'))) { $maxFieldName = 'priceMax'; } return new RangeFacetResult('price', $criteria->hasCondition('price'), $label, (double) $min, (double) $max, (double) $activeMin, (double) $activeMax, $minFieldName, $maxFieldName, [], 'frontend/listing/filter/facet-currency-range.tpl'); }
/** * Helper method for sAdmin::sGetPremiumShippingcosts() * Calculates payment mean surcharge * * @param $country * @param $payment * @param $currencyFactor * @param $dispatch * @param $discount_tax */ private function handlePaymentMeanSurcharge($country, $payment, $currencyFactor, $dispatch, $discount_tax) { $surcharge_name = $this->snippetManager->getNamespace('backend/static/discounts_surcharges')->get('payment_surcharge_absolute', 'Surcharge for payment'); $surcharge_ordernumber = $this->config->get('sPAYMENTSURCHARGEABSOLUTENUMBER', 'PAYMENTSURCHARGEABSOLUTENUMBER'); $percent_ordernumber = $this->config->get('sPAYMENTSURCHARGENUMBER', "PAYMENTSURCHARGE"); // Country surcharge if (!empty($payment['country_surcharge'][$country['countryiso']])) { $payment['surcharge'] += $payment['country_surcharge'][$country['countryiso']]; } $payment['surcharge'] = round($payment['surcharge'] * $currencyFactor, 2); // Fixed surcharge if (!empty($payment['surcharge']) && (empty($dispatch) || $dispatch['surcharge_calculation'] == 3)) { $surcharge = round($payment['surcharge'], 2); $payment['surcharge'] = 0; if (empty($this->sSYSTEM->sUSERGROUPDATA["tax"]) && !empty($this->sSYSTEM->sUSERGROUPDATA["id"])) { $surcharge_net = $surcharge; //$tax_rate = 0; } else { $surcharge_net = round($surcharge / (100 + $discount_tax) * 100, 2); } $tax_rate = $discount_tax; $this->db->insert('s_order_basket', array('sessionID' => $this->session->offsetGet('sessionId'), 'articlename' => $surcharge_name, 'articleID' => 0, 'ordernumber' => $surcharge_ordernumber, 'quantity' => 1, 'price' => $surcharge, 'netprice' => $surcharge_net, 'tax_rate' => $tax_rate, 'datum' => new Zend_Date(), 'modus' => 4, 'currencyFactor' => $currencyFactor)); } // Percentage surcharge if (!empty($payment['debit_percent']) && (empty($dispatch) || $dispatch['surcharge_calculation'] != 2)) { $amount = $this->db->fetchOne('SELECT SUM(quantity*price) as amount FROM s_order_basket WHERE sessionID = ? GROUP BY sessionID', array($this->session->offsetGet('sessionId'))); $percent = round($amount / 100 * $payment['debit_percent'], 2); if ($percent > 0) { $percent_name = $this->snippetManager->getNamespace('backend/static/discounts_surcharges')->get('payment_surcharge_add'); } else { $percent_name = $this->snippetManager->getNamespace('backend/static/discounts_surcharges')->get('payment_surcharge_dev'); } if (empty($this->sSYSTEM->sUSERGROUPDATA["tax"]) && !empty($this->sSYSTEM->sUSERGROUPDATA["id"])) { $percent_net = $percent; } else { $percent_net = round($percent / (100 + $discount_tax) * 100, 2); } $tax_rate = $discount_tax; $this->db->insert('s_order_basket', array('sessionID' => $this->session->offsetGet('sessionId'), 'articlename' => $percent_name, 'articleID' => 0, 'ordernumber' => $percent_ordernumber, 'quantity' => 1, 'price' => $percent, 'netprice' => $percent_net, 'tax_rate' => $tax_rate, 'datum' => new Zend_Date(), 'modus' => 4, 'currencyFactor' => $currencyFactor)); } return $payment; }
/** * Helper method for sAdmin::sNewsletterSubscription * Subscribes the provided email address to the newsletter group * * @param $email * @param $groupID * @return array|int */ private function subscribeNewsletter($email, $groupID) { $result = $this->db->fetchAll('SELECT * FROM s_campaigns_mailaddresses WHERE email = ?', array($email)); if ($result === false) { $result = array("code" => 10, "message" => $this->snippetManager->getNamespace('frontend/account/internalMessages')->get('UnknownError', 'Unknown error')); return $result; } elseif (count($result)) { $result = array("code" => 2, "message" => $this->snippetManager->getNamespace('frontend/account/internalMessages')->get('NewsletterFailureAlreadyRegistered', 'You already receive our newsletter')); return $result; } else { $customer = $this->db->fetchOne('SELECT id FROM s_user WHERE email = ? LIMIT 1', array($email)); $result = $this->db->insert('s_campaigns_mailaddresses', array('customer' => (int) (!empty($customer)), 'groupID' => $groupID, 'email' => $email)); if ($result === false) { $result = array("code" => 10, "message" => $this->snippetManager->getNamespace('frontend/account/internalMessages')->get('UnknownError', 'Unknown error')); return $result; } else { $result = array("code" => 3, "message" => $this->snippetManager->getNamespace('frontend/account/internalMessages')->get('NewsletterSuccess', 'Thank you for receiving our newsletter')); return $result; } } }
/** * Add voucher to cart * @param string $sTicket - voucher code * @access public * @deprecated * @return array */ public function sAddVoucher($sTicket, $BASKET = '') { if (Enlight()->Events()->notifyUntil('Shopware_Modules_Basket_AddVoucher_Start', array('subject' => $this, 'code' => $sTicket, "basket" => $BASKET))) { return false; } $sTicket = stripslashes($sTicket); $sTicket = strtolower($sTicket); $sql = "\n\t\tSELECT * FROM s_emarketing_vouchers WHERE LOWER(vouchercode)=?\n\t\tAND ((valid_to>=now() AND valid_from<=now()) OR valid_to is NULL)\n\t\t"; $ticketResult = $this->sSYSTEM->sDB_CONNECTION->GetRow($sql, array($sTicket)); // Check if voucher was already cashed if ($this->sSYSTEM->_SESSION["sUserId"] && $ticketResult["id"]) { $userid = $this->sSYSTEM->_SESSION["sUserId"]; $sql = "\n\t\t\tSELECT s_order_details.id AS id FROM s_order, s_order_details\n\t\t\tWHERE s_order.userID = {$userid} AND s_order_details.orderID=s_order.id \n\t\t\tAND s_order_details.articleordernumber = '{$ticketResult["ordercode"]}'\n\t\t\tAND s_order_details.ordernumber!='0'\n\t\t\t"; $queryVoucher = $this->sSYSTEM->sDB_CONNECTION->GetAll($sql); if (count($queryVoucher) >= $ticketResult["numorder"] && !$ticketResult["modus"]) { $sErrorMessages[] = $this->snippetObject->get('VoucherFailureAlreadyUsed', 'This voucher was used in an previous order'); return array("sErrorFlag" => true, "sErrorMessages" => $sErrorMessages); } } if ($ticketResult["id"]) { //echo "NO INDIVIDUAL CODE $sTicket"; // Check if ticket is available anymore $countTicket = $this->sSYSTEM->sDB_CONNECTION->GetRow("\n\t\t\tSELECT COUNT(id) AS vouchers FROM s_order_details WHERE articleordernumber='{$ticketResult["ordercode"]}'\n\t\t\tAND s_order_details.ordernumber!='0'\n\t\t\t"); } else { // Check for individual voucher - code $sql = "\n\t\t\tSELECT s_emarketing_voucher_codes.id AS id, s_emarketing_voucher_codes.code AS vouchercode,description, numberofunits,customergroup, value,restrictarticles, minimumcharge, shippingfree, bindtosupplier,\n\t\t\ttaxconfig,\n\t\t\tvalid_from,valid_to,ordercode, modus,percental,strict,subshopID FROM s_emarketing_vouchers, s_emarketing_voucher_codes\n\t\t\tWHERE\n\t\t\t\tmodus = 1\n\t\t\tAND\n\t\t\t\ts_emarketing_vouchers.id = s_emarketing_voucher_codes.voucherID\n\t\t\tAND\n\t\t\t\tLOWER(code) = ?\n\t\t\tAND \n\t\t\t\tcashed != 1\n\t\t\tAND ((s_emarketing_vouchers.valid_to>=now() AND s_emarketing_vouchers.valid_from<=now()) OR s_emarketing_vouchers.valid_to is NULL)\n\t\t\t"; $ticketResult = $this->sSYSTEM->sDB_CONNECTION->GetRow($sql, array($sTicket)); if ($ticketResult["description"]) { $indivualCode = true; } else { $indivualCode = false; } } // Check if ticket exists if (!count($ticketResult) || !$sTicket || $ticketResult["numberofunits"] <= $countTicket["vouchers"] && !$indivualCode) { $sErrorMessages[] = $this->snippetObject->get('VoucherFailureNotFound', 'Voucher could not be found or is not valid anymore'); return array("sErrorFlag" => true, "sErrorMessages" => $sErrorMessages); } if (!empty($ticketResult["strict"])) { $restrictDiscount = true; } else { $restrictDiscount = false; } if (!empty($ticketResult["subshopID"])) { if ($this->sSYSTEM->sSubShop["id"] != $ticketResult["subshopID"]) { $sErrorMessages[] = $this->snippetObject->get('VoucherFailureNotFound', 'Voucher could not be found or is not valid anymore'); return array("sErrorFlag" => true, "sErrorMessages" => $sErrorMessages); } } // Check if any voucher is already in basket $chkBasket = $this->sSYSTEM->sDB_CONNECTION->GetRow("\n\t\tSELECT id FROM s_order_basket WHERE sessionID='" . $this->sSYSTEM->sSESSION_ID . "' AND modus=2\n\t\t"); if (count($chkBasket)) { $sErrorMessages[] = $this->snippetObject->get('VoucherFailureOnlyOnes', 'Only one voucher can be processed in order'); return array("sErrorFlag" => true, "sErrorMessages" => $sErrorMessages); } // Restrict to customergroup if (!empty($ticketResult["customergroup"])) { $userid = $this->sSYSTEM->_SESSION["sUserId"]; if (!empty($userid)) { // Get customergroup $queryCustomergroup = $this->sSYSTEM->sDB_CONNECTION->GetRow("\n SELECT s_core_customergroups.id, customergroup FROM s_user, s_core_customergroups WHERE s_user.id={$userid}\n AND s_user.customergroup = s_core_customergroups.groupkey\n "); } $customergroup = $queryCustomergroup["customergroup"]; if ($customergroup != $ticketResult["customergroup"] && $ticketResult["customergroup"] != $queryCustomergroup["id"] && $ticketResult["customergroup"] != $this->sSYSTEM->sUSERGROUPDATA["id"]) { $sErrorMessages[] = $this->snippetObject->get('VoucherFailureCustomerGroup', 'This voucher is not available for your customergroup'); return array("sErrorFlag" => true, "sErrorMessages" => $sErrorMessages); } } // Restrict to articles if (!empty($ticketResult["restrictarticles"]) && strlen($ticketResult["restrictarticles"]) > 5) { $restrictedArticles = explode(";", $ticketResult["restrictarticles"]); if (count($restrictedArticles) == 0) { $restrictedArticles[] = $ticketResult["restrictarticles"]; } foreach ($restrictedArticles as $k => $restrictedArticle) { $restrictedArticles[$k] = (string) $this->sSYSTEM->sDB_CONNECTION->qstr($restrictedArticle); } $sql = "\n\t\t\tSELECT id FROM s_order_basket WHERE sessionID='" . $this->sSYSTEM->sSESSION_ID . "' AND modus=0\n\t\t\tAND ordernumber IN (" . implode(",", $restrictedArticles) . ")\n\t\t\t"; $getOrdernumbers = $this->sSYSTEM->sDB_CONNECTION->GetOne($sql); $foundMatchingArticle = false; if (!empty($getOrdernumbers)) { $foundMatchingArticle = true; } if (empty($foundMatchingArticle)) { $sErrorMessages[] = $this->snippetObject->get('VoucherFailureProducts', 'This voucher is only available in combination with certain products'); return array("sErrorFlag" => true, "sErrorMessages" => $sErrorMessages); } } // Restrict to supplier if ($ticketResult["bindtosupplier"]) { $searchHersteller = $ticketResult["bindtosupplier"]; $sql = "\n\t\t\tSELECT s_order_basket.id FROM s_order_basket, s_articles, s_articles_supplier WHERE\n\t\t\ts_order_basket.articleID=s_articles.id AND s_articles.supplierID={$searchHersteller}\n\t\t\tAND s_order_basket.sessionID='" . $this->sSYSTEM->sSESSION_ID . "'\n\t\t\t"; $chkHersteller = $this->sSYSTEM->sDB_CONNECTION->GetRow($sql); if (!count($chkHersteller)) { // Name des Herstellers abfragen $queryHersteller = $this->sSYSTEM->sDB_CONNECTION->GetRow("\n\t\t\t\tSELECT name FROM s_articles_supplier WHERE id={$searchHersteller}\n\t\t\t\t"); $sErrorMessages[] = str_replace("{sSupplier}", $queryHersteller["name"], $this->snippetObject->get('VoucherFailureSupplier', 'This voucher is only available for products from {sSupplier}')); return array("sErrorFlag" => true, "sErrorMessages" => $sErrorMessages); } } if (!empty($restrictDiscount) && (!empty($restrictedArticles) || !empty($searchHersteller))) { $amount = $this->sGetAmountRestrictedArticles($restrictedArticles, $searchHersteller); } else { $amount = $this->sGetAmountArticles(); } if ($this->sSYSTEM->sCurrency["factor"] && empty($ticketResult["percental"])) { $factor = $this->sSYSTEM->sCurrency["factor"]; $ticketResult["value"] *= $factor; } else { $factor = 1; } if ($amount["totalAmount"] / $factor < $ticketResult["minimumcharge"]) { $sErrorMessages[] = str_replace("{sMinimumCharge}", $ticketResult["minimumcharge"], $this->snippetObject->get('VoucherFailureMinimumCharge', 'The minimum charge for this voucher is {sMinimumCharge}')); return array("sErrorFlag" => true, "sErrorMessages" => $sErrorMessages); } $timeInsert = date("Y-m-d H:i:s"); $vouchername = $this->sSYSTEM->sCONFIG['sVOUCHERNAME']; if ($ticketResult["percental"]) { $value = $ticketResult["value"]; $vouchername .= " " . $value . " %"; $ticketResult["value"] = $amount["totalAmount"] / 100 * floatval($value); } // Free tax configuration for vouchers // Trac ticket 4708 st.hamann $taxRate = 0; if (!$this->sSYSTEM->sUSERGROUPDATA["tax"] && $this->sSYSTEM->sUSERGROUPDATA["id"] || $ticketResult["taxconfig"] == "none") { // if net customergroup - calculate without tax $tax = $ticketResult["value"] * -1; if ($ticketResult["taxconfig"] == "default" || empty($ticketResult["taxconfig"])) { $taxRate = $this->sSYSTEM->sCONFIG['sVOUCHERTAX']; } elseif ($ticketResult["taxconfig"] == "auto") { $taxRate = $this->getMaxTax(); } elseif (intval($ticketResult["taxconfig"])) { $temporaryTax = $ticketResult["taxconfig"]; $getTaxRate = $this->sSYSTEM->sDB_CONNECTION->getOne("\n SELECT tax FROM s_core_tax WHERE id = ?\n ", array($temporaryTax)); $taxRate = $getTaxRate; } } else { if ($ticketResult["taxconfig"] == "default" || empty($ticketResult["taxconfig"])) { $tax = round($ticketResult["value"] / (100 + $this->sSYSTEM->sCONFIG['sVOUCHERTAX']) * 100, 3) * -1; $taxRate = $this->sSYSTEM->sCONFIG['sVOUCHERTAX']; // Pre 3.5.4 behaviour } elseif ($ticketResult["taxconfig"] == "auto") { // Check max. used tax-rate from basket $tax = $this->getMaxTax(); $taxRate = $tax; $tax = round($ticketResult["value"] / (100 + $tax) * 100, 3) * -1; } elseif (intval($ticketResult["taxconfig"])) { // Fix defined tax $temporaryTax = $ticketResult["taxconfig"]; $getTaxRate = $this->sSYSTEM->sDB_CONNECTION->getOne("\n\t\t\t\tSELECT tax FROM s_core_tax WHERE id = ?\n\t\t\t\t", array($temporaryTax)); $taxRate = $getTaxRate; $tax = round($ticketResult["value"] / (100 + $getTaxRate) * 100, 3) * -1; } else { // No tax $tax = $ticketResult["value"] * -1; } } $ticketResult["value"] = $ticketResult["value"] * -1; if ($ticketResult["shippingfree"]) { $shippingfree = "1"; } else { $shippingfree = "0"; } $sql = "\n\t\tINSERT INTO s_order_basket (sessionID, articlename, articleID, ordernumber, shippingfree, quantity, price, netprice,tax_rate, datum, modus, currencyFactor)\n\t\tVALUES (?,?,?,?,?,1,?,?,?,?,2,?)\n\t\t"; $params = array($this->sSYSTEM->sSESSION_ID, $vouchername, $ticketResult["id"], $ticketResult["ordercode"], $shippingfree, $ticketResult["value"], $tax, $taxRate, $timeInsert, $this->sSYSTEM->sCurrency["factor"]); $sql = Enlight()->Events()->filter('Shopware_Modules_Basket_AddVoucher_FilterSql', $sql, array('subject' => $this, "params" => $params, "voucher" => $ticketResult, "name" => $vouchername, "shippingfree" => $shippingfree, "tax" => $tax)); if (!$this->sSYSTEM->sDB_CONNECTION->Execute($sql, $params)) { return false; } return true; }
/** * Returns the snippet namespace for the passed template. * * @param Shop\Template $template * @return \Enlight_Components_Snippet_Namespace */ private function getConfigSnippetNamespace(Shop\Template $template) { return $this->snippets->getNamespace($this->util->getSnippetNamespace($template) . 'backend/config'); }
/** * @param QueryBuilderFactory $queryBuilderFactory * @param \Shopware_Components_Snippet_Manager $snippetManager */ public function __construct(QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager) { $this->queryBuilderFactory = $queryBuilderFactory; $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels'); }
/** * Subscribe / unsubscribe to mailing list * @param string $email - mail * @param boolean $unsubscribe * @param id $groupID id of the mailinglist group * @access public * @return boolean */ public function sNewsletterSubscription($email, $unsubscribe = false, $groupID = null) { if (empty($unsubscribe)) { $errorflag = array(); /** * Only the mail address needs to be a mandatory item * @ticket #5781 * @author S.Pohl <*****@*****.**> * @date 2011-07-27 */ $fields = array('newsletter'); foreach ($fields as $field) { if (isset($this->sSYSTEM->_POST[$field]) && empty($this->sSYSTEM->_POST[$field])) { $errorflag[$field] = true; } } if (!empty($errorflag)) { return array('code' => 5, 'message' => $this->snippetObject->get('ErrorFillIn', 'Please fill in all red fields'), 'sErrorFlag' => $errorflag); } } if (empty($groupID)) { $groupID = $this->sSYSTEM->sCONFIG["sNEWSLETTERDEFAULTGROUP"]; $sql = ' INSERT IGNORE INTO s_campaigns_groups (id, name) VALUES (?, ?) '; $this->sSYSTEM->sDB_CONNECTION->Execute($sql, array($groupID, 'Newsletter-Empfänger')); } $email = trim(strtolower(stripslashes($email))); if (empty($email)) { return array("code" => 6, "message" => $this->snippetObject->get('NewsletterFailureMail', 'Enter eMail address')); } $reg = "/^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\"([^\"\\\\\r]|(\\\\[\\w\\W]))*\"))@((\\[([0-9]{1,3}\\.){3}[0-9]{1,3}\\])|(([a-z\\-0-9áàäçéèêñóòôöüæøå]+\\.)+[a-z]{2,}))\$/i"; if (!preg_match($reg, $email)) { return array("code" => 1, "message" => $this->snippetObject->get('NewsletterFailureInvalid', 'Enter valid eMail address')); } if (!$unsubscribe) { $sql = "SELECT * FROM s_campaigns_mailaddresses WHERE email=?"; $result = $this->sSYSTEM->sDB_CONNECTION->Execute($sql, array($email)); if ($result === false) { $result = array("code" => 10, "message" => $this->snippetObject->get('UnknownError', 'Unknown error')); } elseif ($result->RecordCount()) { $result = array("code" => 2, "message" => $this->snippetObject->get('NewsletterFailureAlreadyRegistered', 'You already receive our newsletter')); } else { $sql = "INSERT INTO s_campaigns_mailaddresses (`groupID`,email) VALUES(?, ?)"; $result = $this->sSYSTEM->sDB_CONNECTION->Execute($sql, array($groupID, $email)); if ($result === false) { $result = array("code" => 10, "message" => $this->snippetObject->get('UnknownError', 'Unknown error')); } else { $result = array("code" => 3, "message" => $this->snippetObject->get('NewsletterSuccess', 'Thank you for receiving our newsletter')); } } } else { $sql = "DELETE FROM s_campaigns_mailaddresses WHERE email=?"; $result1 = $this->sSYSTEM->sDB_CONNECTION->Execute($sql, array($email)); $result = $this->sSYSTEM->sDB_CONNECTION->Affected_Rows(); $sql = "UPDATE s_user SET newsletter=0 WHERE email=?"; $result2 = $this->sSYSTEM->sDB_CONNECTION->Execute($sql, array($email)); $result += $this->sSYSTEM->sDB_CONNECTION->Affected_Rows(); if ($result1 === false || $result2 === false) { $result = array("code" => 10, "message" => $this->snippetObject->get('UnknownError', 'Unknown error')); } elseif (empty($result)) { $result = array("code" => 4, "message" => $this->snippetObject->get('NewsletterFailureNotFound', 'This mail address could not be found')); } else { $result = array("code" => 5, "message" => $this->snippetObject->get('NewsletterMailDeleted', 'Your mail address was deleted')); } } if (!empty($result['code']) && in_array($result['code'], array(2, 3))) { $sql = ' REPLACE INTO `s_campaigns_maildata` (`email`, `groupID`, `salutation`, `title`, `firstname`, `lastname`, `street`, `streetnumber`, `zipcode`, `city`, `added`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ' . $this->sSYSTEM->sDB_CONNECTION->sysTimeStamp . ') '; $this->sSYSTEM->sDB_CONNECTION->Execute($sql, array($email, $groupID, $this->sSYSTEM->_POST['salutation'], $this->sSYSTEM->_POST['title'], $this->sSYSTEM->_POST['firstname'], $this->sSYSTEM->_POST['lastname'], $this->sSYSTEM->_POST['street'], $this->sSYSTEM->_POST['streetnumber'], $this->sSYSTEM->_POST['zipcode'], $this->sSYSTEM->_POST['city'])); } elseif (!empty($unsubscribe)) { $sql = 'DELETE FROM `s_campaigns_maildata` WHERE `email`=? AND `groupID`=?'; $this->sSYSTEM->sDB_CONNECTION->Execute($sql, array($email, $groupID)); } return $result; }
/** * A helper function that returns a snippet namespace by a specific locale id * * @param $localeId * @return Enlight_Components_Snippet_Namespace */ private function getSnippetNamespace($localeId) { /** @var \Shopware\Models\Shop\Locale $locale */ $locale = $this->models->getRepository('Shopware\\Models\\Shop\\Locale')->find($localeId); return $this->snippets->setLocale($locale)->getNamespace('frontend/swag_browser_language/main'); }