function updateCart() { if (!$this->ms['MODULES']['ALLOW_ORDER_OUT_OF_STOCK_PRODUCT']) { $product_id = $this->post['products_id']; if (is_numeric($this->get['products_id']) and $this->get['tx_multishop_pi1']['action'] == 'add_to_cart') { $product_id = $this->get['products_id']; } if (is_numeric($product_id)) { $product = mslib_fe::getProduct($product_id); if ($product['products_quantity'] < 1 && !$this->ms['MODULES']['ALLOW_ORDER_OUT_OF_STOCK_PRODUCT']) { if ($product['categories_id']) { // get all cats to generate multilevel fake url $level = 0; $cats = mslib_fe::Crumbar($product['categories_id']); $cats = array_reverse($cats); $where = ''; if (count($cats) > 0) { foreach ($cats as $cat) { $where .= "categories_id[" . $level . "]=" . $cat['id'] . "&"; $level++; } $where = substr($where, 0, strlen($where) - 1); } } $link = mslib_fe::typolink($this->conf['products_detail_page_pid'], '&' . $where . '&products_id=' . $product_id . '&tx_multishop_pi1[page_section]=products_detail'); header("Location: " . $this->FULL_HTTP_URL . $link); exit; } } } // error_log("bastest"); // hook if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCart'])) { $params = array(); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCart'] as $funcRef) { $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } else { // custom hook that can be controlled by third-party plugin if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartPreHook'])) { $params = array('get' => &$this->get, 'post' => &$this->post); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartPreHook'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // custom hook that can be controlled by third-party plugin eof $GLOBALS['dont_update_cart'] = 1; //$cart=$GLOBALS['TSFE']->fe_user->getKey('ses', $this->cart_page_uid); require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'pi1/classes/class.tx_mslib_cart.php'; $mslib_cart = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_mslib_cart'); $mslib_cart->init($this); $cart = $mslib_cart->getCart(); if (is_numeric($this->get['products_id']) and $this->get['tx_multishop_pi1']['action'] == 'add_to_cart') { $this->post['products_id'] = $this->get['products_id']; } if (is_numeric($this->post['products_id'])) { $shopping_cart_item = $this->post['products_id']; if ($this->post['tx_multishop_pi1']['cart_item']) { $shopping_cart_item = $this->post['tx_multishop_pi1']['cart_item']; } elseif (is_array($this->post['attributes'])) { $shopping_cart_item = md5($this->post['products_id'] . serialize($this->post['attributes'])); } // custom hook that can be controlled by third-party plugin if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartSetShoppingCartItemPostProc'])) { $params = array('shopping_cart_item' => $shopping_cart_item, 'product' => &$product); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartSetShoppingCartItemPostProc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // custom hook that can be controlled by third-party plugin eof if (is_numeric($cart['products'][$shopping_cart_item]['products_id'])) { $products_id = $cart['products'][$shopping_cart_item]['products_id']; } else { $products_id = $this->post['products_id']; } $product = mslib_fe::getProduct($products_id); if ($product['products_id']) { $product['products_shortdescription_raw'] = $product['products_shortdescription']; $product['products_description_raw'] = $product['products_description']; if ($product['products_image']) { $product['products_image_200'] = mslib_befe::getImagePath($product['products_image'], 'products', '200'); $product['products_image'] = mslib_befe::getImagePath($product['products_image'], 'products', '50'); } // $query = $GLOBALS['TYPO3_DB']->SELECTquery('pa.*', 'tx_multishop_products_attributes pa, tx_multishop_products_options po', 'pa.products_id="' . addslashes($product['products_id']) . '" and pa.page_uid=\'' . $this->showCatalogFromPage . '\' and po.hide!=1 and po.hide_in_cart!=1 and po.language_id=' . $this->sys_language_uid . ' and po.products_options_id=pa.options_id', '', 'pa.sort_order_option_name asc, pa.sort_order_option_value asc', ''); $product_attributes = array(); $res = $GLOBALS['TYPO3_DB']->sql_query($query); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $product_attributes[$row['options_id']][] = $row['options_values_id']; } } // //if (mslib_fe::ProductHasAttributes($product['products_id']) and !count($this->post['attributes'])) { if (is_array($product_attributes) && count($product_attributes) && !count($this->post['attributes'])) { // Product has attributes. We need to redirect the customer to the product detail page so the attributes can be selected if ($product['categories_id']) { // get all cats to generate multilevel fake url $level = 0; $cats = mslib_fe::Crumbar($product['categories_id']); $cats = array_reverse($cats); $where = ''; if (count($cats) > 0) { foreach ($cats as $cat) { $where .= "categories_id[" . $level . "]=" . $cat['id'] . "&"; $level++; } $where = substr($where, 0, strlen($where) - 1); // $where.='&'; } // get all cats to generate multilevel fake url eof } $link = mslib_fe::typolink($this->conf['products_detail_page_pid'], '&' . $where . '&products_id=' . $product['products_id'] . '&tx_multishop_pi1[page_section]=products_detail'); header("Location: " . $this->FULL_HTTP_URL . $link); exit; } if ($this->post['quantity'] and strstr($this->post['quantity'], ",")) { $this->post['quantity'] = str_replace(",", ".", $this->post['quantity']); } if (!$this->post['quantity'] or $this->post['quantity'] and !is_numeric($this->post['quantity'])) { $this->post['quantity'] = 1; } if ($this->post['quantity'] < 0) { $this->post['quantity'] = 0; } if (is_numeric($product['minimum_quantity']) && $product['minimum_quantity'] > 0 && $product['minimum_quantity'] > $this->post['quantity']) { $this->post['quantity'] = $product['minimum_quantity']; } if ($product['products_multiplication']) { $ctr_end = $product['maximum_quantity'] > 0 ? $product['maximum_quantity'] : 9999; $qty_start = $product['minimum_quantity']; if ($this->post['quantity'] > $qty_start) { $low_number = $qty_start; $high_number = $qty_start; for ($ctr_start = $qty_start; $ctr_start <= $ctr_end; $ctr_start++) { if ($ctr_start > $qty_start) { $low_number = $high_number; $high_number += $product['products_multiplication']; } else { $low_number = $ctr_start; $high_number += $product['products_multiplication']; } if ($this->post['quantity'] > $low_number && $this->post['quantity'] < $high_number) { if (round($this->post['quantity'], 2) == round($low_number, 2)) { $this->post['quantity'] = $low_number; break; } else { if (round($this->post['quantity'], 2) == round($high_number, 2)) { $this->post['quantity'] = $high_number; break; } else { $low_remainder = $this->post['quantity'] - $low_number; $high_remainder = $this->post['quantity'] - $high_number; $this->post['quantity'] = $low_number; break; } } } } } } // PROTECTION WHEN PRODUCT MULTIPLICATION IS NOT A FLOAT WE HAVE TO CAST THE QUANTITY AS INTEGER if (!$product['products_multiplication'] || (int) $product['products_multiplication'] == $product['products_multiplication']) { $this->post['quantity'] = round($this->post['quantity'], 0); $cart['products'][$shopping_cart_item]['qty'] = (int) $cart['products'][$shopping_cart_item]['qty']; } $cart['products'][$shopping_cart_item]['qty'] = round(number_format($cart['products'][$shopping_cart_item]['qty'], 2), 2); $current_quantity = $cart['products'][$shopping_cart_item]['qty']; if (!$this->post['tx_multishop_pi1']['cart_item']) { $this->post['quantity'] = $current_quantity + $this->post['quantity']; } if ($product['maximum_quantity'] > 0 and $product['maximum_quantity'] < $this->post['quantity']) { $this->post['quantity'] = $product['maximum_quantity']; } if ($product['minimum_quantity'] and $product['minimum_quantity'] > $this->post['quantity']) { $this->post['quantity'] = $product['minimum_quantity']; } $product['qty'] = $this->post['quantity']; $product['qty'] = round(number_format($product['qty'], 2), 2); $this->post['quantity'] = round(number_format($this->post['quantity'], 2), 2); // chk if the product has staffel price if ($product['staffel_price'] && $this->ms['MODULES']['STAFFEL_PRICE_MODULE']) { if ($this->post['quantity']) { $quantity = $this->post['quantity']; } else { $quantity = $cart['products'][$shopping_cart_item]['qty']; } $product['final_price'] = mslib_fe::calculateStaffelPrice($product['staffel_price'], $quantity) / $quantity; } // custom hook that can be controlled by third-party plugin if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartProductPricePostHook'])) { $params = array('shopping_cart_item' => $shopping_cart_item, 'product' => &$product); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartProductPricePostHook'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // custom hook that can be controlled by third-party plugin eof // add product to the cart (through form on products_detail page) $product['description'] = ''; if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) { //$product['country_tax']=mslib_fe::taxDecimalCrop(($product['final_price']*$product['country_tax_rate']), 2, false); //$product['region_tax']=mslib_fe::taxDecimalCrop(($product['final_price']*$product['region_tax_rate']), 2, false); $product['country_tax'] = round($product['final_price'] * $product['country_tax_rate'], 2); $product['region_tax'] = round($product['final_price'] * $product['region_tax_rate'], 2); if ($product['country_tax'] > 0 && $product['region_tax'] > 0) { $product['tax'] = $product['country_tax'] + $product['region_tax']; } else { $product_tax = $product['final_price'] * $product['tax_rate']; //$product['tax']=mslib_fe::taxDecimalCrop($product_tax, 2, false); $product['tax'] = round($product_tax, 2); } } else { $product['country_tax'] = mslib_fe::taxDecimalCrop($product['final_price'] * $product['country_tax_rate']); $product['region_tax'] = mslib_fe::taxDecimalCrop($product['final_price'] * $product['region_tax_rate']); if ($product['country_tax'] && $product['region_tax']) { $product['tax'] = $product['country_tax'] + $product['region_tax']; } else { $product['tax'] = mslib_fe::taxDecimalCrop($product['final_price'] * $product['tax_rate']); } } $cart['products'][$shopping_cart_item] = $product; // add possible micro download $str = "select p.file_number_of_downloads, pd.file_remote_location, pd.file_label, pd.file_location from tx_multishop_products p, tx_multishop_products_description pd where p.products_id='" . $product['products_id'] . "' and pd.language_id='" . $this->sys_language_uid . "' and p.products_id=pd.products_id"; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) { // use current account $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $cart['products'][$shopping_cart_item]['file_label'] = $row['file_label']; $cart['products'][$shopping_cart_item]['file_location'] = $row['file_location']; $cart['products'][$shopping_cart_item]['file_remote_location'] = $row['file_remote_location']; $cart['products'][$shopping_cart_item]['file_number_of_downloads'] = $row['file_number_of_downloads']; } // add possible micro download eof $attributes_tax = 0; if (is_array($this->post['attributes'])) { foreach ($this->post['attributes'] as $key => $value) { if (is_numeric($key)) { $str = "SELECT * from tx_multishop_products_options o where o.products_options_id='" . $key . "' and language_id='" . $this->sys_language_uid . "'"; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $continue = 0; switch ($row['listtype']) { case 'checkbox': $multiple = 1; $continue = 1; break; case 'hidden_field': case 'textarea': case 'input': case 'date': case 'datetime': case 'dateofbirth': case 'datecustom': $cart['products'][$shopping_cart_item]['attributes'][$key] = $row; $cart['products'][$shopping_cart_item]['attributes'][$key]['options_id'] = $key; $cart['products'][$shopping_cart_item]['attributes'][$key]['products_options_values_name'] = $value; $continue = 0; $multiple = 0; break; default: $continue = 1; $multiple = 0; break; } if ($continue) { if (is_array($value)) { $array = $value; } else { if ($value) { $array = array($value); } } if (count($array)) { if ($multiple) { // reset first unset($cart['products'][$shopping_cart_item]['attributes'][$key]); } $products_id = $this->post['products_id']; $getAtributesFromProductsId = $products_id; // hook to let other plugins further manipulate the option values display if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartAttributesPreProc'])) { $params = array('products_id' => &$products_id, 'getAtributesFromProductsId' => &$getAtributesFromProductsId); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartAttributesPreProc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // hook foreach ($array as $item) { $str = "SELECT * from tx_multishop_products_attributes a, tx_multishop_products_options o, tx_multishop_products_options_values ov where a.products_id='" . $getAtributesFromProductsId . "' and a.options_id='" . $key . "' and a.options_values_id='" . $item . "' and a.page_uid='" . $this->showCatalogFromPage . "' and (o.hide_in_cart=0 or o.hide_in_cart is null) and a.options_id=o.products_options_id and o.language_id='" . $this->sys_language_uid . "' and ov.language_id='" . $this->sys_language_uid . "' and a.options_values_id=ov.products_options_values_id"; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) { $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); // hook to let other plugins further manipulate the option values display if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['cartAttributesArray'])) { $params = array('product_id' => $getAtributesFromProductsId, 'options_id' => &$key, 'row' => &$row); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['cartAttributesArray'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // hook if (!$this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['FORCE_CHECKOUT_SHOW_PRICES_INCLUDING_VAT']) { //$row['country_tax']=mslib_fe::taxDecimalCrop(($row['price_prefix'].$row['options_values_price'])*$product['country_tax_rate'], 2, false); //$row['region_tax']=mslib_fe::taxDecimalCrop(($row['price_prefix'].$row['options_values_price'])*$product['region_tax_rate'], 2, false); $row['country_tax'] = round(($row['price_prefix'] . $row['options_values_price']) * $product['country_tax_rate'], 2); $row['region_tax'] = round(($row['price_prefix'] . $row['options_values_price']) * $product['region_tax_rate'], 2); if ($row['country_tax'] && $row['region_tax']) { $row['tax'] = $row['country_tax'] + $row['region_tax']; } else { //$row['tax']=mslib_fe::taxDecimalCrop(($row['price_prefix'].$row['options_values_price'])*($product['tax_rate']), 2, false); $row['tax'] = round(($row['price_prefix'] . $row['options_values_price']) * $product['tax_rate'], 2); } } else { $row['country_tax'] = mslib_fe::taxDecimalCrop(($row['price_prefix'] . $row['options_values_price']) * $product['country_tax_rate']); $row['region_tax'] = mslib_fe::taxDecimalCrop(($row['price_prefix'] . $row['options_values_price']) * $product['region_tax_rate']); if ($row['country_tax'] && $row['region_tax']) { $row['tax'] = $row['country_tax'] + $row['region_tax']; } else { $row['tax'] = mslib_fe::taxDecimalCrop(($row['price_prefix'] . $row['options_values_price']) * $product['tax_rate']); } } // $attributes_tax += $row['tax'] * $product['qty']; $attributes_tax += $row['tax']; if ($multiple) { $cart['products'][$shopping_cart_item]['attributes'][$key][] = $row; } else { $cart['products'][$shopping_cart_item]['attributes'][$key] = $row; } } } } } } // end if $key } } if (count($_FILES['attributes']['name'])) { foreach ($_FILES['attributes'] as $file_key => $file_data) { foreach ($file_data as $optid => $val) { if (is_numeric($optid) && $_FILES['attributes']['error'][$optid] == 0 && $file_key == 'name') { $str = "SELECT products_options_name,listtype from tx_multishop_products_options o where o.products_options_id='" . $optid . "' and language_id='" . $this->sys_language_uid . "'"; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); if ($row['products_options_name']) { if (strpos($_FILES['attributes']['name'][$optid], '.php') !== false || strpos($_FILES['attributes']['name'][$optid], '.php3') !== false || strpos($_FILES['attributes']['name'][$optid], '.php4') !== false || strpos($_FILES['attributes']['name'][$optid], '.py') !== false || strpos($_FILES['attributes']['name'][$optid], '.php5') !== false) { $_FILES['attributes']['name'][$optid] .= '.protected'; } $target = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/order_resources/' . $_FILES['attributes']['name'][$optid]; move_uploaded_file($_FILES['attributes']['tmp_name'][$optid], $target); $cart['products'][$shopping_cart_item]['attributes'][$optid]['products_options_name'] = $row['products_options_name']; $cart['products'][$shopping_cart_item]['attributes'][$optid]['products_options_values_name'] = $_FILES['attributes']['name'][$optid]; $cart['products'][$shopping_cart_item]['attributes'][$optid]['options_id'] = $optid; $continue = 0; $multiple = 0; } } } } } if ($product['categories_id']) { // get all cats to generate multilevel fake url $level = 0; $cats = mslib_fe::Crumbar($product['categories_id']); $cats = array_reverse($cats); $where = ''; if (count($cats) > 0) { foreach ($cats as $cat) { $where .= "categories_id[" . $level . "]=" . $cat['id'] . "&"; $level++; } $where = substr($where, 0, strlen($where) - 1); $where .= '&'; } // get all cats to generate multilevel fake url eof } // $cart['products'][$shopping_cart_item]['link']=mslib_fe::typolink($product['page_uid'],'&'.$where.'&products_id='.$products_id.'&tx_multishop_pi1[page_section]=products_detail&tx_multishop_pi1[cart_item]='.$shopping_cart_item); $cart['products'][$shopping_cart_item]['link'] = mslib_fe::typolink($this->conf['products_detail_page_pid'], $where . '&products_id=' . $products_id . '&tx_multishop_pi1[page_section]=products_detail&tx_multishop_pi1[cart_item]=' . $shopping_cart_item); $cart['products'][$shopping_cart_item]['total_attributes_tax'] = $attributes_tax; // custom hook that can be controlled by third-party plugin if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartProductPreHook'])) { $params = array('shopping_cart_item' => $shopping_cart_item, 'array' => &$cart['products'][$shopping_cart_item], 'cart' => &$cart); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartProductPreHook'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // custom hook that can be controlled by third-party plugin eof /* $GLOBALS['TSFE']->fe_user->setKey('ses', $this->cart_page_uid, $cart); if ($this->ms['eID']) { $GLOBALS['TSFE']->fe_user->storeSessionData(); } else { $GLOBALS['TSFE']->storeSessionData(); } */ tx_mslib_cart::storeCart($cart); } if ($this->post['winkelwagen']) { // if products relatives are selected foreach ($this->post['winkelwagen'] as $key => $value) { if ($value) { $rel_products_id = $this->post['relation_products_id'][$key]; $rel_id = $this->post['relation_id'][$key]; $rel_carty_quantity = $this->post['relation_cart_quantity'][$key]; if ($rel_carty_quantity < 0) { $rel_carty_quantity = 0; } if ($rel_carty_quantity and strstr($rel_carty_quantity, ",")) { $rel_carty_quantity = str_replace(",", ".", $rel_carty_quantity); } //$cart=$GLOBALS['TSFE']->fe_user->getKey('ses', $this->cart_page_uid); require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'pi1/classes/class.tx_mslib_cart.php'; $mslib_cart = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_mslib_cart'); $mslib_cart->init($this); $cart = $mslib_cart->getCart(); if (preg_match("/^[0-9]+\$/", $rel_products_id)) { $product = mslib_fe::getProduct($rel_products_id); if ($product['products_id']) { $product['products_shortdescription_raw'] = $product['products_shortdescription']; $product['products_description_raw'] = $product['products_description']; if ($product['products_image']) { $product['products_image_200'] = mslib_befe::getImagePath($product['products_image'], 'products', '200'); $product['products_image'] = mslib_befe::getImagePath($product['products_image'], 'products', '50'); } if ($product['categories_id']) { // get all cats to generate multilevel fake url $level = 0; $cats = mslib_fe::Crumbar($product['categories_id']); $cats = array_reverse($cats); $where = ''; if (count($cats) > 0) { foreach ($cats as $cat) { $where .= "categories_id[" . $level . "]=" . $cat['id'] . "&"; $level++; } $where = substr($where, 0, strlen($where) - 1); $where .= '&'; } // get all cats to generate multilevel fake url eof } $link = mslib_fe::typolink($this->conf['products_detail_page_pid'], '&' . $where . '&products_id=' . $product['products_id'] . '&tx_multishop_pi1[page_section]=products_detail'); if (mslib_fe::ProductHasAttributes($product['products_id'])) { // Product has attributes. We need to redirect the customer to the product detail page so the attributes can be selected header("Location: " . $this->FULL_HTTP_URL . $link); exit; } // chk if the product has staffel price if ($product['staffel_price'] && $this->ms['MODULES']['STAFFEL_PRICE_MODULE']) { $product['final_price'] = mslib_fe::calculateStaffelPrice($product['staffel_price'], 1); } if ($product['products_id']) { // add product to the cart (through from on products_detail page) $product['description'] = ''; $current_quantity = $cart['products'][$product['products_id']]['qty']; $cart['products'][$product['products_id']] = $product; $cart['products'][$product['products_id']]['qty'] = $current_quantity + $rel_carty_quantity; // PROTECTION WHEN PRODUCT MULTIPLICATION IS NOT A FLOAT WE HAVE TO CAST THE QUANTITY AS INTEGER if (!$product['products_multiplication'] || (int) $product['products_multiplication'] == $product['products_multiplication']) { $cart['products'][$product['products_id']]['qty'] = (int) $cart['products'][$product['products_id']]['qty']; } $cart['products'][$product['products_id']]['link'] = $link; if ($product['minimum_quantity'] > $cart['products'][$product['products_id']]['qty']) { $cart['products'][$product['products_id']]['qty'] = $product['minimum_quantity']; } // if ($product['products_multiplication']) { $ctr_end = $product['maximum_quantity'] > 0 ? $product['maximum_quantity'] : 9999; $qty_start = $product['minimum_quantity']; if ($cart['products'][$product['products_id']]['qty'] > $qty_start) { $low_number = $qty_start; $high_number = $qty_start; for ($ctr_start = $qty_start; $ctr_start <= $ctr_end; $ctr_start++) { if ($ctr_start > $qty_start) { $low_number = $high_number; $high_number += $product['products_multiplication']; } else { $low_number = $ctr_start; $high_number += $product['products_multiplication']; } if ($cart['products'][$product['products_id']]['qty'] > $low_number && $cart['products'][$product['products_id']]['qty'] < $high_number) { if (round($cart['products'][$product['products_id']]['qty'], 2) == round($low_number, 2)) { $cart['products'][$product['products_id']]['qty'] = $low_number; break; } else { if (round($cart['products'][$product['products_id']]['qty'], 2) == round($high_number, 2)) { $cart['products'][$product['products_id']]['qty'] = $high_number; break; } else { $low_remainder = $cart['products'][$product['products_id']]['qty'] - $low_number; $high_remainder = $cart['products'][$product['products_id']]['qty'] - $high_number; $cart['products'][$product['products_id']]['qty'] = $low_number; break; } } } } } } /* $GLOBALS['TSFE']->fe_user->setKey('ses', $this->cart_page_uid, $cart); if ($this->ms['eID']) { $GLOBALS['TSFE']->fe_user->storeSessionData(); } else { $GLOBALS['TSFE']->storeSessionData(); } */ tx_mslib_cart::storeCart($cart); } } } } } } // send notification message to admin if ($product['products_id']) { $where = ''; if ($product['categories_id']) { // get all cats to generate multilevel fake url $level = 0; $cats = mslib_fe::Crumbar($product['categories_id']); $cats = array_reverse($cats); $where = ''; if (count($cats) > 0) { foreach ($cats as $cat) { $where .= "categories_id[" . $level . "]=" . $cat['id'] . "&"; $level++; } $where = substr($where, 0, strlen($where) - 1); $where .= '&'; } // get all cats to generate multilevel fake url eof } $link = mslib_fe::typolink($this->conf['products_detail_page_pid'], '&' . $where . '&products_id=' . $product['products_id'] . '&tx_multishop_pi1[page_section]=products_detail'); if ($GLOBALS['TSFE']->fe_user->user['username']) { $customer_name = $GLOBALS['TSFE']->fe_user->user['username']; $customer_edit_link = mslib_fe::typolink($this->shop_pid . ',2003', '&tx_multishop_pi1[page_section]=edit_customer&tx_multishop_pi1[cid]=' . $GLOBALS['TSFE']->fe_user->user['uid'] . '&action=edit_customer'); } else { $customer_name = $this->pi_getLL('customer'); $customer_edit_link = ''; } $message = sprintf($this->pi_getLL('customer_added_productx_to_the_shopping_cart'), '<a href="' . $customer_edit_link . '">' . $customer_name . '</a>', '<a href="' . $link . '">' . $product['products_name'] . '</a>') . '.'; if (count($cart['products']) > 0) { if (!$sub_tr_type or $sub_tr_type == 'even') { $sub_tr_type = 'odd'; } else { $sub_tr_type = 'even'; } $mslib_cart = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_mslib_cart'); $mslib_cart->init($this); $cart = $mslib_cart->getCart(); $cart_content .= '<br />' . $this->pi_getLL('content') . ':<br />' . $mslib_cart->getHtmlCartContents('adminNotificationPopup'); $message .= $cart_content; } mslib_befe::storeNotificationMessage($this->pi_getLL('customer_action'), $message); } // end of notification } elseif ($this->get['delete_products_id']) { $shopping_cart_item = $this->get['delete_products_id']; if (is_array($cart['products'][$shopping_cart_item])) { // remove the cart item unset($cart['products'][$shopping_cart_item]); //$GLOBALS['TSFE']->fe_user->setKey('ses', $this->cart_page_uid, $cart); //$GLOBALS['TSFE']->storeSessionData(); tx_mslib_cart::storeCart($cart); tx_mslib_cart::getCart(); } } elseif (is_array($this->post['qty'])) { // add/update products in cart (from shopping cart page) foreach ($cart['products'] as $shopping_cart_item => $value) { if (!isset($value['products_id']) || isset($value['products_id']) && !$value['products_id']) { unset($cart['products'][$shopping_cart_item]); } } foreach ($this->post['qty'] as $shopping_cart_item => $qty) { if ($qty and strstr($qty, ",")) { $qty = str_replace(",", ".", $qty); } if ($qty and !is_numeric($qty)) { $qty = 1; } if (!$qty or $qty < 0.01) { unset($cart['products'][$shopping_cart_item]); } else { $products_id = $cart['products'][$shopping_cart_item]['products_id']; $product = mslib_fe::getProduct($products_id); $product['maximum_quantity'] = str_replace('.00', '', $product['maximum_quantity']); $product['minimum_quantity'] = str_replace('.00', '', $product['minimum_quantity']); // custom hook that can be controlled by third-party plugin if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartByShoppingCartPreProc'])) { $params = array('shopping_cart_item' => $shopping_cart_item, 'products_id' => &$products_id, 'product' => &$product, 'cart' => &$cart, 'qty' => &$qty); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartByShoppingCartPreProc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // custom hook that can be controlled by third-party plugin eof // chk if the product has staffel price if ($product['staffel_price'] && $this->ms['MODULES']['STAFFEL_PRICE_MODULE']) { $cart['products'][$shopping_cart_item]['final_price'] = mslib_fe::calculateStaffelPrice($product['staffel_price'], $qty) / $qty; } $cart['products'][$shopping_cart_item]['qty'] = $qty; // PROTECTION WHEN PRODUCT MULTIPLICATION IS NOT A FLOAT WE HAVE TO CAST IT AS INTEGER if (!$product['products_multiplication'] || (int) $product['products_multiplication'] == $product['products_multiplication']) { $cart['products'][$shopping_cart_item]['qty'] = (int) $cart['products'][$shopping_cart_item]['qty']; } if ($product['minimum_quantity'] > $cart['products'][$shopping_cart_item]['qty']) { $cart['products'][$shopping_cart_item]['qty'] = $product['minimum_quantity']; } if ($product['maximum_quantity'] > 0 && $qty > $product['maximum_quantity']) { $cart['products'][$shopping_cart_item]['qty'] = $product['maximum_quantity']; } if ($product['products_multiplication']) { $ctr_end = $product['maximum_quantity'] > 0 ? $product['maximum_quantity'] : 9999; $qty_start = $product['minimum_quantity']; if ($cart['products'][$shopping_cart_item]['qty'] > $qty_start) { $low_number = $qty_start; $high_number = $qty_start; for ($ctr_start = $qty_start; $ctr_start <= $ctr_end; $ctr_start++) { if ($ctr_start > $qty_start) { $low_number = $high_number; $high_number += $product['products_multiplication']; } else { $low_number = $ctr_start; $high_number += $product['products_multiplication']; } if ($cart['products'][$shopping_cart_item]['qty'] > $low_number && $cart['products'][$shopping_cart_item]['qty'] < $high_number) { if (round($cart['products'][$shopping_cart_item]['qty'], 2) == round($low_number, 2)) { $cart['products'][$shopping_cart_item]['qty'] = $low_number; break; } else { if (round($cart['products'][$shopping_cart_item]['qty'], 2) == round($high_number, 2)) { $cart['products'][$shopping_cart_item]['qty'] = $high_number; break; } else { $low_remainder = $cart['products'][$shopping_cart_item]['qty'] - $low_number; $high_remainder = $cart['products'][$shopping_cart_item]['qty'] - $high_number; $cart['products'][$shopping_cart_item]['qty'] = $low_number; break; } } } } } } } } //die(); //$GLOBALS['TSFE']->fe_user->setKey('ses', $this->cart_page_uid, $cart); //$GLOBALS['TSFE']->storeSessionData(); tx_mslib_cart::storeCart($cart); } // group discount if ($GLOBALS['TSFE']->fe_user->user['uid']) { $discount = mslib_fe::getUserGroupDiscount($GLOBALS['TSFE']->fe_user->user['uid']); if ($discount) { $cart['coupon_discount'] = $discount; $cart['discount'] = $discount; $cart['discount_type'] = 'percentage'; //$GLOBALS['TSFE']->fe_user->setKey('ses', $this->cart_page_uid, $cart); //$GLOBALS['TSFE']->storeSessionData(); tx_mslib_cart::storeCart($cart); } } // store cart contents for later analyses $cart_store_content = $mslib_cart->getCart(); //$cart_store_content=$GLOBALS['TSFE']->fe_user->getKey('ses', $this->cart_page_uid); mslib_befe::storeCustomerCartContent($cart_store_content); // custom hook that can be controlled by third-party plugin if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartPostHook'])) { $params = array('cart' => &$cart); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['updateCartPostHook'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // custom hook that can be controlled by third-party plugin eof if ($product['products_id'] and $this->ms['MODULES']['REDIRECT_BACK_TO_PRODUCTS_DETAIL_PAGE_AFTER_ADD_TO_CART']) { $where = ''; if ($product['categories_id']) { // get all cats to generate multilevel fake url $level = 0; $cats = mslib_fe::Crumbar($product['categories_id']); $cats = array_reverse($cats); $where = ''; if (count($cats) > 0) { foreach ($cats as $cat) { $where .= "categories_id[" . $level . "]=" . $cat['id'] . "&"; $level++; } $where = substr($where, 0, strlen($where) - 1); $where .= '&'; } // get all cats to generate multilevel fake url eof } $link = mslib_fe::typolink($this->conf['products_detail_page_pid'], '&' . $where . '&products_id=' . $product['products_id'] . '&tx_multishop_pi1[page_section]=products_detail'); if ($link) { header("Location: " . $this->FULL_HTTP_URL . $link); exit; } } } }
$options = array('caching' => true, 'cacheDir' => $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/cache/', 'lifeTime' => $this->ms['MODULES']['CACHE_TIME_OUT_SEARCH_PAGES']); $Cache_Lite = new Cache_Lite($options); $string = md5('ajax_products_staffelprice_search_' . $this->shop_pid . '_' . $_REQUEST['pid']); } if (!$this->ms['MODULES']['CACHE_FRONT_END'] or $this->ms['MODULES']['CACHE_FRONT_END'] and !($content = $Cache_Lite->get($string))) { if ($_REQUEST['pid']) { $this->get['pid'] = (int) $_REQUEST['pid']; $this->get['qty'] = (int) $_REQUEST['qty']; } if ($_REQUEST['pid'] and strlen($_REQUEST['pid']) < 1) { exit; } $product = mslib_fe::getProduct($this->get['pid'], '', '', 1, 1); $quantity = $this->get['qty']; if ($product['staffel_price']) { $staffel_price['price'] = mslib_fe::calculateStaffelPrice($product['staffel_price'], $quantity) / $quantity; } else { $staffel_price['price'] = $product['final_price']; } //if ($this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT']) { $staffel_price['price_include_vat'] = $staffel_price['price'] + $staffel_price['price'] * $product['tax_rate']; //} $staffel_price['display_price'] = number_format($staffel_price['price'], 2, '.', ''); $staffel_price['display_price_include_vat'] = number_format($staffel_price['price_include_vat'], 2, '.', ''); // $staffel_price['use_tax_id'] = true; if (isset($this->get['oid']) && is_numeric($this->get['oid']) && $this->get['oid'] > 0) { $orders = mslib_fe::getOrder($this->get['oid']); $iso_customer = mslib_fe::getCountryByName($orders['billing_country']); $iso_customer['country'] = $iso_customer['cn_short_en']; $vat_id = $orders['billing_vat_id'];
public function final_products_price($product, $quantity = 1, $add_currency = 1, $ignore_minimum_quantity = 0, $priceColumn = 'final_price') { if (!$ignore_minimum_quantity) { if ($quantity and $product['minimum_quantity'] > $quantity) { // check if the product has a minimum quantity $quantity = $product['minimum_quantity']; // sum cause we dont want to show the individual price $sum = 1; } } // hook if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['finalPriceCalc'])) { $params = array('product' => &$product, 'quantity' => &$quantity, 'add_currency' => &$add_currency, 'ignore_minimum_quantity' => &$ignore_minimum_quantity, 'priceColumn' => &$priceColumn); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['finalPriceCalc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // hook eof if ($product['staffel_price']) { $final_price = mslib_fe::calculateStaffelPrice($product['staffel_price'], $quantity) / $quantity; $product[$priceColumn] = $final_price; } else { $final_price = $product[$priceColumn]; } if ($sum and $product[$priceColumn] > 0) { $final_price = $product[$priceColumn] * $quantity; } // hook if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['finalPriceCalcPostProc'])) { $params = array('product' => &$product, 'quantity' => &$quantity, 'add_currency' => &$add_currency, 'ignore_minimum_quantity' => &$ignore_minimum_quantity, 'priceColumn' => &$priceColumn, 'final_price' => &$final_price); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['finalPriceCalcPostProc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // hook eof if ($this->conf['disableFeFromCalculatingVatPrices'] != '1') { if ($product['tax_rate'] and $this->ms['MODULES']['SHOW_PRICES_INCLUDING_VAT'] || $this->ms['MODULES']['SHOW_PRICES_WITH_AND_WITHOUT_VAT']) { // in this mode the stored prices in the tx_multishop_products are excluding VAT and we have to add it manually if ($product['country_tax_rate'] && $product['region_tax_rate']) { $country_tax_rate = mslib_fe::taxDecimalCrop($final_price * $product['country_tax_rate']); $region_tax_rate = mslib_fe::taxDecimalCrop($final_price * $product['region_tax_rate']); $final_price = $final_price + ($country_tax_rate + $region_tax_rate); } else { $tax_rate = mslib_fe::taxDecimalCrop($final_price * $product['tax_rate']); $final_price = $final_price + $tax_rate; } } } if ($add_currency) { return mslib_fe::amount2Cents2($final_price); } else { return $final_price; } }
$output['pagination'] = $pagination; } // products pagination module eof $output['products_name'] .= $product['products_name']; $output['products_name_marker'] = $product['products_name']; $output['admin_link'] = ''; if ($this->ROOTADMIN_USER || $this->ADMIN_USER && $this->CATALOGADMIN_USER) { $output['admin_link'] = '<div class="admin_menu"><a href="' . mslib_fe::typolink($this->shop_pid . ',2003', '&tx_multishop_pi1[page_section]=edit_product&cid=' . $product['categories_id'] . '&pid=' . $product['products_id'] . '&action=edit_product', 1) . '" class="admin_menu_edit"><i class="fa fa-pencil"></i></a> <a href="' . mslib_fe::typolink($this->shop_pid . ',2003', '&tx_multishop_pi1[page_section]=delete_product&cid=' . $product['categories_id'] . '&pid=' . $product['products_id'] . '&action=delete_product', 1) . '" class="admin_menu_remove" title="Remove"><i class="fa fa-trash-o"></i></a></div>'; $output['products_name'] .= $output['admin_link']; } $final_price = mslib_fe::final_products_price($product); if ($product['tax_id']) { $tax = mslib_fe::getTaxById($product['tax_id']); if ($tax) { if ($product['staffel_price'] > 0) { $price_excl_vat = mslib_fe::calculateStaffelPrice($product['staffel_price'], $qty) / $qty; } else { $price_excl_vat = $product['final_price']; } //$price_excl_vat=mslib_fe::amount2Cents($price_excl_vat); } if ($product['tax_id'] && $this->ms['MODULES']['SHOW_PRICES_WITH_AND_WITHOUT_VAT']) { if ($tax) { $sub_content .= '<div class="price_excluding_vat">' . $this->pi_getLL('excluding_vat') . ' ' . mslib_fe::amount2Cents($price_excl_vat) . '</div>'; } } } $staffel_price_hid = ''; if ($product['staffel_price'] && $this->ms['MODULES']['STAFFEL_PRICE_MODULE']) { $staffel_price_hid = '<input type="hidden" name="staffel_price" id="staffel_price" value="' . $product['staffel_price'] . '" readonly/>'; }