Example #1
0
 public function getTemplateVarSitemap()
 {
     $pages = [];
     $catalog_mode = Configuration::isCatalogMode();
     $cms = CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1);
     foreach ($cms['cms'] as $p) {
         $pages[] = ['id' => 'cms-page-' . $p['id_cms'], 'label' => $p['meta_title'], 'url' => $this->context->link->getCMSLink(new CMS($p['id_cms']))];
     }
     $pages[] = ['id' => 'stores-page', 'label' => $this->trans('Our stores', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('stores')];
     $pages[] = ['id' => 'contact-page', 'label' => $this->trans('Contact us', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('contact')];
     $pages[] = ['id' => 'sitemap-page', 'label' => $this->trans('Sitemap', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('sitemap')];
     $pages[] = ['id' => 'login-page', 'label' => $this->trans('Log in', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')];
     $pages[] = ['id' => 'register-page', 'label' => $this->trans('Create new account', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')];
     $catalog = ['new-product' => ['id' => 'new-product-page', 'label' => $this->trans('New products', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('new-products')]];
     if ($catalog_mode && Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         $catalog['best-sales'] = ['id' => 'best-sales-page', 'label' => $this->trans('Best sellers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('best-sales')];
         $catalog['prices-drop'] = ['id' => 'prices-drop-page', 'label' => $this->trans('Price drop', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('prices-drop')];
     }
     if (Configuration::get('PS_DISPLAY_SUPPLIERS')) {
         $manufacturers = Manufacturer::getLiteManufacturersList($this->context->language->id, 'sitemap');
         $catalog['manufacturer'] = ['id' => 'manufacturer-page', 'label' => $this->trans('Manufacturers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('manufacturer'), 'children' => $manufacturers];
         $suppliers = Supplier::getLiteSuppliersList($this->context->language->id, 'sitemap');
         $catalog['supplier'] = ['id' => 'supplier-page', 'label' => $this->trans('Suppliers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('supplier'), 'children' => $suppliers];
     }
     $categories = Category::getRootCategory()->recurseLiteCategTree(0, 0, null, null, 'sitemap');
     $catalog['category'] = ['id' => 'category-page', 'label' => $this->trans('Categories', array(), 'Shop.Theme.Catalog'), 'url' => '#', 'children' => $categories['children']];
     $sitemap = [['id' => 'page-page', 'label' => $this->trans('Pages', array(), 'Shop.Theme'), 'url' => '#', 'children' => $pages], ['id' => 'catalog-page', 'label' => $this->trans('Catalog', array(), 'Shop.Theme'), 'url' => '#', 'children' => $catalog]];
     return $sitemap;
 }
 /**
  * Assign template vars related to page content.
  *
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $this->setTemplate('customer/order-return');
 }
 public function renderWidget($hookName, array $params)
 {
     if (Configuration::isCatalogMode()) {
         return;
     }
     $this->smarty->assign($this->getWidgetVariables($hookName, $params));
     return $this->fetch('module:ps_shoppingcart/ps_shoppingcart.tpl');
 }
 public function getPresentationSettings()
 {
     $settings = new ProductPresentationSettings();
     $settings->catalog_mode = Configuration::isCatalogMode();
     $settings->include_taxes = $this->taxConfiguration->includeTaxes();
     $settings->allow_add_variant_to_cart_from_listing = (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY');
     $settings->stock_management_enabled = Configuration::get('PS_STOCK_MANAGEMENT');
     $settings->showPrices = Configuration::showPrices();
     return $settings;
 }
 public function renderWidget($hookName, array $configuration)
 {
     if (Configuration::isCatalogMode() || !Currency::isMultiCurrencyActivated()) {
         return false;
     }
     if (!$this->isCached($this->templateFile, $this->getCacheId('ps_currencyselector'))) {
         $this->smarty->assign($this->getWidgetVariables($hookName, $configuration));
     }
     return $this->fetch($this->templateFile, $this->getCacheId('ps_currencyselector'));
 }
Example #6
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $cart_rules = $this->getTemplateVarCartRules();
     if (count($cart_rules) <= 0) {
         $this->warning[] = $this->trans('You do not have any vouchers.', array(), 'Shop.Notifications.Warning');
     }
     $this->context->smarty->assign(['cart_rules' => $cart_rules]);
     $this->setTemplate('customer/discount');
 }
 /**
  * Assign template vars related to page content.
  *
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $ordersReturn = $this->getTemplateVarOrdersReturns();
     if (count($ordersReturn) <= 0) {
         $this->errors[] = $this->trans('You have no merchandise return authorizations.', array(), 'Shop.Notifications.Error');
     }
     $this->context->smarty->assign('ordersReturn', $ordersReturn);
     $this->setTemplate('customer/order-follow');
 }
Example #8
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $credit_slips = $this->getTemplateVarCreditSlips();
     if (count($credit_slips) <= 0) {
         $this->warning[] = $this->trans('You have not received any credit slips.', array(), 'Shop.Notifications.Warning');
     }
     $this->context->smarty->assign(['credit_slips' => $credit_slips]);
     $this->setTemplate('customer/order-slip');
 }
 /**
  * Assign template vars related to page content.
  *
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $order = new Order(Order::getOrderByCartId((int) $this->id_cart));
     $presentedOrder = $this->order_presenter->present($order);
     $register_form = $this->makeCustomerForm()->setGuestAllowed(false)->fillWith(Tools::getAllValues());
     $this->context->smarty->assign(array('HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation($order), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn($order), 'order' => $presentedOrder, 'register_form' => $register_form));
     if ($this->context->customer->is_guest) {
         /* If guest we clear the cookie for security reason */
         $this->context->customer->mylogout();
     }
     $this->setTemplate('checkout/order-confirmation');
 }
Example #10
0
 /**
  * Assign template vars related to page content.
  *
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $this->order_presenter = new OrderPresenter();
     if (Tools::isSubmit('slowvalidation')) {
         $this->warning[] = $this->trans('If you have just placed an order, it may take a few minutes for it to be validated. Please refresh this page if your order is missing.', array(), 'Shop.Notifications.Warning');
     }
     $orders = $this->getTemplateVarOrders();
     if (count($orders) <= 0) {
         $this->warning[] = $this->trans('You have not placed any orders.', array(), 'Shop.Notifications.Warning');
     }
     $this->context->smarty->assign(array('orders' => $orders));
     $this->setTemplate('customer/history');
 }
Example #11
0
 public function getWidgetVariables($hookName = null, array $configuration = [])
 {
     $notifications = false;
     if (Tools::isSubmit('submitMessage')) {
         $this->sendMessage();
         if (!empty($this->context->controller->errors)) {
             $notifications['messages'] = $this->context->controller->errors;
             $notifications['nw_error'] = true;
         } elseif (!empty($this->context->controller->success)) {
             $notifications['messages'] = $this->context->controller->success;
             $notifications['nw_error'] = false;
         }
     }
     if (($id_customer_thread = (int) Tools::getValue('id_customer_thread')) && ($token = Tools::getValue('token'))) {
         $cm = new CustomerThread($id_customer_thread);
         if ($cm->token == $token) {
             $this->customer_thread = $this->context->controller->objectPresenter->present($cm);
             $order = new Order((int) $this->customer_thread['id_order']);
             if (Validate::isLoadedObject($order)) {
                 $customer_thread['reference'] = $order->getUniqReference();
             }
         }
     }
     $this->contact['contacts'] = $this->getTemplateVarContact();
     $this->contact['message'] = html_entity_decode(Tools::getValue('message'));
     $this->contact['allow_file_upload'] = (bool) Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD');
     if (!(bool) Configuration::isCatalogMode()) {
         $this->contact['orders'] = $this->getTemplateVarOrders();
     } else {
         $this->contact['orders'] = array();
     }
     if ($this->customer_thread['email']) {
         $this->contact['email'] = $this->customer_thread['email'];
     } else {
         $this->contact['email'] = Tools::safeOutput(Tools::getValue('from', isset($this->context->cookie) && isset($this->context->cookie->email) && Validate::isEmail($this->context->cookie->email) ? $this->context->cookie->email : ''));
     }
     return ['contact' => $this->contact, 'notifications' => $notifications];
 }
Example #12
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     if (!($id_order = (int) Tools::getValue('id_order')) || !Validate::isUnsignedId($id_order)) {
         $this->redirect_after = '404';
         $this->redirect();
     } else {
         if (Tools::getIsset('errorQuantity')) {
             $this->errors[] = $this->trans('You do not have enough products to request an additional merchandise return.', array(), 'Shop.Notifications.Error');
         } elseif (Tools::getIsset('errorMsg')) {
             $this->errors[] = $this->trans('Please provide an explanation for your RMA.', array(), 'Shop.Notifications.Error');
         } elseif (Tools::getIsset('errorDetail1')) {
             $this->errors[] = $this->trans('Please check at least one product you would like to return.', array(), 'Shop.Notifications.Error');
         } elseif (Tools::getIsset('errorDetail2')) {
             $this->errors[] = $this->trans('For each product you wish to add, please specify the desired quantity.', array(), 'Shop.Notifications.Error');
         } elseif (Tools::getIsset('errorNotReturnable')) {
             $this->errors[] = $this->trans('This order cannot be returned', array(), 'Shop.Notifications.Error');
         } elseif (Tools::getIsset('messagesent')) {
             $this->success[] = $this->trans('Message successfully sent', array(), 'Shop.Notifications.Success');
         }
         $order = new Order($id_order);
         if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
             $this->order_to_display = (new OrderPresenter())->present($order);
             $this->context->smarty->assign(['order' => $this->order_to_display, 'HOOK_DISPLAYORDERDETAIL' => Hook::exec('displayOrderDetail', ['order' => $order])]);
         } else {
             $this->redirect_after = '404';
             $this->redirect();
         }
         unset($order);
     }
     $this->setTemplate('customer/order-detail');
 }
Example #13
0
 /**
  * Check if the product can be accessed by the Customer
  *
  * @return bool Indicates if the Customer in the current Cart has access
  */
 public function checkProductsAccess()
 {
     if (Configuration::isCatalogMode()) {
         return true;
     }
     foreach ($this->getProducts() as $product) {
         if (!Product::checkAccessStatic($product['id_product'], $this->id_customer)) {
             return $product['id_product'];
         }
     }
     return false;
 }
Example #14
0
 public function getTemplateVarConfiguration()
 {
     $quantity_discount_price = Configuration::get('PS_DISPLAY_DISCOUNT_PRICE');
     return array('display_taxes_label' => $this->getDisplayTaxesLabel(), 'low_quantity_threshold' => (int) Configuration::get('PS_LAST_QTIES'), 'is_b2b' => (bool) Configuration::get('PS_B2B_ENABLE'), 'is_catalog' => (bool) Configuration::isCatalogMode(), 'show_prices' => (bool) Configuration::showPrices(), 'opt_in' => array('partner' => (bool) Configuration::get('PS_CUSTOMER_OPTIN')), 'quantity_discount' => array('type' => $quantity_discount_price ? 'price' : 'discount', 'label' => $quantity_discount_price ? $this->getTranslator()->trans('Price', array(), 'Shop.Theme.Catalog') : $this->getTranslator()->trans('Discount', array(), 'Shop.Theme.Catalog')), 'voucher_enabled' => (int) CartRule::isFeatureActive(), 'return_enabled' => (int) Configuration::get('PS_ORDER_RETURN'), 'number_of_days_for_return' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS'));
 }
Example #15
0
 public function getTemplateVarProduct()
 {
     $productSettings = $this->getProductPresentationSettings();
     $product = $this->objectPresenter->present($this->product);
     $product['id_product'] = (int) $this->product->id;
     $product['out_of_stock'] = (int) $this->product->out_of_stock;
     $product['new'] = (int) $this->product->new;
     $product['id_product_attribute'] = (int) Tools::getValue('id_product_attribute');
     $product['minimal_quantity'] = $this->getProductMinimalQuantity($product);
     $product['quantity_wanted'] = $this->getRequiredQuantity($product);
     $product_full = Product::getProductProperties($this->context->language->id, $product, $this->context);
     $product_full = $this->addProductCustomizationData($product_full);
     $product_full['show_quantities'] = (bool) (Configuration::get('PS_DISPLAY_QTIES') && Configuration::get('PS_STOCK_MANAGEMENT') && $this->product->quantity > 0 && $this->product->available_for_order && !Configuration::isCatalogMode());
     $product_full['quantity_label'] = $this->product->quantity > 1 ? $this->trans('Items', array(), 'Shop.Theme.Catalog') : $this->trans('Item', array(), 'Shop.Theme.Catalog');
     $product_full['quantity_discounts'] = $this->quantity_discounts;
     if ($product_full['unit_price_ratio'] > 0) {
         $unitPrice = $productSettings->include_taxes ? $product_full['price'] : $product_full['price_tax_exc'];
         $product_full['unit_price'] = $unitPrice / $product_full['unit_price_ratio'];
     }
     $group_reduction = GroupReduction::getValueForProduct($this->product->id, (int) Group::getCurrent()->id);
     if ($group_reduction === false) {
         $group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
     }
     $product_full['customer_group_discount'] = $group_reduction;
     $presenter = $this->getProductPresenter();
     return $presenter->present($productSettings, $product_full, $this->context->language);
 }
Example #16
0
 public function initContent()
 {
     if (Configuration::isCatalogMode()) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $this->restorePersistedData($this->checkoutProcess);
     $this->checkoutProcess->handleRequest(Tools::getAllValues());
     $presentedCart = $this->cart_presenter->present($this->context->cart);
     if (count($presentedCart['products']) <= 0 || $presentedCart['minimalPurchaseRequired']) {
         Tools::redirect('index.php?controller=cart');
     }
     $this->checkoutProcess->setNextStepReachable()->markCurrentStep()->invalidateAllStepsAfterCurrent();
     $this->saveDataToPersist($this->checkoutProcess);
     if (!$this->checkoutProcess->hasErrors()) {
         if ($_SERVER['REQUEST_METHOD'] !== 'GET' && !$this->ajax) {
             return $this->redirectWithNotifications($this->checkoutProcess->getCheckoutSession()->getCheckoutURL());
         }
     }
     $this->context->smarty->assign(['checkout_process' => new RenderableProxy($this->checkoutProcess), 'cart' => $presentedCart]);
     $this->setTemplate('checkout/checkout');
 }
Example #17
0
 public function displayAjaxProductRefresh()
 {
     if (Configuration::isCatalogMode()) {
         return;
     }
     $url = $this->context->link->getProductLink($this->id_product, null, null, null, $this->context->language->id, null, (int) Product::getIdProductAttributesByIdAttributes($this->id_product, Tools::getValue('group')), false, false, true, ['quantity_wanted' => (int) $this->qty]);
     ob_end_clean();
     header('Content-Type: application/json');
     $this->ajaxDie(Tools::jsonEncode(['success' => true, 'productUrl' => $url]));
 }