예제 #1
0
 public function create()
 {
     $app = JFactory::getApplication();
     $formData = JRequest::get('post');
     $document = JFactory::getDocument();
     $email = $formData['email_create'];
     $document->setMimeEncoding('application/json');
     $errors = array();
     $creationData = array("success" => true);
     if (!JeproshopTools::isEmail($email) || empty($email)) {
         $creationData['has_errors'] = true;
         $errors[] = JText::_('Invalid email address.');
         $creationData['errors'] = $errors;
     } elseif (JeproshopCustomerModelCustomer::customerExists($email)) {
         $creationData['has_errors'] = true;
         $errors[] = JText::_('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false);
         $_POST['email'] = $_POST['email_create'];
         $creationData['errors'] = $errors;
         unset($_POST['email_create']);
     } else {
         $creationData['has_errors'] = false;
         $this->create_account = true;
         $view = $app->input->get('view');
         $viewClass = $this->getView($view, JFactory::getDocument()->getType());
         $viewClass->assign('email_create', JeproshopTools::safeOutput($email));
         //$app->input->set('jform[email]', $email);
     }
     $creationData['success'] = true;
     $creationData['email'] = $formData['email_create'];
     echo json_encode($creationData);
     $app->close();
 }
예제 #2
0
 /**
  * Get the user's journey
  *
  * @param integer $category_id Category ID
  * @param string $path Path end
  * @param bool $link_on_the_item
  * @param string $category_type
  * @param JeproshopContext $context
  * @return string
  * @internal param bool $linkOnTheLastItem Put or not a link on the current category
  * @internal param $string [optional] $categoryType defined what type of categories is used (products or cms)
  */
 public static function getPath($category_id, $path = '', $link_on_the_item = false, $category_type = 'products', JeproshopContext $context = null)
 {
     if (!$context) {
         $context = JeproshopContext::getContext();
     }
     $category_id = (int) $category_id;
     if ($category_id == 1) {
         return '<span class="navigation_end">' . $path . '</span>';
     }
     $pipe = '>';
     //Configuration::get('PS_NAVIGATION_PIPE');
     if (empty($pipe)) {
         $pipe = '>';
     }
     $full_path = '';
     if ($category_type === 'products') {
         $interval = JeproshopCategoryModelCategory::getInterval($category_id);
         $root_category_id = $context->shop->getCategoryId();
         $interval_root = JeproshopCategoryModelCategory::getInterval($root_category_id);
         $db = JFactory::getDBO();
         if ($interval) {
             $query = "SELECT category.category_id, category_lang.name, category_lang.link_rewrite FROM " . $db->quoteName('#__jeproshop_category');
             $query .= " AS category LEFT JOIN " . $db->quoteName('#__jeproshop_category_lang') . " AS category_lang ON (category_lang.category_id =";
             $query .= "category.category_id" . JeproshopShopModelShop::addSqlRestrictionOnLang('category_lang') . ")" . JeproshopShopModelShop::addSqlAssociation('category');
             $query .= "\tWHERE category.n_left <= " . $interval->n_left . " AND category.n_right >= " . $interval->n_right . "\tAND category.n_left >= ";
             $query .= $interval_root->n_left . " AND category.n_right <= " . $interval_root->n_right . " AND category_lang.lang_id = " . (int) $context->language->lang_id;
             $query .= "\tAND category.published = 1 AND category.depth_level > " . (int) $interval_root->depth_level . " ORDER BY category.depth_level ASC";
             $db->setQuery($query);
             $categories = $db->loadObjectList();
             $n = 1;
             $n_categories = count($categories);
             foreach ($categories as $category) {
                 $full_path .= ($n < $n_categories || $link_on_the_item ? '<a href="' . JeproshopTools::safeOutput($context->controller->getCategoryLink((int) $category->category_id, $category->link_rewrite)) . '" title="' . htmlentities($category->name, ENT_NOQUOTES, 'UTF-8') . '">' : '') . htmlentities($category->name, ENT_NOQUOTES, 'UTF-8') . ($n < $n_categories || $link_on_the_item ? '</a>' : '') . ($n++ != $n_categories || !empty($path) ? '<span class="navigation-pipe">' . $pipe . '</span>' : '');
             }
             return $full_path . $path;
         }
     } else {
         if ($category_type === 'CMS') {
             $category = new CMSCategory($category_id, $context->language->id);
             if (!Validate::isLoadedObject($category)) {
                 die(Tools::displayError());
             }
             $category_link = $context->link->getCMSCategoryLink($category);
             if ($path != $category->name) {
                 $full_path .= '<a href="' . Tools::safeOutput($category_link) . '">' . htmlentities($category->name, ENT_NOQUOTES, 'UTF-8') . '</a><span class="navigation-pipe">' . $pipe . '</span>' . $path;
             } else {
                 $full_path = ($link_on_the_item ? '<a href="' . Tools::safeOutput($category_link) . '">' : '') . htmlentities($path, ENT_NOQUOTES, 'UTF-8') . ($link_on_the_item ? '</a>' : '');
             }
             return Tools::getPath($category->parent_id, $full_path, $link_on_the_item, $category_type);
         }
     }
 }
예제 #3
0
 /**
      * Check if order is free
      * @return boolean
      * /
     public function checkFreeOrder(){
         $context = JeproshopContext::getContext();
         if ($context->cart->getOrderTotal() <= 0) {
             $order = new JeproshopFreeOrderModelFreeOrder();
             $order->free_order_class = true;
             $order->validateOrder($context->cart->cart_id, Configuration::get('PS_OS_PAYMENT'), 0, Tools::displayError('Free order', false), null, array(), null, false, $context->cart->secure_key);
             return (int)JeproshopOrderModelOrder::getOrderByCartId($context->cart->cart_id);
         }
         return false;
     }
 
 
     public function assignCarrier(){
         $view = JFactory::getDBO();
         $context = JeproshopContext::getContext();
         $address = new JeproshopAddressModelAddress($context->cart->address_delivery_id);
         $zone_id = JeproshopAddressModelAddress::getZoneIdByAddressId($address->address_id);
         $carriers = $context->cart->simulateCarriersOutput(null, true);
         $checked = $context->cart->simulateCarrierSelectedOutput(false);
         $delivery_option_list = $context->cart->getDeliveryOptionList();
         $delivery_option = $context->cart->getDeliveryOption(null, false);
         $this->setDefaultCarrierSelection($delivery_option_list);
 
         $view->assignRef('address_collection', $context->cart->getAddressCollection());
         $view->assignRef('delivery_option_list', $delivery_option_list);
         $view->assignRef('carriers', $carriers);
         $view->assignRef('checked',  $checked);
         $view->assignRef('delivery_option', $delivery_option);
 
 
         $vars = array(
             /*'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array(
                     'carriers' => $carriers,
                     'checked' => $checked,
                     'delivery_option_list' => $delivery_option_list,
                     'delivery_option' => $delivery_option
                 ))*  /
         );
 
         JeproshopCartModelCart::addExtraCarriers($vars);
 
         $view->assignRef('extra_carriers', $vars);
     }
 
     /**
      * Decides what the default carrier is and update the cart with it
      *
      * @todo this function must be modified - id_carrier is now delivery_option
      *
      * @param array $carriers
      *
      * @deprecated since 1.5.0
      *
      * @return number the id of the default carrier
      * /
     protected function setDefaultCarrierSelection($carriers) {
         $context = JeproshopContext::getContext();
         if (!$context->cart->getDeliveryOption(null, true))
             $context->cart->setDeliveryOption($context->cart->getDeliveryOption());
     }*/
 public function globalInitialization()
 {
     $app = JFactory::getApplication();
     $view = $app->input->get('view');
     $viewClass = $this->getView($view, JFactory::getDocument()->getType());
     $context = JeproshopContext::getContext();
     $this->isLogged = (bool) ($context->customer->customer_id && JeproshopCustomerModelCustomer::customerIdExistsStatic((int) $context->cookie->customer_id));
     parent::initialize();
     /* Disable some cache related bugs on the cart/order */
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     if (!$context->customer->isLogged(true) && $this->useMobileTheme() && $app->input->get('step')) {
         $app->redirect(JRoute::_('index.php?option=com_jeproshop&view=authentication&lang_id=' . $context->language->lang_id, true, 1));
     }
     // Redirect to the good order process
     $task = $app->input->get('task', '');
     $order_process_type = JeproshopSettingModelSetting::getValue('order_process_type');
     if ($order_process_type == 'standard' && ($task != '' || $task != 'display')) {
         //$app->redirect('index.php?option=com_jeproshop&view=order');
     }
     if ($order_process_type == 'page_checkout' && $task != 'opc') {
         $step = $app->input->get('step');
         if (isset($step) && $step == 3) {
             $app->redirect('index.php?option=com_jeproshop&view=order&task=opc&isPaymentStep=true');
         }
         $app->redirect('index.php?option=com_jeproshop&view=order&task=opc');
     }
     $catalog_mode = JeproshopSettingModelSetting::getValue('catalog_mode');
     if ($catalog_mode) {
         $this->has_errors = true;
         JError::raiseError(500, JText::_('COM_JEPROSHOP_THIS_STORE_DOES_NOT_ACCEPT_NEW_ORDER_MESSAGE'));
     }
     $order_id = (int) $app->input->get('order_id');
     $currentTask = $app->input->get('task');
     if ($currentTask == 'submitReorder' && $order_id) {
         $oldCart = new JeproshopCartModelCart(JeproshopOrderModelOrder::getStaticCartId($order_id, $context->customer->customer_id));
         $duplication = $oldCart->duplicate();
         if (!$duplication || !JeproshopTools::isLoadedObject($duplication->cart, 'cart_id')) {
             $this->has_errors = true;
             Tools::displayError('Sorry. We cannot renew your order.');
         } else {
             if (!$duplication->success) {
                 $this->has_errors = true;
                 Tools::displayError('Some items are no longer available, and we are unable to renew your order.');
             } else {
                 $context->cookie->cart_id = $duplication->cart->cart_id;
                 $context->cookie->write();
                 if ($order_process_type == 'page_checkout') {
                     $app->redirect('index.php?option=com_jeproshop&view=order&task=opc');
                 }
                 $app->redirect('index.php?option=com_jeproshop&view=order');
             }
         }
     }
     $viewClass->assignRef('order_process_type', $order_process_type);
     $nbProducts = $context->cart->numberOfProducts();
     if ($nbProducts) {
         if (JeproshopCartRuleModelCartRule::isFeaturePublished()) {
             if (Tools::isSubmit('submitAddDiscount')) {
                 if (!($code = trim(Tools::getValue('discount_name')))) {
                     $this->has_errors = true;
                     JError::raiseError('You must enter a voucher code.');
                 } elseif (!Validate::isCleanHtml($code)) {
                     $this->has_errors = true;
                     JEroor::raiseError('The voucher code is invalid.');
                 } else {
                     $cartRule = new JeproshopCartRuleModelCartRule(JeproshopCartRuleModelCartRule::getIdByCode($code));
                     if ($cartRule && JeproshopTools::isLoadedObject($cartRule, 'cart_rule_id')) {
                         if ($error = $cartRule->checkValidity($context, false, true)) {
                             $this->has_errors = true;
                             JError::raiseError(500, $error);
                         } else {
                             $context->cart->addCartRule($cartRule->cart_rule_id);
                             if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                                 Tools::redirect('index.php?controller=order-opc&addingCartRule=1');
                             }
                             Tools::redirect('index.php?controller=order&task=adding_cart_rule');
                         }
                     } else {
                         $this->has_errors = true;
                         Tools::displayError('This voucher does not exists.');
                     }
                 }
                 $discountName = JeproshopTools::safeOutput($code);
                 $viewClass->assignRef('discount_name', $discountName);
             } elseif (($cart_rule_id = (int) Tools::getValue('delete_discount')) && JeproshopTools::isUnsignedId($cart_rule_id)) {
                 $context->cart->removeCartRule($cart_rule_id);
                 $app->redirect('index.php?option=com_jeproshop&view=order&task=opc');
             }
         }
         /* Is there only virtual product in cart */
         if ($isVirtualCart = $context->cart->isVirtualCart()) {
             $this->setNoCarrier();
         }
     }
     //$viewClass->assignRef('back', JTools::safeOutput(Tools::getValue('back')));*/
 }
예제 #4
0
 /**
  * Assign template vars related to category
  */
 protected function assignCategory()
 {
     // Assign category to the template
     if ($this->category !== false && JeproshopTools::isLoadedObject($this->category, 'category_id') && $this->category->inShop() && $this->category->isAssociatedToShop()) {
         $path = JeproshopTools::getPath($this->category->category_id, $this->product->name, true);
     } elseif (JeproshopCategoryModelCategory::inShopStatic($this->product->default_category_id, $this->context->shop)) {
         $this->category = new JeproshopCategoryModelCategory((int) $this->product->default_category_id, (int) $this->context->language->lang_id);
         if (JeproshopTools::isLoadedObject($this->category, 'category_id') && $this->category->published && $this->category->isAssociatedToShop()) {
             $path = JeproshopTools::getPath((int) $this->product->default_category_id, $this->product->name[$this->context->language->lang_id]);
         }
     }
     if (!isset($path) || !$path) {
         $path = JeproshopTools::getPath((int) $this->context->shop->category_id, $this->product->name[$this->context->language->lang_id]);
     }
     $subCategories = array();
     if (JeproshopTools::isLoadedObject($this->category, 'category_id')) {
         $subCategories = $this->category->getSubCategories($this->context->language->lang_id, true);
         // various assignments before Hook::exec
         $this->assignRef('path', $path);
         $this->assignRef('category', $this->category);
         $this->assignRef('sub_categories', $subCategories);
         $this->assignRef('current_category_id', $this->category->category_id);
         $this->assignRef('parent_category_id', $this->category->parent_id);
         $return_category_name = JeproshopTools::safeOutput($this->category->getFieldByLang('name'));
         $this->assignRef('return_category_name', $return_category_name);
         $categories = JeproshopCategoryModelCategory::getHomeCategories($this->context->language->lang_id, true, (int) $this->context->shop->shop_id);
         $this->assignRef('categories', $categories);
     }
     //$this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category))));
 }