public function displayHeader() { global $css_files, $js_files; if (!self::$initialized) { $this->init(); } // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies) header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); /* Hooks are volontary out the initialize array (need those variables already assigned) */ self::$smarty->assign(array('time' => time(), 'static_token' => Tools::getToken(false), 'token' => Tools::getToken(), 'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'), 'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'), 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => (int) Tools::getValue('content_only'))); self::$smarty->assign(array('HOOK_HEADER' => Module::hookExec('header'), 'HOOK_TOP' => Module::hookExec('top'), 'HOOK_BELOWNAVH' => Module::hookExec('belownavh'), 'HOOK_FILTERBY_CENTER' => Module::hookExec('filterbyCenter'))); if ((Configuration::get('PS_CSS_THEME_CACHE') or Configuration::get('PS_JS_THEME_CACHE')) and is_writable(_PS_THEME_DIR_ . 'cache')) { // CSS compressor management if (Configuration::get('PS_CSS_THEME_CACHE')) { Tools::cccCss(); } //JS compressor management if (Configuration::get('PS_JS_THEME_CACHE')) { Tools::cccJs(); } } self::$smarty->assign('css_files', $css_files); self::$smarty->assign('js_files', array_unique($js_files)); self::$smarty->display(_PS_THEME_DIR_ . 'header.tpl'); }
public function run() { $this->init(); $this->preProcess(); if (Tools::getValue('ajax') == 'true') { if (Tools::getIsset('summary')) { if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) { if (self::$cookie->id_customer) { $customer = new Customer((int) self::$cookie->id_customer); $groups = $customer->getGroups(); } else { $groups = array(1); } if ((int) self::$cart->id_address_delivery) { $deliveryAddress = new Address((int) self::$cart->id_address_delivery); } $result = array('carriers' => Carrier::getCarriersForOrder((int) Country::getIdZone((isset($deliveryAddress) and (int) $deliveryAddress->id) ? (int) $deliveryAddress->id_country : (int) Configuration::get('PS_COUNTRY_DEFAULT')), $groups)); } $result['summary'] = self::$cart->getSummaryDetails(); $result['customizedDatas'] = Product::getAllCustomizedDatas((int) self::$cart->id); $result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']); $result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']); die(Tools::jsonEncode($result)); } else { $this->includeCartModule(); } } else { $this->setMedia(); $this->displayHeader(); $this->process(); $this->displayContent(); $this->displayFooter(); } }
public function update($nullValues = false) { self::$_nbProducts = 0; $return = parent::update(); Module::hookExec('cart'); return $return; }
function displayOrderStep($params) { global $smarty, $cart, $errors; $smarty->assign('errors', $errors); if (file_exists(_PS_SHIP_IMG_DIR_ . intval($cart->id_carrier) . '.jpg')) { $smarty->assign('carrierPicture', 1); } $cart->save(); // Hack to get loyalty and other modules happy $summary = $cart->getSummaryDetails(); $customizedDatas = Product::getAllCustomizedDatas(intval($cart->id)); Product::addCustomizationPrice($summary['products'], $customizedDatas); if ($free_ship = intval(Configuration::get('PS_SHIPPING_FREE_PRICE'))) { $discounts = $cart->getDiscounts(); $total_free_ship = $free_ship - ($summary['total_products_wt'] + $summary['total_discounts']); foreach ($discounts as $discount) { if ($discount['id_discount_type'] == 3) { $total_free_ship = 0; break; } } $smarty->assign('free_ship', $total_free_ship); } $smarty->assign($summary); $token = Tools::getToken(false); $smarty->assign(array('token_cart' => $token, 'voucherAllowed' => Configuration::get('PS_VOUCHERS'), 'HOOK_SHOPPING_CART' => Module::hookExec('shoppingCart', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Module::hookExec('shoppingCartExtra', $summary), 'shippingCost' => $cart->getOrderTotalLC(true, 5), 'shippingCostTaxExc' => $cart->getOrderTotalLC(false, 5), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'lastProductAdded' => $cart->getLastProduct())); Tools::safePostVars(); include_once dirname(__FILE__) . '/../../header.php'; echo $this->display(__FILE__, 'ordersummary.tpl'); }
protected function canonicalRedirection() { global $link, $cookie; if (Configuration::get('PS_CANONICAL_REDIRECT') && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') { // Automatically redirect to the canonical URL if needed if (isset($this->php_self) && !empty($this->php_self)) { // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain $canonicalURL = $link->getPageLink($this->php_self, $this->ssl, $cookie->id_lang); if (!Tools::getValue('ajax') && !preg_match('/^' . Tools::pRegexp($canonicalURL, '/') . '([&?].*)?$/', ($this->ssl && _PS_SSL_ENABLED_ ? 'https://' : 'http://') . urldecode($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']))) { if ($_SERVER['REQUEST_URI'] == __PS_BASE_URI__) { header('HTTP/1.0 303 See Other'); header('Cache-Control: no-cache'); } else { header('HTTP/1.0 301 Moved Permanently'); header('Cache-Control: no-cache'); } $params = ''; $excludedKey = array('isolang', 'id_lang'); foreach ($_GET as $key => $value) { if (!in_array($key, $excludedKey)) { $params .= ($params == '' ? '?' : '&') . $key . '=' . $value; } } Module::hookExec('frontCanonicalRedirect'); if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) { die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $canonicalURL . $params . '">' . $canonicalURL . $params . '</a>'); } Tools::redirectLink($canonicalURL . $params); } } } }
function processOrderStep($params) { global $cart, $smarty, $errors; if (!isset($_POST['id_address_delivery']) or !Address::isCountryActiveById(intval($_POST['id_address_delivery']))) { $errors[] = 'this address is not in a valid area'; } else { $cart->id_address_delivery = intval($_POST['id_address_delivery']); $cart->id_address_invoice = isset($_POST['same']) ? intval($_POST['id_address_delivery']) : intval($_POST['id_address_invoice']); if (!$cart->update()) { $errors[] = Tools::displayError('an error occured while updating your cart'); } Module::hookExec('orderAddressVerification', array()); if (isset($_POST['message']) and !empty($_POST['message'])) { if (!Validate::isMessage($_POST['message'])) { $errors[] = Tools::displayError('invalid message'); } elseif ($oldMessage = Message::getMessageByCartId(intval($cart->id))) { $message = new Message(intval($oldMessage['id_message'])); $message->message = htmlentities($_POST['message'], ENT_COMPAT, 'UTF-8'); $message->update(); } else { $message = new Message(); $message->message = htmlentities($_POST['message'], ENT_COMPAT, 'UTF-8'); $message->id_cart = intval($cart->id); $message->id_customer = intval($cart->id_customer); $message->add(); } } } }
public function displayTopNews() { if (!self::$initialized) { parent::init(); } self::$smarty->assign(array('NEWS_HOOK' => Module::hookExec('newshook'))); returnparent::displayTopNews(); }
public function add($autodate = true, $nullValues = false) { if (parent::add($autodate, $nullValues)) { Module::hookExec('paymentCCAdded', array('paymentCC' => $this)); return true; } return false; }
public function hookLeftColumn($params) { global $smarty; if (!$params['cookie']->isLogged()) { return false; } $smarty->assign(array('voucherAllowed' => intval(Configuration::get('PS_VOUCHERS')), 'returnAllowed' => intval(Configuration::get('PS_ORDER_RETURN')), 'HOOK_BLOCK_MY_ACCOUNT' => Module::hookExec('myAccountBlock'))); return $this->display(__FILE__, $this->name . '.tpl'); }
public function process() { parent::process(); if ($id_order = Tools::getValue('id_order') and $email = Tools::getValue('email')) { $order = new Order((int) $id_order); if (!Validate::isLoadedObject($order)) { $this->errors[] = Tools::displayError('Invalid order'); } elseif (!$order->isAssociatedAtGuest($email)) { $this->errors[] = Tools::displayError('Invalid order'); } else { $customer = new Customer((int) $order->id_customer); $id_order_state = (int) $order->getCurrentState(); $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang); $addressInvoice = new Address((int) $order->id_address_invoice); $addressDelivery = new Address((int) $order->id_address_delivery); $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields); $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); if ($order->total_discounts > 0) { self::$smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts)); } $products = $order->getProducts(); $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart); Product::addCustomizationPrice($products, $customizedDatas); $this->processAddressFormat($addressDelivery, $addressInvoice); self::$smarty->assign(array('shop_name' => Configuration::get('PS_SHOP_NAME'), 'order' => $order, 'return_allowed' => false, 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable((int) $id_order_state) and $order->invoice_number, 'order_history' => $order->getHistory((int) self::$cookie->id_lang, false, true), 'products' => $products, 'discounts' => $order->getDiscounts(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) ? new State((int) $addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) ? new State((int) $addressDelivery->id_state) : false, 'is_guest' => true, 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'use_tax' => Configuration::get('PS_TAX'), 'customizedDatas' => $customizedDatas, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues)); if ($carrier->url and $order->shipping_number) { self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); } self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order)); if (Tools::isSubmit('submitTransformGuestToCustomer')) { $customer = new Customer((int) $order->id_customer); if (!Validate::isLoadedObject($customer)) { $this->errors[] = Tools::displayError('Invalid customer'); } if (!$customer->transformToCustomer(self::$cookie->id_lang, Tools::getValue('password'))) { $this->errors[] = Tools::displayError('An error occurred while transforming guest to customer.'); } if (!Tools::getValue('password')) { $this->errors[] = Tools::displayError('Invalid password'); } else { self::$smarty->assign('transformSuccess', true); } } } if (sizeof($this->errors)) { /* Handle brute force attacks */ sleep(1); } } self::$smarty->assign(array('action' => 'guest-tracking.php', 'errors' => $this->errors)); }
public function process() { parent::process(); self::$smarty->assign('HOOK_HOME', Module::hookExec('home')); self::$smarty->assign('HOOK_MAIN_TOP', Module::hookExec('displayMainTop')); self::$smarty->assign('HOOK_CONTENT_SIDE1', Module::hookExec('displayContentSide1')); //self::$smarty->assign('HOOK_CONTENT_TOP' , Module::hookExec('displayContentTop')); //self::$smarty->assign('HOOK_CONTENT_BTM' , Module::hookExec('displayContentBtm')); self::$smarty->assign('HOOK_CONTENT_SIDE2', Module::hookExec('displayContentSide2')); self::$smarty->assign('HOOK_MAIN_BTM', Module::hookExec('displayMainBtm')); }
public function preProcess() { parent::preProcess(); if (Tools::isSubmit('submitReturnMerchandise')) { $customizationQtyInput = Tools::getValue('customization_qty_input'); if (!($id_order = (int) Tools::getValue('id_order'))) { Tools::redirect('history.php'); } if (!($order_qte_input = Tools::getValue('order_qte_input'))) { Tools::redirect('order-follow.php?errorDetail1'); } if ($customizationIds = Tools::getValue('customization_ids') and !$customizationQtyInput) { Tools::redirect('order-follow.php?errorDetail1'); } if (!($ids_order_detail = Tools::getValue('ids_order_detail')) and !$customizationIds) { Tools::redirect('order-follow.php?errorDetail2'); } $order = new Order((int) $id_order); if (!$order->isReturnable()) { Tools::redirect('order-follow.php?errorNotReturnable'); } if ($order->id_customer != self::$cookie->id_customer) { die(Tools::displayError()); } $orderReturn = new OrderReturn(); $orderReturn->id_customer = (int) self::$cookie->id_customer; $orderReturn->id_order = $id_order; $orderReturn->question = strval(Tools::getValue('returnText')); if (empty($orderReturn->question)) { Tools::redirect('order-follow.php?errorMsg'); } if (!$orderReturn->checkEnoughProduct($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput)) { Tools::redirect('order-follow.php?errorQuantity'); } $orderReturn->state = 1; $orderReturn->add(); $orderReturn->addReturnDetail($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput); Module::hookExec('orderReturn', array('orderReturn' => $orderReturn)); Tools::redirect('order-follow.php'); } $ordersReturn = OrderReturn::getOrdersReturn((int) self::$cookie->id_customer); if (Tools::isSubmit('errorQuantity')) { self::$smarty->assign('errorQuantity', true); } elseif (Tools::isSubmit('errorMsg')) { self::$smarty->assign('errorMsg', true); } elseif (Tools::isSubmit('errorDetail1')) { self::$smarty->assign('errorDetail1', true); } elseif (Tools::isSubmit('errorDetail2')) { self::$smarty->assign('errorDetail2', true); } elseif (Tools::isSubmit('errorNotReturnable')) { self::$smarty->assign('errorNotReturnable', true); } self::$smarty->assign('ordersReturn', $ordersReturn); }
public function init() { global $smarty; parent::init(); if (Module::isInstalled('agilepricecomparison')) { $HOOK_AGILE_PRICE_COMPARISON = ''; if (!intval(Configuration::get('AGILE_PC_USE_DEFAULT_HOOK'))) { $HOOK_AGILE_PRICE_COMPARISON = Module::hookExec('agilepricecomparison', array()); } $smarty->assign(array('HOOK_AGILE_PRICE_COMPARISON' => $HOOK_AGILE_PRICE_COMPARISON)); } }
public function postProcess() { global $currentIndex; if (Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE')) { $uploadMaxSize = (int) str_replace('M', '', ini_get('upload_max_filesize')); $postMaxSize = (int) str_replace('M', '', ini_get('post_max_size')); $maxSize = $uploadMaxSize < $postMaxSize ? $uploadMaxSize : $postMaxSize; $_POST['PS_ATTACHMENT_MAXIMUM_SIZE'] = $maxSize < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE') ? $maxSize : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE'); } if (isset($_POST['submitGeneral' . $this->table])) { Module::hookExec('categoryUpdate'); // We call this hook, for regenerate cache of categories if (Tools::getValue('PS_CONDITIONS') == true and (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 or !Db::getInstance()->getValue(' SELECT `id_cms` FROM `' . _DB_PREFIX_ . 'cms` WHERE id_cms = ' . (int) Tools::getValue('PS_CONDITIONS_CMS_ID')))) { $this->_errors[] = Tools::displayError('Assign a valid CMS page if you want it to be read.'); } if ($this->tabAccess['edit'] === '1') { $this->_postConfig($this->_fieldsGeneral); } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } elseif (isset($_POST['submitShop' . $this->table])) { if ($this->tabAccess['edit'] === '1') { $this->_postConfig($this->_fieldsShop); } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } elseif (isset($_POST['submitAppearance' . $this->table])) { if ($this->tabAccess['edit'] === '1') { $this->_postConfig($this->_fieldsAppearance); } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } elseif (isset($_POST['submitThemes' . $this->table])) { if ($this->tabAccess['edit'] === '1') { if ($val = Tools::getValue('PS_THEME')) { if (rewriteSettingsFile(NULL, $val, NULL)) { Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token); } else { $this->_errors[] = Tools::displayError('Cannot access settings file.'); } } else { $this->_errors[] = Tools::displayError('You must choose a graphical theme.'); } } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } parent::postProcess(); }
public function displayFooter() { if (!self::$initialized) { $this->init(); } self::$smarty->assign(array('HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => self::$cart)), 'HOOK_FOOTER' => Module::hookExec('footer'), 'content_only' => (int) Tools::getValue('content_only'), 'HOOK_CONTENT_BTM' => Module::hookExec('displayContentBtm'), 'HOOK_CONTENT_SIDE2' => Module::hookExec('displayContentSide2'), 'HOOK_MAIN_BTM' => Module::hookExec('displayMainBtm'), 'HOOK_BBODY_BTM' => Module::hookExec('displayBbodyBtm'), 'HOOK_BFOOT_TOP' => Module::hookExec('displayBfootTop'), 'HOOK_BFOOT_BTM' => Module::hookExec('displayBfootBtm'))); self::$smarty->display(_PS_THEME_DIR_ . 'footer.tpl'); //live edit if (Tools::isSubmit('live_edit') && ($ad = Tools::getValue('ad') && Tools::getValue('liveToken') == sha1(Tools::getValue('ad') . _COOKIE_KEY_))) { self::$smarty->assign(array('ad' => $ad, 'live_edit' => true)); self::$smarty->display(_PS_ALL_THEMES_DIR_ . 'live_edit.tpl'); } else { Tools::displayError(); } }
public function displayHeader() { global $css_files, $js_files; if (!self::$initialized) { $this->init(); } // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies) header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); /* Hooks are volontary out the initialize array (need those variables already assigned) */ self::$smarty->assign(array('time' => time(), 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'static_token' => Tools::getToken(false), 'token' => Tools::getToken(), 'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'), 'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'), 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => (int) Tools::getValue('content_only'))); self::$smarty->assign(array('HOOK_HEADER' => Module::hookExec('header'), 'HOOK_TOP' => Module::hookExec('top'), 'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'))); if ((Configuration::get('PS_CSS_THEME_CACHE') or Configuration::get('PS_JS_THEME_CACHE')) and is_writable(_PS_THEME_DIR_ . 'cache')) { // CSS compressor management if (Configuration::get('PS_CSS_THEME_CACHE')) { Tools::cccCss(); } //JS compressor management if (Configuration::get('PS_JS_THEME_CACHE')) { Tools::cccJs(); } } /*pl*/ $tags_name = Tools::getValue('pltn'); self::$smarty->assign('meta_title', $tags_name . ' - Blog '); // $id_pl_blog_category = (int) Tools::getValue('plidc'); // if ($id_pl_blog_category != null) // { // $category = $this->getMetaCategoryById($id_pl_blog_category); // $meta_title = $category['category_meta_title']; // $meta_description = $category['category_meta_description']; // $meta_keywords = $category['category_meta_keywords']; // if ($meta_title != null) // self::$smarty->assign('meta_title', $meta_title.' - Blog '); // if ($meta_description != null) // self::$smarty->assign('meta_description',$meta_description); // if ($meta_keywords != null) // self::$smarty->assign('meta_keywords', $meta_keywords); // } // else // { // $category_name = 'List post'; // self::$smarty->assign('meta_title', $category_name.' - Blog '); // } /* -pl */ self::$smarty->assign('css_files', $css_files); self::$smarty->assign('js_files', array_unique($js_files)); self::$smarty->display(_PS_THEME_DIR_ . 'header.tpl'); }
/** * Smarty {hookExec} function plugin * * Type: function<br> * Name: hookExec<br> * Purpose: Execute a prestashop hook * @author Egil Möller <*****@*****.**> * <pre> * params * hook name of hook to execute * Set any of the following global variables: * product * cart * </pre> * @param array parameters * @param Smarty * @return string|null */ function smarty_function_hookExec($params, &$smarty) { global $product, $cart; $old_product = $product; $old_cart = $cart; if (isset($params['product'])) { $product = $params['product']; } if (isset($params['cart'])) { $cart = $params['cart']; } $res = Module::hookExec($params['hook']); $cart = $old_cart; $product = $old_product; return $res; }
public function process() { parent::process(); $hasProduct = false; $product_list = Tools::getValue('compare_product_list'); $postProducts = isset($product_list) ? rtrim($product_list, '|') : ''; if (!Configuration::get('PS_COMPARATOR_MAX_ITEM')) { return Tools::redirect('404.php'); } if ($postProducts) { $ids = array_unique(explode('|', $postProducts)); if (sizeof($ids) > 0) { if (sizeof($ids) > Configuration::get('PS_COMPARATOR_MAX_ITEM')) { $ids = array_slice($ids, 0, Configuration::get('PS_COMPARATOR_MAX_ITEM')); } $listProducts = array(); $listFeatures = array(); foreach ($ids as $id) { $curProduct = new Product((int) $id, true, (int) self::$cookie->id_lang); if (!Validate::isLoadedObject($curProduct)) { continue; } if (!$curProduct->active) { unset($ids[$k]); continue; } foreach ($curProduct->getFrontFeatures(self::$cookie->id_lang) as $feature) { $listFeatures[$curProduct->id][$feature['id_feature']] = $feature['value']; } $cover = Product::getCover((int) $id); $curProduct->id_image = Tools::htmlentitiesUTF8(Product::defineProductImage(array('id_image' => $cover['id_image'], 'id_product' => $id), self::$cookie->id_lang)); $curProduct->allow_oosp = Product::isAvailableWhenOutOfStock($curProduct->out_of_stock); $listProducts[] = $curProduct; } if (sizeof($listProducts) > 0) { $width = 80 / sizeof($listProducts); $hasProduct = true; $ordered_features = Feature::getFeaturesForComparison($ids, self::$cookie->id_lang); self::$smarty->assign(array('ordered_features' => $ordered_features, 'product_features' => $listFeatures, 'products' => $listProducts, 'link' => new Link(), 'width' => $width, 'homeSize' => Image::getSize('home'))); self::$smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids))); } } } self::$smarty->assign('hasProduct', $hasProduct); }
public function preProcess() { parent::preProcess(); $query = urldecode(Tools::getValue('q')); if ($this->ajaxSearch) { self::$link = new Link(); $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true); if (is_array($searchResults)) { foreach ($searchResults as &$product) { $product['product_link'] = self::$link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']); } } die(Tools::jsonEncode($searchResults)); } elseif ($this->instantSearch && !is_array($query)) { $this->productSort(); $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))); $this->p = abs((int) Tools::getValue('p', 1)); $search = Search::find((int) self::$cookie->id_lang, $query, $this->p, $this->n, $this->orderBy, $this->orderWay); Module::hookExec('search', array('expr' => $query, 'total' => $search['total'])); $nbProducts = $search['total']; $this->pagination($nbProducts); self::$smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'instantSearch' => $this->instantSearch, 'homeSize' => Image::getSize('home'))); } elseif ($query = Tools::getValue('search_query', Tools::getValue('ref')) and !is_array($query)) { $this->productSort(); $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))); $this->p = abs((int) Tools::getValue('p', 1)); $search = Search::find((int) self::$cookie->id_lang, $query, $this->p, $this->n, $this->orderBy, $this->orderWay); Module::hookExec('search', array('expr' => $query, 'total' => $search['total'])); $nbProducts = $search['total']; $this->pagination($nbProducts); self::$smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'homeSize' => Image::getSize('home'))); } elseif ($tag = urldecode(Tools::getValue('tag')) and !is_array($tag)) { $this->productSort(); $nbProducts = (int) Search::searchTag((int) self::$cookie->id_lang, $tag, true); $this->pagination($nbProducts); $result = Search::searchTag((int) self::$cookie->id_lang, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay); Module::hookExec('search', array('expr' => $tag, 'total' => sizeof($result))); self::$smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home'))); } else { self::$smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0)); } self::$smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')); }
/** * Logs a given customer in. */ public static function login_customer($id_customer) { global $cart, $cookie; // Make sure that that the customers exists. $sql = "SELECT * FROM `" . _DB_PREFIX_ . "customer` WHERE `id_customer` = '" . pSQL($id_customer) . "'"; $result = Db::getInstance()->GetRow($sql); // The user account has been found! if (!empty($result['id_customer'])) { // See => CustomerCore::getByEmail $customer = new Customer(); $customer->id = $result['id_customer']; foreach ($result as $key => $value) { if (key_exists($key, $customer)) { $customer->{$key} = $value; } } // See => AuthControllerCore Module::hookExec('beforeAuthentication'); $cookie->id_compare = isset($cookie->id_compare) ? $cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id); $cookie->id_customer = (int) $customer->id; $cookie->customer_lastname = $customer->lastname; $cookie->customer_firstname = $customer->firstname; $cookie->passwd = $customer->passwd; $cookie->logged = 1; $cookie->email = $customer->email; $cookie->is_guest = $customer->isGuest(); if (Configuration::get('PS_CART_FOLLOWING') and (empty($cookie->id_cart) or Cart::getNbProducts($cookie->id_cart) == 0)) { $cookie->id_cart = (int) Cart::lastNoneOrderedCart((int) $customer->id); } // Update cart address. $cart->id_carrier = 0; $cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id); $cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id); $cart->secure_key = $customer->secure_key; $cart->update(); Module::hookExec('authentication'); // Customer is now logged in. return true; } // Invalid customer specified. return false; }
/** * Inflate customer via id and authenticate * -- */ public function login($i_id_customer = 0) { $cookie = $this->context->cookie; $customer = new Customer(); $customer->id = $i_id_customer; $cookie->id_customer = (int) $customer->id; $cookie->customer_lastname = $customer->lastname; $cookie->customer_firstname = $customer->firstname; $cookie->logged = 1; $cookie->passwd = $customer->passwd; $cookie->email = $customer->email; if (Configuration::get('PS_CART_FOLLOWING') && (empty($cookie->id_cart) || Cart::getNbProducts($cookie->id_cart) == 0)) { $cookie->id_cart = (int) Cart::lastNoneOrderedCart((int) $customer->id); } if (version_compare(_PS_VERSION_, '1.5', '>')) { Hook::exec('actionAuthentication'); } else { Module::hookExec('authentication'); } $this->redirectOpenerAccount(); }
public function postProcess() { global $currentIndex; /* PrestaShop demo mode */ if (_PS_MODE_DEMO_) { $this->_errors[] = Tools::displayError('This functionnality has been disabled.'); return; } if (Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE') or Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') or Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE')) { $uploadMaxSize = (int) str_replace('M', '', ini_get('upload_max_filesize')); $postMaxSize = (int) str_replace('M', '', ini_get('post_max_size')); $maxSize = $uploadMaxSize < $postMaxSize ? $uploadMaxSize : $postMaxSize; $_POST['PS_ATTACHMENT_MAXIMUM_SIZE'] = $maxSize < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE') ? $maxSize : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE'); if (Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') > $maxSize or Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE') > $maxSize) { $this->_errors[] = Tools::displayError($this->l('The chosen limit is superior to the server\'s maximum upload capacity. You need to increase your server limit.')); return; } else { if (!Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE')) { $_POST['PS_LIMIT_UPLOAD_FILE_VALUE'] = 1; } else { if (!Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE')) { $_POST['PS_LIMIT_UPLOAD_IMAGE_VALUE'] = 1; } else { $_POST['PS_LIMIT_UPLOAD_FILE_VALUE'] = Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE'); $_POST['PS_LIMIT_UPLOAD_IMAGE_VALUE'] = Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE'); } } } } if (isset($_POST['submitGeneral' . $this->table])) { Module::hookExec('categoryUpdate'); // We call this hook, for regenerate cache of categories if (Tools::getValue('PS_CONDITIONS') == true and (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 or !Db::getInstance()->getValue(' SELECT `id_cms` FROM `' . _DB_PREFIX_ . 'cms` WHERE id_cms = ' . (int) Tools::getValue('PS_CONDITIONS_CMS_ID')))) { $this->_errors[] = Tools::displayError('Assign a valid CMS page if you want it to be read.'); } if ($this->tabAccess['edit'] === '1') { $this->_postConfig($this->_fieldsGeneral); } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } elseif (isset($_POST['submitShop' . $this->table])) { if ($this->tabAccess['edit'] === '1') { $this->_postConfig($this->_fieldsShop); } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } elseif (isset($_POST['submitAppearance' . $this->table])) { if ($this->tabAccess['edit'] === '1') { $this->_postConfig($this->_fieldsAppearance); } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } elseif (isset($_POST['submitThemes' . $this->table])) { if ($this->tabAccess['edit'] === '1') { if ($val = Tools::getValue('PS_THEME')) { if (rewriteSettingsFile(NULL, $val, NULL)) { Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token); } else { $this->_errors[] = Tools::displayError('Cannot access settings file.'); } } else { $this->_errors[] = Tools::displayError('You must choose a graphical theme.'); } } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } parent::postProcess(); }
/** * Copy a product image * * @param integer $id_product Product Id for product image filename * @param integer $id_image Image Id for product image filename */ public function copyImage($id_product, $id_image, $method = 'auto') { if (!isset($_FILES['image_product']['tmp_name']) or !file_exists($_FILES['image_product']['tmp_name'])) { return false; } if ($error = checkImage($_FILES['image_product'], $this->maxImageSize)) { $this->_errors[] = $error; } else { if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName)) { $this->_errors[] = Tools::displayError('An error occured during the image upload'); } elseif (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $id_product . '-' . $id_image . '.jpg')) { $this->_errors[] = Tools::displayError('an error occurred while copying image'); } elseif ($method == 'auto') { $imagesTypes = ImageType::getImagesTypes('products'); foreach ($imagesTypes as $k => $imageType) { if (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $id_product . '-' . $id_image . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) { $this->_errors[] = Tools::displayError('an error occurred while copying image') . ' ' . stripslashes($imageType['name']); } } } @unlink($tmpName); Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_product)); } }
} $months = Tools::dateMonths(); if (isset($_POST['days']) and is_numeric($_POST['days'])) { $selectedDays = intval($_POST['days']); } $days = Tools::dateDays(); /* Select the most appropriate country */ if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) { $selectedCountry = intval($_POST['id_country']); } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); if (Validate::isLanguageIsoCode($array[0])) { $selectedCountry = Country::getByIso($array[0]); if (!$selectedCountry) { $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT')); } } } if (!isset($selectedCountry)) { $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT')); } $countries = Country::getCountries(intval($cookie->id_lang), true); $smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0)); /* Call a hook to display more information on form */ $smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop'))); } include dirname(__FILE__) . '/header.php'; $smarty->assign('errors', $errors); Tools::safePostVars(); $smarty->display(_PS_THEME_DIR_ . 'authentication.tpl'); include dirname(__FILE__) . '/footer.php';
public function preProcess() { parent::preProcess(); if (self::$cookie->isLogged() and !Tools::isSubmit('ajax')) { Tools::redirect('my-account.php'); } if (Tools::getValue('create_account')) { $create_account = 1; self::$smarty->assign('email_create', 1); } if (Tools::isSubmit('SubmitCreate')) { if (!Validate::isEmail($email = Tools::getValue('email_create')) or empty($email)) { $this->errors[] = Tools::displayError('Invalid e-mail address'); } elseif (Customer::customerExists($email)) { $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.'); $_POST['email'] = $_POST['email_create']; unset($_POST['email_create']); } else { $create_account = 1; self::$smarty->assign('email_create', Tools::safeOutput($email)); $_POST['email'] = $email; } } if (Tools::isSubmit('submitAccount') or Tools::isSubmit('submitGuestAccount')) { $create_account = 1; if (Tools::isSubmit('submitAccount')) { self::$smarty->assign('email_create', 1); } /* New Guest customer */ if (!Tools::getValue('is_new_customer', 1) and !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) { $this->errors[] = Tools::displayError('You cannot create a guest account.'); } if (!Tools::getValue('is_new_customer', 1)) { $_POST['passwd'] = md5(time() . _COOKIE_KEY_); } if (isset($_POST['guest_email']) and $_POST['guest_email']) { $_POST['email'] = $_POST['guest_email']; } /* Preparing customer */ $customer = new Customer(); $lastnameAddress = $_POST['lastname']; $firstnameAddress = $_POST['firstname']; $_POST['lastname'] = $_POST['customer_lastname']; $_POST['firstname'] = $_POST['customer_firstname']; if (!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) { $this->errors[] = Tools::displayError('You must register at least one phone number'); } if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) { $this->errors[] = Tools::displayError('Invalid date of birth'); } $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days']; $this->errors = array_unique(array_merge($this->errors, $customer->validateControler())); /* Preparing address */ $address = new Address(); $_POST['lastname'] = $lastnameAddress; $_POST['firstname'] = $firstnameAddress; $address->id_customer = 1; $this->errors = array_unique(array_merge($this->errors, $address->validateControler())); /* US customer: normalize the address */ if ($address->id_country == Country::getByIso('US')) { include_once _PS_TAASC_PATH_ . 'AddressStandardizationSolution.php'; $normalize = new AddressStandardizationSolution(); $address->address1 = $normalize->AddressLineStandardization($address->address1); $address->address2 = $normalize->AddressLineStandardization($address->address2); } $zip_code_format = Country::getZipCodeFormat((int) Tools::getValue('id_country')); if (Country::getNeedZipCode((int) Tools::getValue('id_country'))) { if ($postcode = Tools::getValue('postcode') and $zip_code_format) { $zip_regexp = '/^' . $zip_code_format . '$/ui'; $zip_regexp = str_replace(' ', '( |)', $zip_regexp); $zip_regexp = str_replace('-', '(-|)', $zip_regexp); $zip_regexp = str_replace('N', '[0-9]', $zip_regexp); $zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp); $zip_regexp = str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), $zip_regexp); if (!preg_match($zip_regexp, $postcode)) { $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), str_replace('N', '0', str_replace('L', 'A', $zip_code_format))); } } elseif ($zip_code_format) { $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is required.'); } elseif ($postcode and !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode)) { $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.'); } } if (Country::isNeedDniByCountryId($address->id_country) and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) { $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.'); } elseif (!Country::isNeedDniByCountryId($address->id_country)) { $address->dni = NULL; } if (!sizeof($this->errors)) { if (Customer::customerExists(Tools::getValue('email'))) { $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.'); } if (Tools::isSubmit('newsletter')) { $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr()); $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s')); } if (!sizeof($this->errors)) { if (!($country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT'))) or !Validate::isLoadedObject($country)) { die(Tools::displayError()); } if ((int) $country->contains_states and !(int) $address->id_state) { $this->errors[] = Tools::displayError('This country requires a state selection.'); } else { $customer->active = 1; /* New Guest customer */ if (Tools::isSubmit('is_new_customer')) { $customer->is_guest = !Tools::getValue('is_new_customer', 1); } else { $customer->is_guest = 0; } if (!$customer->add()) { $this->errors[] = Tools::displayError('An error occurred while creating your account.'); } else { $address->id_customer = (int) $customer->id; if (!$address->add()) { $this->errors[] = Tools::displayError('An error occurred while creating your address.'); } else { if (!$customer->is_guest) { if (!Mail::Send((int) self::$cookie->id_lang, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname . ' ' . $customer->lastname)) { $this->errors[] = Tools::displayError('Cannot send email'); } } self::$smarty->assign('confirmation', 1); self::$cookie->id_customer = (int) $customer->id; self::$cookie->customer_lastname = $customer->lastname; self::$cookie->customer_firstname = $customer->firstname; self::$cookie->passwd = $customer->passwd; self::$cookie->logged = 1; self::$cookie->email = $customer->email; self::$cookie->is_guest = !Tools::getValue('is_new_customer', 1); /* Update cart address */ self::$cart->secure_key = $customer->secure_key; self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id); self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id); self::$cart->update(); Module::hookExec('createAccount', array('_POST' => $_POST, 'newCustomer' => $customer)); if (Tools::isSubmit('ajax')) { $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => true, 'id_customer' => (int) self::$cookie->id_customer, 'id_address_delivery' => self::$cart->id_address_delivery, 'id_address_invoice' => self::$cart->id_address_invoice, 'token' => Tools::getToken(false)); die(Tools::jsonEncode($return)); } if ($back = Tools::getValue('back')) { Tools::redirect($back); } Tools::redirect('my-account.php'); } } } } } if (sizeof($this->errors)) { if (!Tools::getValue('is_new_customer')) { unset($_POST['passwd']); } if (Tools::isSubmit('ajax')) { $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => false, 'id_customer' => 0); die(Tools::jsonEncode($return)); } } } if (Tools::isSubmit('SubmitLogin')) { Module::hookExec('beforeAuthentication'); $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email)) { $this->errors[] = Tools::displayError('E-mail address required'); } elseif (!Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid e-mail address'); } elseif (empty($passwd)) { $this->errors[] = Tools::displayError('Password is required'); } elseif (Tools::strlen($passwd) > 32) { $this->errors[] = Tools::displayError('Password is too long'); } elseif (!Validate::isPasswd($passwd)) { $this->errors[] = Tools::displayError('Invalid password'); } else { $customer = new Customer(); $authentication = $customer->getByEmail(trim($email), trim($passwd)); if (!$authentication or !$customer->id) { /* Handle brute force attacks */ sleep(1); $this->errors[] = Tools::displayError('Authentication failed'); } else { self::$cookie->id_compare = isset(self::$cookie->id_compare) ? self::$cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id); self::$cookie->id_customer = (int) $customer->id; self::$cookie->customer_lastname = $customer->lastname; self::$cookie->customer_firstname = $customer->firstname; self::$cookie->id_default_group = $customer->id_default_group; self::$cookie->logged = 1; self::$cookie->is_guest = $customer->isGuest(); self::$cookie->passwd = $customer->passwd; self::$cookie->email = $customer->email; if (Configuration::get('PS_CART_FOLLOWING') and (empty(self::$cookie->id_cart) or Cart::getNbProducts(self::$cookie->id_cart) == 0)) { self::$cookie->id_cart = (int) Cart::lastNoneOrderedCart((int) $customer->id); } /* Update cart address */ self::$cart->id_carrier = 0; self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id); self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id); // If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated self::$cart->secure_key = $customer->secure_key; self::$cart->update(); Module::hookExec('authentication'); if (!Tools::isSubmit('ajax')) { if ($back = Tools::getValue('back')) { Tools::redirect($back); } Tools::redirect('my-account.php'); } } } if (Tools::isSubmit('ajax')) { $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'token' => Tools::getToken(false)); die(Tools::jsonEncode($return)); } } if (isset($create_account)) { /* Select the most appropriate country */ if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) { $selectedCountry = (int) $_POST['id_country']; } /* FIXME : language iso and country iso are not similar, * maybe an associative table with country an language can resolve it, * But for now it's a bug ! * @see : bug #6968 * @link:http://www.prestashop.com/bug_tracker/view/6968/ elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); if (Validate::isLanguageIsoCode($array[0])) { $selectedCountry = Country::getByIso($array[0]); if (!$selectedCountry) $selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT')); } }*/ if (!isset($selectedCountry)) { $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); } if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries((int) self::$cookie->id_lang, true, true); } else { $countries = Country::getCountries((int) self::$cookie->id_lang, true); } self::$smarty->assign(array('countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'vat_management' => Configuration::get('VATNUMBER_MANAGEMENT'))); /* Call a hook to display more information on form */ self::$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop'))); } /* Generate years, months and days */ if (isset($_POST['years']) and is_numeric($_POST['years'])) { $selectedYears = (int) $_POST['years']; } $years = Tools::dateYears(); if (isset($_POST['months']) and is_numeric($_POST['months'])) { $selectedMonths = (int) $_POST['months']; } $months = Tools::dateMonths(); if (isset($_POST['days']) and is_numeric($_POST['days'])) { $selectedDays = (int) $_POST['days']; } $days = Tools::dateDays(); self::$smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0)); self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active); }
/** * copyImg copy an image located in $url and save it in a path * according to $entity->$id_entity . * $id_image is used if we need to add a watermark * * @param int $id_entity id of product or category (set in entity) * @param int $id_image (default null) id of the image if watermark enabled. * @param string $url path or url to use * @param string entity 'products' or 'categories' * @return void */ private static function copyImg($id_entity, $id_image = NULL, $url, $entity = 'products') { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES')); switch ($entity) { default: case 'products': $imageObj = new Image($id_image); $path = $imageObj->getPathForCreation(); break; case 'categories': $path = _PS_CAT_IMG_DIR_ . (int) $id_entity; break; } $url_source_file = str_replace(' ', '%20', trim($url)); if (@copy($url_source_file, $tmpfile)) { imageResize($tmpfile, $path . '.jpg'); $imagesTypes = ImageType::getImagesTypes($entity); foreach ($imagesTypes as $k => $imageType) { imageResize($tmpfile, $path . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']); } if (in_array($imageType['id_image_type'], $watermark_types)) { Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_entity)); } } else { unlink($tmpfile); return false; } unlink($tmpfile); return true; }
public function update($nullValues = false) { if (isset(self::$_nbProducts[$this->id])) { unset(self::$_nbProducts[$this->id]); } if (isset(self::$_totalWeight[$this->id])) { unset(self::$_totalWeight[$this->id]); } $this->_products = NULL; $return = parent::update(); Module::hookExec('cart'); return $return; }
<?php // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies) header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); require_once dirname(__FILE__) . '/init.php'; /* CSS */ $css_files[_THEME_CSS_DIR_ . 'global.css'] = 'all'; /* Hooks are volontary out the initialize array (need those variables already assigned) */ $smarty->assign(array('HOOK_HEADER' => Module::hookExec('header'), 'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'), 'HOOK_TOP' => Module::hookExec('top'), 'static_token' => Tools::getToken(false), 'token' => Tools::getToken(), 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => intval(Tools::getValue('content_only')))); if (isset($css_files) and !empty($css_files)) { $smarty->assign('css_files', $css_files); } if (isset($js_files) and !empty($js_files)) { $smarty->assign('js_files', $js_files); } /* Display a maintenance page if shop is closed */ if (isset($maintenance) and (!isset($_SERVER['REMOTE_ADDR']) or $_SERVER['REMOTE_ADDR'] != Configuration::get('PS_MAINTENANCE_IP'))) { header('HTTP/1.1 503 temporarily overloaded'); $smarty->display(_PS_THEME_DIR_ . 'maintenance.tpl'); exit; } $smarty->caching = 0; $smarty->display(_PS_THEME_DIR_ . 'header.tpl');
public function displayForm($isMainTab = true) { global $currentIndex; parent::displayForm(); if (!($obj = $this->loadObject(true))) { return; } echo ' <form action="' . $currentIndex . '&token=' . $this->token . '" method="post"> ' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . ' <fieldset><legend><img src="../img/admin/asterisk.gif" />' . $this->l('Attributes group') . '</legend> <label>' . $this->l('Name:') . ' </label> <div class="margin-form">'; foreach ($this->_languages as $language) { echo ' <div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="33" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlspecialchars($this->getFieldValue($obj, 'name', (int) $language['id_lang'])) . '" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div> <script type="text/javascript"> var flag_fields = \'name¤public_name\'; </script>'; } $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'name', false, true); echo ' <div class="clear"></div> </div> <label>' . $this->l('Public name:') . ' </label> <div class="margin-form">'; foreach ($this->_languages as $language) { echo ' <div id="public_name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="33" type="text" name="public_name_' . $language['id_lang'] . '" value="' . htmlspecialchars($this->getFieldValue($obj, 'public_name', (int) $language['id_lang'])) . '" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> <p style="clear: both">' . $this->l('Term or phrase displayed to the customer') . '</p> </div>'; } $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'public_name', false, true); echo ' <div class="clear"></div> </div> <label>' . $this->l('Color group:') . ' </label> <div class="margin-form"> <input type="radio" name="is_color_group" id="is_color_group_on" value="1" ' . ($this->getFieldValue($obj, 'is_color_group') ? 'checked="checked" ' : '') . '/> <label class="t" for="is_color_group_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Yes') . '" /></label> <input type="radio" name="is_color_group" id="is_color_group_off" value="0" ' . (!$this->getFieldValue($obj, 'is_color_group') ? 'checked="checked" ' : '') . '/> <label class="t" for="is_color_group_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('No') . '" /></label> <p>' . $this->l('This is a color group') . '</p> </div> ' . Module::hookExec('attributeGroupForm', array('id_attribute_group' => $obj->id)) . ' <div class="margin-form"> <input type="submit" value="' . $this->l(' Save ') . '" name="submitAdd' . $this->table . '" class="button" /> </div> <div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div> </fieldset> </form>'; }
public function process() { global $cart, $currency; parent::process(); if (!($id_product = (int) Tools::getValue('id_product')) or !Validate::isUnsignedId($id_product)) { $this->errors[] = Tools::displayError('Product not found'); } else { if (!Validate::isLoadedObject($this->product) or !$this->product->active and Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct' . $this->product->id) || !file_exists(dirname(__FILE__) . '/../' . Tools::getValue('ad') . '/ajax.php')) { header('HTTP/1.1 404 page not found'); $this->errors[] = Tools::displayError('Product is no longer available.'); } elseif (!$this->product->checkAccess((int) self::$cookie->id_customer)) { $this->errors[] = Tools::displayError('You do not have access to this product.'); } else { self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id)); if (!$this->product->active) { self::$smarty->assign('adminActionDisplay', true); } /* rewrited url set */ $rewrited_url = self::$link->getProductLink($this->product->id, $this->product->link_rewrite); /* Product pictures management */ require_once 'images.inc.php'; self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']))); if (Tools::isSubmit('submitCustomizedDatas')) { $this->pictureUpload($this->product, $cart); $this->textRecord($this->product, $cart); $this->formTargetFormat(); } elseif (isset($_GET['deletePicture']) and !$cart->deletePictureToProduct((int) $this->product->id, (int) Tools::getValue('deletePicture'))) { $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture'); } $files = self::$cookie->getFamily('pictures_' . (int) $this->product->id); $textFields = self::$cookie->getFamily('textFields_' . (int) $this->product->id); foreach ($textFields as $key => $textField) { $textFields[$key] = str_replace('<br />', "\n", $textField); } self::$smarty->assign(array('pictures' => $files, 'textFields' => $textFields)); if ((int) Tools::getValue('pp') == 1) { echo 'here1'; } $productPriceWithTax = Product::getPriceStatic($id_product, true, NULL, 6); if (Product::$_taxCalculationMethod == PS_TAX_INC) { $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2); } if ((int) Tools::getValue('pp') == 1) { $time2 = time(); echo 'time2: ' . $time2; } $productPriceWithoutEcoTax = (double) ($productPriceWithTax - $this->product->ecotax); $configs = Configuration::getMultiple(array('PS_ORDER_OUT_OF_STOCK', 'PS_LAST_QTIES')); /* Features / Values */ $features = $this->product->getFrontFeatures((int) self::$cookie->id_lang); $attachments = $this->product->getAttachments((int) self::$cookie->id_lang); /* Category */ $category = false; if (isset($_SERVER['HTTP_REFERER']) and preg_match('!^(.*)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) and !strstr($_SERVER['HTTP_REFERER'], '.html')) { if (isset($regs[2]) and is_numeric($regs[2])) { if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[2])))) { $category = new Category((int) $regs[2], (int) self::$cookie->id_lang); } } elseif (isset($regs[5]) and is_numeric($regs[5])) { if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[5])))) { $category = new Category((int) $regs[5], (int) self::$cookie->id_lang); } } } if (!$category) { $category = new Category($this->product->id_category_default, (int) self::$cookie->id_lang); } if (isset($category) and Validate::isLoadedObject($category)) { self::$smarty->assign(array('path' => Tools::getPath((int) $category->id, $this->product->name, true), 'category' => $category, 'subCategories' => $category->getSubCategories((int) self::$cookie->id_lang, true), 'id_category_current' => (int) $category->id, 'id_category_parent' => (int) $category->id_parent, 'return_category_name' => Tools::safeOutput($category->name))); } else { self::$smarty->assign('path', Tools::getPath((int) $this->product->id_category_default, $this->product->name)); } self::$smarty->assign('return_link', (isset($category->id) and $category->id) ? Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript: history.back();'); $lang = Configuration::get('PS_LANG_DEFAULT'); if (Pack::isPack((int) $this->product->id, (int) $lang) and !Pack::isInStock((int) $this->product->id, (int) $lang)) { $this->product->quantity = 0; } $group_reduction = (100 - Group::getReduction((int) self::$cookie->id_customer)) / 100; $id_customer = (isset(self::$cookie->id_customer) and self::$cookie->id_customer) ? (int) self::$cookie->id_customer : 0; $id_group = $id_customer ? (int) Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_; $id_country = (int) ($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT')); if ((int) Tools::getValue('pp') == 1) { $time3 = time(); echo 'time3: ' . $time3; } // Tax $tax = (double) Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); self::$smarty->assign('tax_rate', $tax); $ecotax_rate = (double) Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2); if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) { $ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2); } $manufacturer = new Manufacturer((int) $this->product->id_manufacturer, 1); $sizechart = new Sizechart((int) $this->product->id_sizechart, 1); //see if the product is already in the wishlist if ($id_customer) { $sql = "select id from ps_wishlist where id_customer = " . $id_customer . " and id_product = " . $this->product->id; $res = Db::getInstance()->ExecuteS($sql); if ($res) { self::$smarty->assign("in_wishlist", true); } else { self::$smarty->assign("in_wishlist", false); } } else { self::$smarty->assign("in_wishlist", false); } self::$smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int) $this->product->id, (int) Shop::getCurrentShop(), (int) self::$cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (double) $tax), 'product' => $this->product, 'ecotax_tax_inc' => $ecotaxTaxAmount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'homeSize' => Image::getSize('home'), 'product_manufacturer' => $manufacturer, 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => (double) $productPriceWithoutEcoTax, 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) $configs['PS_LAST_QTIES'], 'group_reduction' => $group_reduction, 'col_img_dir' => _PS_COL_IMG_DIR_, 'sizechart' => $sizechart->sizechart, 'sizechart_data' => $sizechart->sizechart_data)); self::$smarty->assign(array('HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent'))); if ((int) Tools::getValue('pp') == 1) { $time4 = time(); echo 'time4: ' . $time4; } $images = $this->product->getImages((int) self::$cookie->id_lang); $productImages = array(); foreach ($images as $k => $image) { if ($image['cover']) { self::$smarty->assign('mainImage', $images[0]); $cover = $image; $cover['id_image'] = Configuration::get('PS_LEGACY_IMAGES') ? $this->product->id . '-' . $image['id_image'] : $image['id_image']; $cover['id_image_only'] = (int) $image['id_image']; } $productImages[(int) $image['id_image']] = $image; } if (!isset($cover)) { $cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang) . '-default', 'legend' => 'No picture', 'title' => 'No picture'); } $size = Image::getSize('large'); self::$smarty->assign(array('cover' => $cover, 'imgWidth' => (int) $size['width'], 'mediumSize' => Image::getSize('medium'), 'largeSize' => Image::getSize('large'), 'accessories' => $this->product->getAccessories((int) self::$cookie->id_lang))); if (sizeof($productImages)) { self::$smarty->assign('images', $productImages); } if ((int) Tools::getValue('pp') == 1) { $time5 = time(); echo 'time5: ' . $time5; } /* Attributes / Groups & colors */ $colors = array(); //see if the product has shades if ($this->product->id_group && $this->product->id_group > 0) { global $link; $related_productIds = $this->product->getRelatedProducts(); $related_products = array(); foreach ($related_productIds as &$productId) { $relProduct = new Product((int) $productId['id_product'], true, self::$cookie->id_lang); $idImage = $relProduct->getCoverWs(); if ($idImage) { $idImage = $relProduct->id . '-' . $idImage; } else { $idImage = Language::getIsoById(1) . '-default'; } $relProduct->image_link = $link->getImageLink($relProduct->link_rewrite, $idImage, 'small'); $relProduct->link = $relProduct->getLink(); $related_products[] = $relProduct; } self::$smarty->assign('relatedProducts', $related_products); } if ((int) Tools::getValue('pp') == 1) { $time6 = time(); echo 'time6: ' . $time6; } $attributesGroups = $this->product->getAttributesGroups((int) self::$cookie->id_lang); // @todo (RM) should only get groups and not all declination ? if (is_array($attributesGroups) and $attributesGroups) { $groups = array(); $combinationImages = $this->product->getCombinationImages((int) self::$cookie->id_lang); foreach ($attributesGroups as $k => $row) { /* Color management */ if ((isset($row['attribute_color']) and $row['attribute_color'] or file_exists(_PS_COL_IMG_DIR_ . $row['id_attribute'] . '.jpg')) and $row['id_attribute_group'] == $this->product->id_color_default) { $colors[$row['id_attribute']]['value'] = $row['attribute_color']; $colors[$row['id_attribute']]['name'] = $row['attribute_name']; if (!isset($colors[$row['id_attribute']]['attributes_quantity'])) { $colors[$row['id_attribute']]['attributes_quantity'] = 0; } $colors[$row['id_attribute']]['attributes_quantity'] += (int) $row['quantity']; } if (!isset($groups[$row['id_attribute_group']])) { $groups[$row['id_attribute_group']] = array('name' => $row['public_group_name'], 'is_color_group' => $row['is_color_group'], 'default' => -1); } $groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name']; if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1) { $groups[$row['id_attribute_group']]['default'] = (int) $row['id_attribute']; } if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) { $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0; } $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int) $row['quantity']; $combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name']; $combinations[$row['id_product_attribute']]['attributes'][] = (int) $row['id_attribute']; $combinations[$row['id_product_attribute']]['price'] = (double) $row['price']; $combinations[$row['id_product_attribute']]['ecotax'] = (double) $row['ecotax']; $combinations[$row['id_product_attribute']]['weight'] = (double) $row['weight']; $combinations[$row['id_product_attribute']]['quantity'] = (int) $row['quantity']; $combinations[$row['id_product_attribute']]['reference'] = $row['reference']; $combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact']; $combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity']; $combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1; } if ((int) Tools::getValue('pp') == 1) { $time7 = time(); echo 'time7: ' . $time7; } //wash attributes list (if some attributes are unavailables and if allowed to wash it) if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) { foreach ($groups as &$group) { foreach ($group['attributes_quantity'] as $key => &$quantity) { if (!$quantity) { unset($group['attributes'][$key]); } } } foreach ($colors as $key => $color) { if (!$color['attributes_quantity']) { unset($colors[$key]); } } } if ((int) Tools::getValue('pp') == 1) { $time71 = time(); echo 'time71: ' . $time71; } foreach ($groups as &$group) { natcasesort($group['attributes']); } foreach ($combinations as $id_product_attribute => $comb) { $attributeList = ''; foreach ($comb['attributes'] as $id_attribute) { $attributeList .= '\'' . (int) $id_attribute . '\','; } $attributeList = rtrim($attributeList, ','); $combinations[$id_product_attribute]['list'] = $attributeList; } self::$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $this->product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages)); } if ((int) Tools::getValue('pp') == 1) { $time72 = time(); echo 'time72: ' . $time72; } //$newProducts = Product::getNewProducts((int)(self::$cookie->id_lang), 0, 10, false, 'date_add', 'desc'); /*$categoryProducts = $this->getRandomCatProducts(); self::$smarty->assign('cat_products', $categoryProducts);*/ //$brandProducts = $this->getRandomBrandProducts(); //self::$smarty->assign('brand_products', $brandProducts); if ((int) Tools::getValue('pp') == 1) { $time73 = time(); echo ' time73: ' . $time73; } self::$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->getCustomizationFields((int) self::$cookie->id_lang))); if ((int) Tools::getValue('pp') == 1) { $time74 = time(); echo 'time74: ' . $time74; } // Pack management self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int) self::$cookie->id_lang, true) : array()); self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int) self::$cookie->id_lang, true, 1)); if ((int) Tools::getValue('pp') == 1) { print_r('pack done'); } } } if ((int) Tools::getValue('pp') == 1) { $time8 = time(); echo 'time8: ' . $time8; } if ($this->is_saree || $this->is_lehenga) { if ($this->is_lehenga) { self::$smarty->assign('is_lehenga', $this->is_lehenga); } self::$smarty->assign('as_shown', (bool) $this->product->as_shown); /*if($blouse_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 1)) self::$smarty->assign('measurement_info', $blouse_measurements); if($skirt_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 2)) self::$smarty->assign('skirt_measurement_info', $skirt_measurements);*/ if ((int) Tools::getValue('pp') == 1) { $time81 = time(); echo 'time81: ' . $time81; } if ($this->is_saree) { //count of all styles mapped to this product $res = Db::getInstance()->getRow("select count(s.id_style) as style_count from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1"); $style_count = (int) $res['style_count']; if ($style_count === 0) { // show the default style for sarees $style = array('id_style' => 1, 'style_image_small' => '1-small.png', 'style_name' => 'Round'); } else { $res = Db::getInstance()->getRow("select s.id_style, s.style_name, s.style_image_small from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1 and ps.is_default = 1"); if (!empty($res)) { //show the default style for this product $style = array('id_style' => $res['id_style'], 'style_image_small' => $res['style_image_small'], 'style_name' => $res['style_name']); } } if ((int) Tools::getValue('pp') == 1) { $time82 = time(); echo 'time82: ' . $time82; } self::$smarty->assign('blouse_style_count', $style_count); self::$smarty->assign('blouse_style', $style); } } else { if ($this->is_skd || $this->is_skd_rts) { self::$smarty->assign('is_anarkali', $this->is_anarkali); if ($this->is_anarkali) { if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 5)) { self::$smarty->assign('kurta_measurement_info', $kurta_measurements); } } else { if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 3)) { self::$smarty->assign('kurta_measurement_info', $kurta_measurements); } } if ($salwar_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 4)) { self::$smarty->assign('salwar_measurement_info', $salwar_measurements); } //get default styles for this product (RTS) if ($this->is_skd_rts) { $res = Db::getInstance()->ExecuteS("select count(s.id_style) as style_count, s.style_type, ps.id_product from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} group by ps.id_product,s.style_type"); foreach ($res as $s) { $style_count = (int) $s['style_count']; if ((int) $s['style_type'] === 4) { self::$smarty->assign('kurta_style_count', $style_count); } else { if ((int) $s['style_type'] === 5) { self::$smarty->assign('salwar_style_count', $style_count); } } } $res = Db::getInstance()->ExecuteS("select s.id_style, s.style_type, s.style_image_small, s.style_name from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and ps.is_default = 1"); foreach ($res as $s) { $style = array('id_style' => $s['id_style'], 'style_image_small' => $s['style_image_small'], 'style_name' => $s['style_name']); if ((int) $s['style_type'] === 4) { self::$smarty->assign('kurta_style', $style); } else { if ((int) $s['style_type'] === 5) { self::$smarty->assign('salwar_style', $style); } } } } } } self::$smarty->assign('is_bottoms', $this->is_bottoms); self::$smarty->assign('is_abaya', $this->is_abaya); self::$smarty->assign('is_wristwear', $this->is_wristwear); self::$smarty->assign('is_pakistani_rts', $this->is_pakistani_rts); if ((int) Tools::getValue('pp') == 1) { $time85 = time(); echo 'time85: ' . $time85; } self::$smarty->assign(array('ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'categories' => Category::getHomeCategories((int) self::$cookie->id_lang), 'have_image' => Product::getCover((int) Tools::getValue('id_product')), 'tax_enabled' => Configuration::get('PS_TAX'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'ecotax' => !sizeof($this->errors) and $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'))); if ((int) Tools::getValue('pp') == 1) { $time9 = time(); echo 'time9: ' . $time9; } //add this to product stats //Tools::captureActivity(PSTAT_VIEWS,$id_product); if ((int) Tools::getValue('pp') == 1) { $time1 = time(); echo 'process end: ' . $time1; } }