/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->productSort(); // Override default configuration values: cause the new products page must display latest products first. if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) { $this->orderBy = 'date_add'; $this->orderWay = 'DESC'; } $nbProducts = (int) Product::getNewProducts($this->context->language->id, null, null, true); $this->pagination($nbProducts); $products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay); $this->addColorsToProductList($products); $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'))); if ($this->ajax) { $product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl'); $pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl'); $nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products)); $nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100; echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage)); die; } else { $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl'); } }
public function add($autodate = true, $null_values = true) { $order = new Order($this->id_order); $cart = new Cart($order->id_cart); Hook::exec('actionBeforeAddOrderInvoice', array('order_invoice' => $this, 'order' => $order, 'cart' => $cart)); return parent::add($autodate, $null_values); }
public function initContent() { $this->display_column_left = false; $this->process(); if (!isset($this->context->cart)) { $this->context->cart = new Cart(); } if (!$this->useMobileTheme()) { $this->context->smarty->assign(array('HOOK_HEADER' => Hook::exec('displayHeader'), 'HOOK_LEFT_COLUMN' => $this->display_column_left ? Hook::exec('displayLeftColumn') : '', 'HOOK_RIGHT_COLUMN' => $this->display_column_right ? Hook::exec('displayRightColumn', array('cart' => $this->context->cart)) : '')); } else { $this->context->smarty->assign('HOOK_MOBILE_HEADER', Hook::exec('displayMobileHeader')); } $contextLink = $this->context->link; $postParameters = $this->getPostParameters(); try { $sid = SkrillPaymentCore::getSid($postParameters); } catch (Exception $e) { Tools::redirect($contextLink->getPageLink('order', true, null, array('step' => '3', 'skrillerror' => 'ERROR_GENERAL_REDIRECT'))); } if (!$sid) { Tools::redirect($contextLink->getPageLink('order', true, null, array('step' => '3', 'skrillerror' => 'ERROR_GENERAL_REDIRECT'))); } $redirectUrl = SkrillPaymentCore::getSkrillRedirectUrl($sid); if (Configuration::get('SKRILL_GENERAL_DISPLAY') != "IFRAME") { Tools::redirect($redirectUrl); } $this->context->smarty->assign(array('fullname' => $this->context->customer->firstname . " " . $this->context->customer->lastname, 'lang' => $this->getLang(), 'redirectUrl' => $redirectUrl, 'total' => $this->context->cart->getOrderTotal(true, Cart::BOTH), 'this_path' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/')); $this->setTemplate($this->getTemplateName()); }
public function initContent() { parent::initContent(); if ($id_category = Tools::getvalue('id_category') && Tools::getvalue('id_category') != Null) { $this->context->smarty->assign(BlogCategory::GetMetaByCategory(Tools::getvalue('id_category'))); } if ($id_post = Tools::getvalue('id_post') && Tools::getvalue('id_post') != Null) { $this->context->smarty->assign(SmartBlogPost::GetPostMetaByPost(Tools::getvalue('id_post'))); } if (Tools::getvalue('id_category') == Null && Tools::getvalue('id_post') == Null) { $meta['meta_title'] = Configuration::get('smartblogmetatitle'); $meta['meta_description'] = Configuration::get('smartblogmetadescrip'); $meta['meta_keywords'] = Configuration::get('smartblogmetakeyword'); $this->context->smarty->assign($meta); } if (Configuration::get('smartshowcolumn') == 0) { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight'))); } elseif (Configuration::get('smartshowcolumn') == 1) { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'))); } elseif (Configuration::get('smartshowcolumn') == 2) { $this->context->smarty->assign(array('HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight'))); } elseif (Configuration::get('smartshowcolumn') == 3) { $this->context->smarty->assign(array()); } else { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight'))); } }
private function getConditionsToApprove() { $allConditions = array(); $hookedConditions = Hook::exec('termsAndConditions', array(), null, true); if (!is_array($hookedConditions)) { $hookedConditions = array(); } foreach ($hookedConditions as $hookedCondition) { if ($hookedCondition instanceof TermsAndConditions) { $allConditions[] = $hookedCondition; } elseif (is_array($hookedCondition)) { foreach ($hookedCondition as $hookedConditionObject) { if ($hookedConditionObject instanceof TermsAndConditions) { $allConditions[] = $hookedConditionObject; } } } } if (Configuration::get('PS_CONDITIONS')) { array_unshift($allConditions, $this->getDefaultTermsAndConditions()); } /* * If two TermsAndConditions objects have the same identifier, * the one at the end of the list overrides the first one. * This allows a module to override the default checkbox * in a consistent manner. */ $reducedConditions = array(); foreach ($allConditions as $condition) { if ($condition instanceof TermsAndConditions) { $reducedConditions[$condition->getIdentifier()] = $condition; } } return $reducedConditions; }
public function display() { $order_invoice_list = $this->order->getInvoicesCollection(); Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list)); $pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty); $pdf->render(); }
public function hookFooter($params) { if (!$this->isCached('blockmyaccountfooter.tpl', $this->getCacheId())) { $this->smarty->assign(array('voucherAllowed' => CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN'), 'HOOK_BLOCK_MY_ACCOUNT' => Hook::exec('displayMyAccountBlockfooter'))); } return $this->display(__FILE__, 'blockmyaccountfooter.tpl', $this->getCacheId()); }
public function setDeliveryNumber($order_invoice_id, $id_shop) { if (!$order_invoice_id) return false; $number = Configuration::get('PS_DELIVERY_NUMBER', null, null, $id_shop); // If invoice start number has been set, you clean the value of this configuration if ($number) Configuration::updateValue('PS_DELIVERY_NUMBER', false, false, null, $id_shop); $order_invoice = new OrderInvoice($order_invoice_id); $order = new Order($order_invoice->id_order); $cart = new Cart($order->id_cart); if($ref = Hook::exec('actionBeforeAddDeliveryNumber', array('order'=>$order,'cart'=>$cart,'number'=>$number))) $number = $ref; $sql = 'UPDATE `'._DB_PREFIX_.'order_invoice` SET delivery_number ='; if ($number) $sql .= (int)$number; else $sql .= '(SELECT new_number FROM (SELECT (MAX(`delivery_number`) + 1) AS new_number FROM `'._DB_PREFIX_.'order_invoice`) AS result)'; $sql .=' WHERE `id_order_invoice` = '.(int)$order_invoice_id; return Db::getInstance()->execute($sql); }
public function getPaymentOptions() { // Payment options coming from intermediate, deprecated version of the Advanced API $rawDisplayPaymentEUOptions = Hook::exec('displayPaymentEU', array(), null, true); if (!is_array($rawDisplayPaymentEUOptions)) { $rawDisplayPaymentEUOptions = array(); } $displayPaymentEUOptions = array_map(array('PrestaShop\\PrestaShop\\Core\\Payment\\PaymentOption', 'convertLegacyOption'), $rawDisplayPaymentEUOptions); // Payment options coming from regular Advanced API $advancedPaymentOptions = Hook::exec('advancedPaymentOptions', array(), null, true); if (!is_array($advancedPaymentOptions)) { $advancedPaymentOptions = array(); } // Payment options coming from regular Advanced API $newOption = Hook::exec('paymentOptions', array(), null, true); if (!is_array($newOption)) { $newOption = array(); } $paymentOptions = array_merge($displayPaymentEUOptions, $advancedPaymentOptions, $newOption); foreach ($paymentOptions as $paymentOptionKey => $paymentOption) { if (!is_array($paymentOption)) { unset($paymentOptions[$paymentOptionKey]); } } return $paymentOptions; }
public function initContent() { $meta = array(); parent::initContent(); $colums = Context::getContext()->theme->hasColumns(Context::getContext()->controller->page_name); if ($colums) { $hide_column_left = isset($colums['left_column']) && !empty($colums['left_column']) ? 0 : 1; $hide_column_right = isset($colums['right_column']) && !empty($colums['right_column']) ? 0 : 1; } /* if ( Tools::getvalue('id_category') && Tools::getvalue('id_category') != Null) { $this->context->smarty->assign(BlogCategory::GetMetaByCategory(Tools::getvalue('id_category'))); } if (Tools::getvalue('id_post') && Tools::getvalue('id_post') != Null) { $this->context->smarty->assign(SmartBlogPost::GetPostMetaByPost(Tools::getvalue('id_post'))); } if (Tools::getvalue('id_category') == Null && Tools::getvalue('id_post') == Null) { $meta['meta_title'] = Configuration::get('smartblogmetatitle'); $meta['meta_description'] = Configuration::get('smartblogmetadescrip'); $meta['meta_keywords'] = Configuration::get('smartblogmetakeyword'); $this->context->smarty->assign($meta); } */ $this->context->smarty->assign($meta); if (Configuration::get('smartshowcolumn') == 0) { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'hide_right_column' => '', 'hide_left_column' => '', 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight'))); } elseif (Configuration::get('smartshowcolumn') == 1) { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'hide_right_column' => '1', 'hide_left_column' => '', 'HOOK_RIGHT_COLUMN' => '')); } elseif (Configuration::get('smartshowcolumn') == 2) { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => '', 'hide_right_column' => '', 'hide_left_column' => '1', 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight'))); } elseif (Configuration::get('smartshowcolumn') == 3) { $this->context->smarty->assign(array('hide_right_column' => $hide_column_right, 'hide_left_column' => $hide_column_left)); } else { $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'hide_right_column' => '', 'hide_left_column' => '', 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight'))); } }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->addJS(_THEME_JS_DIR_ . 'index.js'); $this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'), 'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'), 'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent'))); $this->setTemplate(_PS_THEME_DIR_ . 'index.tpl'); }
/** * Load default routes group by languages */ protected function loadRoutes($id_shop = null) { $context = Context::getContext(); // Load custom routes from modules $modules_routes = Hook::exec('moduleRoutes', array('id_shop' => $id_shop), null, true, false); if (is_array($modules_routes) && count($modules_routes)) { foreach ($modules_routes as $module_route) { if (is_array($module_route) && count($module_route)) { foreach ($module_route as $route => $route_details) { if (array_key_exists('controller', $route_details) && array_key_exists('rule', $route_details) && array_key_exists('keywords', $route_details) && array_key_exists('params', $route_details)) { if (!isset($this->default_routes[$route])) { $this->default_routes[$route] = array(); $this->default_routes[$route] = array_merge($this->default_routes[$route], $route_details); } } } } } } // Set default routes //new edit by Ha!*!*y :: Select only active languages foreach (Language::getLanguages(TRUE) as $lang) { foreach ($this->default_routes as $id => $route) { $this->addRoute($id, $route['rule'], $route['controller'], $lang['id_lang'], $route['keywords'], isset($route['params']) ? $route['params'] : array(), $id_shop); } } if ($this->use_routes) { // Get iso lang $iso_lang = Tools::getValue('isolang'); $id_lang = $context->language->id; if (!empty($iso_lang)) { $id_lang = Language::getIdByIso($iso_lang); } // Load routes from meta table $sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang FROM `' . _DB_PREFIX_ . 'meta` m LEFT JOIN `' . _DB_PREFIX_ . 'meta_lang` ml ON (m.id_meta = ml.id_meta' . Shop::addSqlRestrictionOnLang('ml', $id_shop) . ') ORDER BY LENGTH(ml.url_rewrite) DESC'; if ($results = Db::getInstance()->executeS($sql)) { foreach ($results as $row) { if ($row['url_rewrite']) { $this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang'], array(), array(), $id_shop); } } } // Set default empty route if no empty route (that's weird I know) if (!$this->empty_route) { $this->empty_route = array('routeID' => 'index', 'rule' => '', 'controller' => 'index'); } // Load custom routes foreach ($this->default_routes as $route_id => $route_data) { if ($custom_route = Configuration::get('PS_ROUTE_' . $route_id, null, null, $id_shop)) { foreach (Language::getLanguages() as $lang) { $this->addRoute($route_id, $custom_route, $route_data['controller'], $lang['id_lang'], $route_data['keywords'], isset($route_data['params']) ? $route_data['params'] : array(), $id_shop); } } } } }
/** * Execute the hook displayOrderConfirmation */ public function displayOrderConfirmation() { $params = $this->displayHook(); if ($params && is_array($params)) { return Hook::exec('displayOrderConfirmation', $params); } return false; }
public function add($autodate = true, $nullValues = false) { if (parent::add($autodate, $nullValues)) { Hook::exec('actionPaymentCCAdd', array('paymentCC' => $this)); return true; } return false; }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $has_address = $this->context->customer->getAddresses($this->context->language->id); $this->context->smarty->assign(array('has_customer_an_address' => empty($has_address), 'voucherAllowed' => (int) CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN'))); $this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Hook::exec('displayCustomerAccount')); $this->setTemplate(_PS_THEME_DIR_ . 'my-account.tpl'); }
public function hookDisplayLeftColumn($params) { if (!$this->context->customer->isLogged()) { return false; } $this->smarty->assign(array('voucherAllowed' => CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN'), 'HOOK_BLOCK_MY_ACCOUNT' => Hook::exec('displayMyAccountBlock'))); return $this->display(__FILE__, $this->name . '.tpl'); }
public function display() { ${"GLOBALS"}["nnzuxvjxuh"] = "pdf"; ${${"GLOBALS"}["vnnfjesv"]} = $this->order->getInvoicesCollection(); Hook::exec("actionPDFInvoiceRender", array("order_invoice_list" => ${${"GLOBALS"}["vnnfjesv"]})); ${${"GLOBALS"}["nnzuxvjxuh"]} = new PDF(${${"GLOBALS"}["vnnfjesv"]}, PDF::TEMPLATE_INVOICE, $this->context->smarty, $this->context->language->id); $pdf->render(); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { $original_query = Tools::getValue('q'); $query = Tools::replaceAccentedChars(urldecode($original_query)); if ($this->ajax_search) { $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'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']); } Hook::exec('actionSearch', array('expr' => $query, 'total' => count($searchResults))); } $this->ajaxDie(Tools::jsonEncode($searchResults)); } //Only controller content initialization when the user use the normal search parent::initContent(); $product_per_page = isset($this->context->cookie->nb_item_per_page) ? (int) $this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE'); if ($this->instant_search && !is_array($query)) { $this->productSort(); $this->n = abs((int) Tools::getValue('n', $product_per_page)); $this->p = abs((int) Tools::getValue('p', 1)); $search = Search::find($this->context->language->id, $query, 1, 10, 'position', 'desc'); Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total'])); $nbProducts = $search['total']; $this->pagination($nbProducts); $this->addColorsToProductList($search['result']); $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'instant_search' => $this->instant_search, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')))); } elseif (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) { $this->productSort(); $this->n = abs((int) Tools::getValue('n', $product_per_page)); $this->p = abs((int) Tools::getValue('p', 1)); $original_query = $query; $query = Tools::replaceAccentedChars(urldecode($query)); $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay); if (is_array($search['result'])) { foreach ($search['result'] as &$product) { $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total']; } } Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total'])); $nbProducts = $search['total']; $this->pagination($nbProducts); $this->addColorsToProductList($search['result']); $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')))); } elseif (($tag = urldecode(Tools::getValue('tag'))) && !is_array($tag)) { $nbProducts = (int) Search::searchTag($this->context->language->id, $tag, true); $this->pagination($nbProducts); $result = Search::searchTag($this->context->language->id, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay); Hook::exec('actionSearch', array('expr' => $tag, 'total' => count($result))); $this->addColorsToProductList($result); $this->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')))); } else { $this->context->smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0)); } $this->context->smarty->assign(array('add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'))); $this->setTemplate(_PS_THEME_DIR_ . 'search.tpl'); }
protected function _assignSummaryInformations() { $summary = $this->context->cart->getSummaryDetails(); $customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id); // override customization tax rate with real tax (tax rules) if ($customizedDatas) { foreach ($summary['products'] as &$productUpdate) { $productId = (int) isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id']; $productAttributeId = (int) isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id']; if (isset($customizedDatas[$productId][$productAttributeId])) { $productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); } } Product::addCustomizationPrice($summary['products'], $customizedDatas); } $cart_product_context = Context::getContext()->cloneContext(); foreach ($summary['products'] as $key => &$product) { $product['quantity'] = $product['cart_quantity']; // for compatibility with 1.2 themes if ($cart_product_context->shop->id != $product['id_shop']) { $cart_product_context->shop = new Shop((int) $product['id_shop']); } $product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute'], _PS_PRICE_COMPUTE_PRECISION_, null, false, false, 1, false, null, null, null, $null, true, true, $cart_product_context); /** * ABU edit: variable is_discount set à 1 à tord, calcul foireux de presta * @bugfix: https://github.com/PrestaShop/PrestaShop/commit/379e28b341730ea95c0b2d6567817305ea841b23 * @perso: soustraction de l'ecotax au price_without_specific_price @else */ if (Product::getTaxCalculationMethod()) { // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_); $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price'], _PS_PRICE_COMPUTE_PRECISION_); } else { // $product['is_discounted'] = $product['price_without_specific_price'] != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_); $product['is_discounted'] = Tools::ps_round($product['price_without_specific_price'] - $product['ecotax'], _PS_PRICE_COMPUTE_PRECISION_) != Tools::ps_round($product['price_wt'], _PS_PRICE_COMPUTE_PRECISION_); } } // Get available cart rules and unset the cart rules already in the cart $available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, isset($this->context->customer->id) ? $this->context->customer->id : 0, true, true, true, $this->context->cart); $cart_cart_rules = $this->context->cart->getCartRules(); foreach ($available_cart_rules as $key => $available_cart_rule) { if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], CartRule::BO_ORDER_CODE_PREFIX) === 0) { unset($available_cart_rules[$key]); continue; } foreach ($cart_cart_rules as $cart_cart_rule) { if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule']) { unset($available_cart_rules[$key]); continue 2; } } } $show_option_allow_separate_package = !$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE'); $this->context->smarty->assign($summary); $this->context->smarty->assign(array('token_cart' => Tools::getToken(false), 'isLogged' => $this->isLogged, 'isVirtualCart' => $this->context->cart->isVirtualCart(), 'productNumber' => $this->context->cart->nbProducts(), 'voucherAllowed' => CartRule::isFeatureActive(), 'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING), 'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING), 'customizedDatas' => $customizedDatas, 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'lastProductAdded' => $this->context->cart->getLastProduct(), 'displayVouchers' => $available_cart_rules, 'show_option_allow_separate_package' => $show_option_allow_separate_package, 'smallSize' => Image::getSize(ImageType::getFormatedName('small')))); $this->context->smarty->assign(array('HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary), 'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary))); }
public function add($autodate = true, $null_values = false) { if (!parent::add($autodate)) { return false; } $order = new Order((int) $this->id_order); // Update id_order_state attribute in Order $order->current_state = $this->id_order_state; $order->update(); // start of implementation of the module code - taxamo $operation = null; $list_orderstateoperation = Taxamoeuvat::getListValues(); foreach ($list_orderstateoperation as $orderstateoperation) { if ($orderstateoperation['id_order_state'] == $order->current_state) { $operation = $orderstateoperation['operation']; } } if (!is_null($operation)) { if ($operation == 1 || $operation == 2) { $last_id_order_transaction = Taxamoeuvat::getLastIdByOrder($order->id); if (is_null($last_id_order_transaction)) { $res_process_store_transaction = Tools::taxamoStoreTransaction($order->id_currency, $order->id_address_invoice, $order->id_customer, $order->getCartProducts()); if (is_null($res_process_store_transaction['key_transaction'])) { $res_process_store_transaction['comment'] .= '* Transaccion NO Adicionada'; } else { $res_process_store_transaction['comment'] .= '* Transaccion ADICIONADA'; } Taxamoeuvat::addTransaction($order->id, $order->current_state, $res_process_store_transaction['key_transaction'], $res_process_store_transaction['comment']); } else { $reg_taxamo_transaction = null; $reg_taxamo_transaction = Taxamoeuvat::idExistsTransaction((int) $last_id_order_transaction); $res_process_store_transaction['key_transaction'] = $reg_taxamo_transaction[0]['key_transaction']; $res_process_store_transaction['comment'] = ''; } if ($operation == 2) { if (is_null($res_process_store_transaction['key_transaction'])) { $res_process_store_transaction['comment'] .= '* Transaccion NO Confirmada'; } else { $res_process_confirm_transaction = Tools::taxamoConfirmTransaction($res_process_store_transaction['key_transaction']); if (!is_null($res_process_confirm_transaction['status']) && $res_process_confirm_transaction['status'] == 'C') { $res_process_store_transaction['comment'] .= '* Transaccion CONFIRMADA'; } else { if (!empty($res_process_confirm_transaction['error'])) { $res_process_store_transaction['comment'] .= $res_process_confirm_transaction['error']; $res_process_store_transaction['comment'] .= '* Transaccion NO Confirmada'; } } } Taxamoeuvat::addTransaction($order->id, $order->current_state, $res_process_store_transaction['key_transaction'], $res_process_store_transaction['comment']); } } } // end of code implementation module - taxamo Hook::exec('actionOrderHistoryAddAfter', array('order_history' => $this), null, false, true, false, $order->id_shop); return true; }
/** * Start forms process * @see FrontController::postProcess() */ public function postProcess() { if (Tools::isSubmit('email')) { if (!($email = Tools::getValue('email')) || !Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid e-mail address'); } else { $customer = new Customer(); $customer->getByemail($email); if (!Validate::isLoadedObject($customer)) { $this->errors[] = Tools::displayError('There is no account registered to this e-mail address.'); } elseif (!$customer->active) { $this->errors[] = Tools::displayError('You cannot regenerate the password for this account.'); } elseif (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) { $this->errors[] = sprintf(Tools::displayError('You can regenerate your password only every %d minute(s)'), (int) $min_time); } else { $mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => $this->context->link->getPageLink('password', true, null, 'token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id)); if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) { $this->context->smarty->assign(array('confirmation' => 2, 'email' => $customer->email)); } else { $this->errors[] = Tools::displayError('Error occurred while sending the e-mail.'); } } } } elseif (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) { $email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . (int) $id_customer); if ($email) { $customer = new Customer(); $customer->getByemail($email); if (!Validate::isLoadedObject($customer)) { $this->errors[] = Tools::displayError('Customer account not found'); } elseif (!$customer->active) { $this->errors[] = Tools::displayError('You cannot regenerate the password for this account.'); } elseif (strtotime($customer->last_passwd_gen . '+' . (int) Configuration::get('PS_PASSWD_TIME_FRONT') . ' minutes') - time() > 0) { Tools::redirect('index.php?controller=authentication&error_regen_pwd'); } else { $customer->passwd = Tools::encrypt($password = Tools::passwdGen(MIN_PASSWD_LENGTH)); $customer->last_passwd_gen = date('Y-m-d H:i:s', time()); if ($customer->update()) { Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password)); $mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{passwd}' => $password); if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) { $this->context->smarty->assign(array('confirmation' => 1, 'email' => $customer->email)); } else { $this->errors[] = Tools::displayError('Error occurred while sending the e-mail.'); } } else { $this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.'); } } } else { $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted'); } } elseif (Tools::getValue('token') || Tools::getValue('id_customer')) { $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted'); } }
public function initContent() { // $this->productSort(); // $nbProducts = (int)(Product::getTransitProducts((int)(self::$cookie->id_lang), isset($this->p) ? (int)($this->p) - 1 : NULL, isset($this->n) ? (int)($this->n) : NULL, true)); //$this->pagination($nbProducts); $products = Product::getTransitProducts((int) $this->context->cookie->id_lang, isset($this->p) ? (int) $this->p - 1 : NULL, isset($this->n) ? (int) $this->n : NULL, false, $this->orderBy, $this->orderWay); $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'path' => "Товар в пути")); parent::initContent(); $this->setTemplate(_PS_THEME_DIR_ . 'transit.tpl'); }
public function add($autodate = true, $null_values = false) { if ($this->position <= 0) { $this->position = Attribute::getHigherPosition($this->id_attribute_group) + 1; } $return = parent::add($autodate, $null_values); if ($return) { Hook::exec('actionAttributeSave', array('id_attribute' => $this->id)); } return $return; }
/** * Logs a given customer in. */ public static function login_customer($id_customer) { // 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::processSubmitLogin Hook::exec('actionBeforeAuthentication'); $context = Context::getContext(); $context->cookie->id_compare = isset($context->cookie->id_compare) ? $context->cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id); $context->cookie->id_customer = (int) $customer->id; $context->cookie->customer_lastname = $customer->lastname; $context->cookie->customer_firstname = $customer->firstname; $context->cookie->logged = 1; $customer->logged = 1; $context->cookie->is_guest = $customer->isGuest(); $context->cookie->passwd = $customer->passwd; $context->cookie->email = $customer->email; // Add customer to the context $context->customer = $customer; if (Configuration::get('PS_CART_FOLLOWING') && (empty($context->cookie->id_cart) || Cart::getNbProducts($context->cookie->id_cart) == 0) && ($id_cart = (int) Cart::lastNoneOrderedCart($context->customer->id))) { $context->cart = new Cart($id_cart); } else { $context->cart->id_carrier = 0; $context->cart->setDeliveryOption(null); $context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id); $context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id); } $context->cart->id_customer = (int) $customer->id; $context->cart->secure_key = $customer->secure_key; $context->cart->save(); $context->cookie->id_cart = (int) $context->cart->id; $context->cookie->update(); $context->cart->autosetProductAddress(); Hook::exec('actionAuthentication'); // Login information have changed, so we check if the cart rules still apply CartRule::autoRemoveFromCart($context); CartRule::autoAddToCart($context); // Customer is now logged in. return true; } // Invalid customer specified. return false; }
public function initContent() { if (Tools::isSubmit('module') && Tools::getValue('controller') == 'payment') { $currency = Currency::getCurrency((int) $this->context->cart->id_currency); $orderTotal = $this->context->cart->getOrderTotal(); $minimal_purchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency); Hook::exec('overrideMinimalPurchasePrice', array('minimalPurchase' => &$minimalPurchase)); if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase) { Tools::redirect('index.php?controller=order&step=1'); } } parent::initContent(); }
public function delete() { /* Also delete related products */ Db::getInstance()->execute(' DELETE FROM `' . _DB_PREFIX_ . 'feature_product` WHERE `id_feature_value` = ' . (int) $this->id); $return = parent::delete(); if ($return) { Hook::exec('actionFeatureValueDelete', array('id_feature_value' => $this->id)); } /* Reinitializing position */ $this->cleanPositions($this->id_feature); return $return; }
public function setMedia() { $this->addJquery(); $this->addjqueryPlugin('validate'); $this->addJS(_PS_JS_DIR_ . 'jquery/plugins/validate/localization/messages_' . $this->context->language->iso_code . '.js'); $this->addCSS(__PS_BASE_URI__ . $this->admin_webpath . '/themes/' . $this->bo_theme . '/css/admin-theme.css', 'all', 0); $this->addCSS(__PS_BASE_URI__ . $this->admin_webpath . '/themes/' . $this->bo_theme . '/css/overrides.css', 'all', PHP_INT_MAX); $this->addJS(_PS_JS_DIR_ . 'vendor/spin.js'); $this->addJS(_PS_JS_DIR_ . 'vendor/ladda.js'); Media::addJsDef(array('img_dir' => _PS_IMG_)); Media::addJsDefL('one_error', $this->l('There is one error.', null, true, false)); Media::addJsDefL('more_errors', $this->l('There are several errors.', null, true, false)); Hook::exec('actionAdminLoginControllerSetMedia'); }
public function getDeliveryOptions() { $delivery_option_list = $this->context->cart->getDeliveryOptionList(); $include_taxes = !Product::getTaxCalculationMethod((int) $this->context->cart->id_customer) && (int) Configuration::get('PS_TAX'); $display_taxes_label = Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'); $carriers_available = array(); if (isset($delivery_option_list[$this->context->cart->id_address_delivery])) { foreach ($delivery_option_list[$this->context->cart->id_address_delivery] as $id_carriers_list => $carriers_list) { foreach ($carriers_list as $carriers) { if (is_array($carriers)) { foreach ($carriers as $carrier) { $carrier = array_merge($carrier, $this->objectPresenter->present($carrier['instance'])); $delay = $carrier['delay'][$this->context->language->id]; unset($carrier['instance'], $carrier['delay']); $carrier['delay'] = $delay; if ($this->isFreeShipping($this->context->cart, $carriers_list)) { $carrier['price'] = $this->translator->trans('Free', array(), 'Shop.Theme.Checkout'); } else { if ($include_taxes) { $carrier['price'] = $this->priceFormatter->convertAndFormat($carriers_list['total_price_with_tax']); if ($display_taxes_label) { $carrier['price'] = sprintf($this->translator->trans('%s tax incl.', array(), 'Shop.Theme.Checkout'), $carrier['price']); } } else { $carrier['price'] = $this->priceFormatter->convertAndFormat($carriers_list['total_price_without_tax']); if ($display_taxes_label) { $carrier['price'] = sprintf($this->translator->trans('%s tax excl.', array(), 'Shop.Theme.Checkout'), $carrier['price']); } } } if (count($carriers) > 1) { $carrier['label'] = $carrier['price']; } else { $carrier['label'] = $carrier['name'] . ' - ' . $carrier['delay'] . ' - ' . $carrier['price']; } // If carrier related to a module, check for additionnal data to display $carrier['extraContent'] = ''; if ($carrier['is_module']) { if ($moduleId = Module::getModuleIdByName($carrier['external_module_name'])) { $carrier['extraContent'] = Hook::exec('displayCarrierExtraContent', array('carrier' => $carrier), $moduleId); } } $carriers_available[$id_carriers_list] = $carrier; } } } } } return $carriers_available; }
public function initContent() { parent::initContent(); if ($orders = Order::getCustomerOrders($this->context->customer->id)) { foreach ($orders as &$order) { $myOrder = new Order((int) $order['id_order']); if (Validate::isLoadedObject($myOrder)) { $order['virtual'] = $myOrder->isVirtual(false); } } } $has_address = $this->context->customer->getAddresses($this->context->language->id); $this->context->smarty->assign(array('orders' => $orders, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'), 'slowValidation' => Tools::isSubmit('slowvalidation'), 'has_customer_an_address' => empty($has_address), 'voucherAllowed' => (int) CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN'))); $this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Hook::exec('displayCustomerAccount')); $this->setTemplate(_PS_THEME_DIR_ . 'my-account.tpl'); }
public function postProcess() { $a = new Attachment(Tools::getValue('id_attachment'), $this->context->language->id); if (!$a->id) { Tools::redirect('index.php'); } Hook::exec('actionDownloadAttachment', array('attachment' => &$a)); if (ob_get_level() && ob_get_length() > 0) { ob_end_clean(); } header('Content-Transfer-Encoding: binary'); header('Content-Type: ' . $a->mime); header('Content-Length: ' . filesize(_PS_DOWNLOAD_DIR_ . $a->file)); header('Content-Disposition: attachment; filename="' . utf8_decode($a->file_name) . '"'); readfile(_PS_DOWNLOAD_DIR_ . $a->file); exit; }