Ejemplo n.º 1
0
 /**
  * Load class supplier using identifier in $_GET (if possible)
  * otherwise return an empty supplier, or die
  *
  * @param boolean $opt Return an empty supplier if load fail
  * @return supplier|boolean
  */
 public function loadObject($opt = false)
 {
     $app = JFactory::getApplication();
     $currency_id = (int) $app->input->get('currency_id');
     if ($currency_id && JeproshopTools::isUnsignedInt($currency_id)) {
         if (!$this->currency) {
             $this->currency = new JeproshopCurrencyModelCurrency($currency_id);
         }
         if (JeproshopTools::isLoadedObject($this->currency, 'currency_id')) {
             return $this->currency;
         }
         // throw exception
         JError::raiseError(500, 'The currency cannot be loaded (or not found)');
         return false;
     } elseif ($opt) {
         if (!$this->currency) {
             $this->currency = new JeproshopCurrencyModelCurrency();
         }
         return $this->currency;
     } else {
         $this->context->controller->has_errors = true;
         Tools::displayError('The currency cannot be loaded (the identifier is missing or invalid)');
         return false;
     }
 }
Ejemplo n.º 2
0
 public function initialize()
 {
     parent::initialize();
     $app = JFactory::getApplication();
     $context = JeproshopContext::getContext();
     // Get address ID
     $address_id = 0;
     $type = $app->input->get('type');
     if ($this->use_ajax && isset($type)) {
         if ($type == 'delivery' && isset($context->cart->address_delivery_id)) {
             $address_id = (int) $context->cart->address_delivery_id;
         } else {
             if ($type == 'invoice' && isset($context->cart->address_invoice_id) && $context->cart->id_address_invoice != $context->cart->address_delivery_id) {
                 $address_id = (int) $context->cart->address_invoice_id;
             }
         }
     } else {
         $address_id = (int) $app->input->get('address_id', 0);
     }
     // Initialize address
     if ($address_id) {
         $address = new JeproshopAddressModelAddress($address_id);
         $view = $app->input->get('view');
         $viewClass = $this->getView($view, JFactory::getDocument()->getType());
         if (JeproshopTools::isLoadedObject($address, 'address_id') && JeproshopCustomerModelCustomer::customerHasAddress($context->customer->customer_id, $address_id)) {
             $task = $app->input->get('task');
             if (isset($task) && $task == 'delete') {
                 if ($address->delete()) {
                     if ($context->cart->address_invoice_id == $address->address_id) {
                         unset($context->cart->address_invoice_id);
                     }
                     if ($context->cart->id_address_delivery == $address->address_id) {
                         unset($context->cart->id_address_delivery);
                         $context->cart->updateAddressId($address->address_id, (int) JeproshopAddressModelAddress::getCustomerFirstAddressId($context->customer->customer_id));
                     }
                     $app->redirect('index.php?option=com_jeproshop&view=address');
                 }
                 $this->has_errors = true;
                 JError::raiseError(500, 'This address cannot be deleted.');
             }
         } elseif ($this->use_ajax) {
             $app->close;
         } else {
             $app->redirect('index.php?option=com_jeproshop&view=address');
         }
     }
 }
Ejemplo n.º 3
0
 public function initialize()
 {
     $app = JFactory::getApplication();
     $context = JeproshopContext::getContext();
     parent::initialize();
     $category_id = $app->input->get('category_id');
     $task = $app->input->get('task');
     if ($category_id && $task != 'delete') {
         $this->category = new JeproshopCategoryModelCategory($category_id);
     } else {
         if (JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
             $this->category = new JeproshopCategoryModelCategory($context->shop->category_id);
         } elseif (count(JeproshopCategoryModelCategory::getCategoriesWithoutParent()) > 1 && JeproshopSettingModelSetting::getValue('multishop_feature_active') && count(JeproshopShopModelShop::getShops(true, null, true)) != 1) {
             $this->category = JeproshopCategoryModelCategory::getTopCategory();
         } else {
             $this->category = new JeproshopCategoryModelCategory(JeproshopSettingModelSetting::getValue('root_category'));
         }
     }
     if (JeproshopTools::isLoadedObject($this->category, 'category_id') && !$this->category->isAssociatedToShop() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
         $app->redirect('index.php?option=com_jeproshop&view=category&task=edit&category_id=' . (int) $context->shop->getCategoryId() . '&' . JeproshopTools::getCategoryToken() . '=1');
     }
 }
Ejemplo n.º 4
0
 public function loadObject($option = false)
 {
     $app = JFactory::getApplication();
     $tag_id = $app->input->get('tag_id');
     if ($tag_id && JeproshopTools::isUnsignedInt($tag_id)) {
         if (!$this->tag) {
             $this->tag = new JeproshopTagModelTag($tag_id);
         }
         if (JeproshopTools::isLoadedObject($this->tag, 'tag_id')) {
             return $this->tag;
         }
         JError::raiseError(500, JText::_('COM_JEPROSHOP_TAG_CANNOT_BE_LOADED_OR_FOUND_LABEL'));
     } elseif ($option) {
         if ($this->tag) {
             $this->tag = new JeproshopTagModelTag();
         }
         return $this->tag;
     } else {
         JError::raiseError(500, JText::_('COM_JEPROSHOP_THE_TAG_CANNOT_BE_LOADED_THE_IDENTIFIER_IS_MISSING_OR_INVALID_MESSAGE'));
         return false;
     }
 }
Ejemplo n.º 5
0
 public function loadObject($option = false)
 {
     echo 'correct';
     exit;
     $app = JFactory::getApplication();
     $attribute_id = $app->input->get('attribute_id');
     if ($attribute_id && JeproshopTools::isUnsignedInt($attribute_id)) {
         if (!$this->attribute) {
             $this->attribute = new JeproshopAttributeModelAttribute($attribute_id);
         }
         if (JeproshopTools::isLoadedObject($this->attribute, 'attribute_id')) {
             return $this->attribute;
         }
         JError::raiseError(500, JText::_('COM_JEPROSHOP_ATTRIBUTE_CANNOT_BE_LOADED_OR_FOUND_LABEL'));
     } elseif ($option) {
         if ($this->attribute) {
             $this->attribute = new JeproshopAttributeModelAttribute();
         }
         return $this->attribute;
     } else {
         JError::raiseError(500, JText::_('COM_JEPROSHOP_THE_ATTRIBUTE_CANNOT_BE_LOADED_THE_IDENTIFIER_IS_MISSING_OR_INVALID_MESSAGE'));
         return false;
     }
 }
Ejemplo n.º 6
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')));*/
 }
Ejemplo n.º 7
0
 /**
  * Set cookie currency from POST or default currency
  *
  * @param $cookie
  * @return JeproshopCurrencyModelCurrency object
  */
 public static function setCurrency($cookie)
 {
     $app = JFactory::getApplication();
     if ($app->input->get('SubmitCurrency')) {
         if (isset($_POST['currency_id']) && is_numeric($_POST['currency_id'])) {
             $currency = JeproshopCurrencyModelCurrency::getCurrencyInstance($_POST['currency_id']);
             if (is_object($currency, 'currency_id') && $currency->currency_id && !$currency->deleted && $currency->isAssociatedToShop()) {
                 $cookie->currency_id = (int) $currency->currency_id;
             }
         }
     }
     $currency = null;
     if ((int) $cookie->currency_id) {
         $currency = JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $cookie->currency_id);
     }
     if (!JeproshopTools::isLoadedObject($currency, 'currency_id') || (bool) $currency->deleted || !(bool) $currency->published) {
         $currency = JeproshopCurrencyModelCurrency::getCurrencyInstance(JeproshopSettingModelSetting::getValue('default_currency'));
     }
     $cookie->currency_id = (int) $currency->currency_id;
     if ($currency->isAssociatedToShop()) {
         return $currency;
     } else {
         // get currency from context
         $currency = JeproshopShopModelShop::getEntityIds('currency', JeproshopContext::getContext()->shop->shop_id, true, true);
         if (isset($currency[0]) && $currency[0]['id_currency']) {
             $cookie->id_currency = $currency[0]['id_currency'];
             return Currency::getCurrencyInstance((int) $cookie->id_currency);
         }
     }
     return $currency;
 }
Ejemplo n.º 8
0
JeproshopSettingModelSetting::loadSettings();
/** load languages  */
JeproshopLanguageModelLanguage::loadLanguages();
/** set context cookie */
$life_time = time() + max(JeproshopSettingModelSetting::getValue('bo_life_time'), 1) * 3600;
$context->cookie = new JeproshopCookie('jeproshop_admin', '', $life_time);
/** @var  employee */
$context->employee = new JeproshopEmployeeModelEmployee(JFactory::getUser()->id);
$context->cookie->employee_id = $context->employee->employee_id;
/** Loading default country */
$context->country = new JeproshopCountryModelCountry(JeproshopSettingModelSetting::getValue('default_country'), JeproshopSettingModelSetting::getValue('default_lang'));
/** if the cookie stored language is not an available language, use default language */
if (isset($context->cookie->lang_id) && $context->cookie->lang_id) {
    $language = new JeproshopLanguageModelLanguage($context->cookie->lang_id);
}
if (!isset($language) || !JeproshopTools::isLoadedObject($language, 'lang_id')) {
    $language = new JeproshopLanguageModelLanguage(JeproshopSettingModelSetting::getValue('default_lang'));
}
$context->language = $language;
$currency_id = $context->cookie->currency_id ? $context->cookie->currency_id : JeproshopSettingModelSetting::getValue('default_currency');
$context->currency = new JeproshopCurrencyModelCurrency($currency_id);
/** controller and redirection */
$controller = JFactory::getApplication()->input->get('view');
//if($controller == 'orders'){ $controller = 'order'; }
if ($controller) {
    if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php')) {
        require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controller.php';
        require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php';
    } else {
        $controller = '';
    }
Ejemplo n.º 9
0
 public function renderAddForm($tpl = null)
 {
     //print_r(JeproshopCustomerModelCustomer::searchByName('je'));
     $context = JeproshopContext::getContext();
     if ($context->shop->getShopContext() != JeproshopShopModelShop::CONTEXT_SHOP && JeproshopShopModelShop::isFeaturePublished()) {
         $context->controller->has_errors = true;
         $this->l('You have to select a shop before creating new orders.');
     }
     $app = JFactory::getApplication();
     $cart_id = (int) $app->input->get('cart_id');
     $cart = new JeproshopCartModelCart((int) $cart_id);
     if ($cart_id && !JeproshopTools::isLoadedObject($cart, 'cart_id')) {
         $context->controller->has_errors = true;
         $this->l('This cart does not exists');
     }
     if ($cart_id && JeproshopTools::isLoadedObject($cart, 'cart_id') && !$cart->customer_id) {
         $context->controller->has_errors = true;
         $this->l('The cart must have a customer');
     }
     if ($context->controller->has_errors) {
         return false;
     }
     /*parent::renderForm();
             unset($this->toolbar_btn['save']);
             $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch'));
     */
     $defaults_order_statues = array('cheque' => (int) JeproshopSettingModelSetting::getValue('order_status_cheque'), 'bank_wire' => (int) JeproshopSettingModelSetting::getValue('order_status_bank_wire'), 'cash_on_delivery' => (int) JeproshopSettingModelSetting::getValue('order_status_preparation'), 'other' => (int) JeproshopSettingModelSetting::getValue('order_status_payment'));
     $payment_modules = array();
     /*  foreach (PaymentModule::getInstalledPaymentModules() as $p_module)
                 $payment_modules[] = Module::getInstanceById((int)$p_module['id_module']);
     */
     $recyclable_pack = (int) JeproshopSettingModelSetting::getValue('offer_recycled_wrapping');
     $this->assignRef('recyclable_pack', $recyclable_pack);
     $gift_wrapping = (int) JeproshopSettingModelSetting::getValue('offer_gift_wrapping');
     $this->assignRef('gift_wrapping', $gift_wrapping);
     $this->assignRef('cart', $cart);
     $this->assignRef('cart_id', $cart_id);
     $currencies = JeproshopCurrencyModelCurrency::getCurrenciesByShopId(JeproshopContext::getContext()->shop->shop_id);
     $this->assignRef('currencies', $currencies);
     $languages = JeproshopLanguageModelLanguage::getLanguages(true, JeproshopContext::getContext()->shop->shop_id);
     $this->assignRef('languages', $languages);
     $this->assignRef('payment_modules', $payment_modules);
     $order_statues = JeproshopOrderStatusModelOrderStatus::getOrderStatus((int) JeproshopContext::getContext()->language->lang_id);
     $this->assignRef('order_statues', $order_statues);
     $this->assignRef('defaults_order_statues', $defaults_order_statues);
     /*    'show_toolbar' => $this->show_toolbar,
               'toolbar_btn' => $this->toolbar_btn,
               'toolbar_scroll' => $this->toolbar_scroll,
               'title' => array($this->l('Orders'), $this->l('Create order'))
           ));* /
           $this->content .= $this->createTemplate('form.tpl')->fetch(); */
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
Ejemplo n.º 10
0
 protected function loadObject($option = false)
 {
     $app = JFactory::getApplication();
     $product_id = $app->input->get('product_id');
     $isLoaded = false;
     $context = JeproshopContext::getContext();
     if ($product_id && JeproshopTools::isUnsignedInt($product_id)) {
         if (!$this->product) {
             $this->product = new JeproshopProductModelProduct($product_id, false, $context->language->lang_id);
         }
         if (!JeproshopTools::isLoadedObject($this->product, 'product_id')) {
             JError::raiseError(500, JText::_('COM_JEPROSHOP_PRODUCT_NOT_FOUND_MESSAGE'));
             $isLoaded = false;
         } else {
             $isLoaded = true;
         }
     } elseif ($option) {
         if (!$this->product) {
             $this->product = new JeproshopProductModelProduct();
         }
     } else {
         JError::raiseError(500, JText::_('COM_JEPROSHOP_PRODUCT_DOES_NOT_EXIST_MESSAGE'));
         $isLoaded = false;
     }
     //specified
     if ($isLoaded && JeproshopTools::isLoadedObject($this->product, 'product_id')) {
         if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP && JeproshopShopModelShop::isFeaturePublished() && !$this->product->isAssociatedToShop()) {
             $this->product = new JeproshopProductModelProduct((int) $this->product->product_id, false, $context->language->lang_id, (int) $this->product->default_shop_id);
         }
         $this->product->loadStockData();
     }
     return $isLoaded;
 }
Ejemplo n.º 11
0
 /**
  * Load class object using identifier in $_GET (if possible)
  * otherwise return an empty object, or die
  *
  * @param boolean $opt Return an empty object if load fail
  * @return object|boolean
  */
 public function loadObject($opt = false)
 {
     $app = JFactory::getApplication();
     $cart_id = (int) $app->input->get('cart_id');
     if ($cart_id && JeproshopTools::isUnsignedInt($cart_id)) {
         if (!$this->cart) {
             $this->cart = new JeproshopCartModelCart($cart_id);
         }
         if (JeproshopTools::isLoadedObject($this->cart, 'cart_id')) {
             return $this->cart;
         }
         // throw exception
         $this->errors[] = Tools::displayError('The object cannot be loaded (or found)');
         return false;
     } elseif ($opt) {
         if (!$this->cart) {
             $this->cart = new JeproshopCartModelCart();
         }
         return true;
     } else {
         $this->errors[] = Tools::displayError('The object cannot be loaded (the identifier is missing or invalid)');
         return false;
     }
 }
Ejemplo n.º 12
0
 /**
  * Return current group object
  * Use context
  * @static
  * @return Group Group object
  */
 public static function getCurrent()
 {
     static $groups = array();
     $customer = JeproshopContext::getContext()->customer;
     if (JeproshopTools::isLoadedObject($customer, 'customer_id')) {
         $group_id = (int) $customer->default_group_id;
     } else {
         $group_id = (int) JeproshopSettingModelSetting::getValue('unidentified_group');
     }
     if (!isset($groups[$group_id])) {
         $groups[$group_id] = new JeproshopGroupModelGroup($group_id);
     }
     if (!$groups[$group_id]->isAssociatedToShop(JeproshopContext::getContext()->shop->shop_id)) {
         $group_id = (int) JeproshopSettingModelSetting::getValue('customer_group');
         if (!isset($groups[$group_id])) {
             $groups[$group_id] = new JeproshopGroupModelGroup($group_id);
         }
     }
     return $groups[$group_id];
 }
Ejemplo n.º 13
0
 /**
  * Initialize an address corresponding to the specified id address or if empty to the
  * default shop configuration
  *
  * @param int $address_id
  * @return Address address
  */
 public static function initialize($address_id = null)
 {
     //if an address_id has been specified retrieve the address
     if ($address_id) {
         $address = new JeproshopAddressModelAddress($address_id);
         if (!JeproshopTools::isLoadedObject($address, 'address_id')) {
             JError::raiseError(500, JText::_('COM_JEPROSHOP_INVALID_ADDRESS_MESSAGE'));
         }
     } else {
         // Set the default address
         $address = new JeproshopAddressModelAddress();
         $address->country_id = (int) JeproshopContext::getContext()->country->country_id;
         $address->state_id = 0;
         $address->postcode = 0;
     }
     return $address;
 }
Ejemplo n.º 14
0
 public function loadObject($option = false)
 {
     $app = JFactory::getApplication();
     $carrier_id = $app->input->get('carrier_id');
     if ($carrier_id && JeproshopTools::isUnsignedInt($carrier_id)) {
         if (!$this->carrier) {
             $this->carrier = new JeproshopCarrierModelcarrier($carrier_id);
         }
         if (JeproshopTools::isLoadedObject($this->carrier, 'carrier_id')) {
             return true;
         }
         return false;
     } elseif ($option) {
         if (!$this->carrier) {
             $this->carrier = new JeproshopCarrierModelCarrier();
         }
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 15
0
 /**
  * @see StockManagerInterface::addProduct()
  */
 public function addProduct($product_id, $product_attribute_id = 0, JeproshopWarehouseModelWarehouse $warehouse, $quantity, $stock_mvt_reason_id, $price_tax_excluded, $is_usable = true, $supply_order_id = null)
 {
     if (!JeproshopTools::isLoadedObject($warehouse, 'warehouse_id') || !$price_tax_excluded || !$quantity || !$product_id) {
         return false;
     }
     $price_tax_excluded = (double) round($price_tax_excluded, 6);
     if (!StockMvtReason::exists($id_stock_mvt_reason)) {
         $id_stock_mvt_reason = Configuration::get('PS_STOCK_MVT_INC_REASON_DEFAULT');
     }
     $context = Context::getContext();
     $mvt_params = array('id_stock' => null, 'physical_quantity' => $quantity, 'id_stock_mvt_reason' => $id_stock_mvt_reason, 'id_supply_order' => $id_supply_order, 'price_te' => $price_te, 'last_wa' => null, 'current_wa' => null, 'id_employee' => $context->employee->id, 'employee_firstname' => $context->employee->firstname, 'employee_lastname' => $context->employee->lastname, 'sign' => 1);
     $stock_exists = false;
     // switch on MANAGEMENT_TYPE
     switch ($warehouse->management_type) {
         // case CUMP mode
         case 'WA':
             $stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id);
             // if this product is already in stock
             if (count($stock_collection) > 0) {
                 $stock_exists = true;
                 // for a warehouse using WA, there is one and only one stock for a given product
                 $stock = $stock_collection->current();
                 // calculates WA price
                 $last_wa = $stock->price_te;
                 $current_wa = $this->calculateWA($stock, $quantity, $price_te);
                 $mvt_params['id_stock'] = $stock->id;
                 $mvt_params['last_wa'] = $last_wa;
                 $mvt_params['current_wa'] = $current_wa;
                 $stock_params = array('physical_quantity' => $stock->physical_quantity + $quantity, 'price_te' => $current_wa, 'usable_quantity' => $is_usable ? $stock->usable_quantity + $quantity : $stock->usable_quantity, 'id_warehouse' => $warehouse->id);
                 // saves stock in warehouse
                 $stock->hydrate($stock_params);
                 $stock->update();
             } else {
                 $mvt_params['last_wa'] = 0;
                 $mvt_params['current_wa'] = $price_te;
             }
             break;
             // case FIFO / LIFO mode
         // case FIFO / LIFO mode
         case 'FIFO':
         case 'LIFO':
             $stock_collection = $this->getStockCollection($id_product, $id_product_attribute, $warehouse->id, $price_te);
             // if this product is already in stock
             if (count($stock_collection) > 0) {
                 $stock_exists = true;
                 // there is one and only one stock for a given product in a warehouse and at the current unit price
                 $stock = $stock_collection->current();
                 $stock_params = array('physical_quantity' => $stock->physical_quantity + $quantity, 'usable_quantity' => $is_usable ? $stock->usable_quantity + $quantity : $stock->usable_quantity);
                 // updates stock in warehouse
                 $stock->hydrate($stock_params);
                 $stock->update();
                 // sets mvt_params
                 $mvt_params['id_stock'] = $stock->id;
             }
             break;
         default:
             return false;
             break;
     }
     if (!$stock_exists) {
         $stock = new Stock();
         $stock_params = array('id_product_attribute' => $id_product_attribute, 'id_product' => $id_product, 'physical_quantity' => $quantity, 'price_te' => $price_te, 'usable_quantity' => $is_usable ? $quantity : 0, 'id_warehouse' => $warehouse->id);
         // saves stock in warehouse
         $stock->hydrate($stock_params);
         $stock->add();
         $mvt_params['id_stock'] = $stock->id;
     }
     // saves stock mvt
     $stock_mvt = new StockMvt();
     $stock_mvt->hydrate($mvt_params);
     $stock_mvt->add();
     return true;
 }
Ejemplo n.º 16
0
 /**
  * Add several tags in database and link it to a product
  *
  * @param integer $lang_id Language id
  * @param integer $product_id Product id to link tags with
  * @param string|array $tag_list List of tags, as array or as a string with comas
  * @param string $separator
  * @return bool Operation success
  */
 public static function addTags($lang_id, $product_id, $tag_list, $separator = ',')
 {
     $db = JFactory::getDBO();
     if (!JeproshopTools::isUnsignedInt($lang_id)) {
         return false;
     }
     if (!is_array($tag_list)) {
         $tag_list = array_filter(array_unique(array_map('trim', preg_split('#\\' . $separator . '#', $tag_list, null, PREG_SPLIT_NO_EMPTY))));
     }
     $list = array();
     if (is_array($tag_list)) {
         foreach ($tag_list as $tag) {
             if (!JeproshopTools::isGenericName($tag)) {
                 return false;
             }
             $tag = trim(substr($tag, 0, 32));
             $tag_obj = new JeproshopTagModelTag(null, $tag, (int) $lang_id);
             /* Tag does not exist in database */
             if (!JeproshopTools::isLoadedObject($tag_obj, 'tag_id')) {
                 $tag_obj->name = $tag;
                 $tag_obj->lang_id = (int) $lang_id;
                 $tag_obj->add();
             }
             if (!in_array($tag_obj->tag_id, $list)) {
                 $list[] = $tag_obj->tag_id;
             }
         }
     }
     $data = '';
     $result = true;
     foreach ($list as $tag_id) {
         $query = "INSERT INTO " . $db->quoteName('#__jeproshop_product_tag') . " ( " . $db->quoteName('tag_id') . ", ";
         $query .= $db->quoteName('product_id') . ") VALUES (" . (int) $tag_id . ", " . (int) $product_id . ")";
         $db->setQuery($query);
         $result &= $db->query();
     }
     return $result;
 }
Ejemplo n.º 17
0
 /**
  * Fill the variables used for stock management
  */
 public function loadStockData()
 {
     if (JeproshopTools::isLoadedObject($this, 'product_id')) {
         // By default, the product quantity correspond to the available quantity to sell in the current shop
         $this->quantity = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($this->product_id, 0);
         $this->out_of_stock = JeproshopStockAvailableModelStockAvailable::outOfStock($this->product_id);
         $this->depends_on_stock = JeproshopStockAvailableModelStockAvailable::dependsOnStock($this->product_id);
         if (JeproshopContext::getContext()->shop->getShopContext() == JeproshopShopModelShop::CONTEXT_GROUP && JeproshopContext::getContext()->shop->getContextShopGroup()->share_stock == 1) {
             $this->advanced_stock_management = $this->useAdvancedStockManagement();
         }
     }
 }
Ejemplo n.º 18
0
 public function update_rules_group()
 {
     if ($this->viewAccess() && JeproshopTools::checkTaxToken()) {
         $app = JFactory::getApplication();
         $tax_rules_group_id = $app->input->get('tax_rules_group_id');
         if (isset($tax_rules_group_id) && !empty($tax_rules_group_id)) {
             $tax_rules_group = new JeproshopTaxRulesGroupModelTaxRulesGroup($tax_rules_group_id);
             if (JeproshopTools::isLoadedObject($tax_rules_group, 'tax_rules_group_id')) {
                 $tax_rules_group->update();
             }
         }
     }
 }
Ejemplo n.º 19
0
 public function loadObject($option = false)
 {
     $app = JFactory::getApplication();
     $category_id = $app->input->get('category_id');
     if (!isset($this->context) || $this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     $isLoaded = false;
     if ($category_id && JeproshopTools::isUnsignedInt($category_id)) {
         if (!$this->context->controller->category) {
             $this->context->controller->category = new JeproshopCategoryModelCategory($category_id);
         }
         if (!JeproshopTools::isLoadedObject($this->context->controller->category, 'category_id')) {
             JError::raiseError(500, JText::_('COM_JEPROSHOP_CATEGORY_NOT_FOUND_MESSAGE'));
             $isLoaded = false;
         } else {
             $isLoaded = true;
         }
     } elseif ($option) {
         if (!$this->context->controller->category) {
             $this->context->controller->category = new JeproshopCategoryModelCategory();
         }
     } else {
         JError::raiseError(500, JText::_('COM_JEPROSHOP_CATEGORY_DOES_NOT_EXIST_MESSAGE'));
         $isLoaded = false;
     }
     return $isLoaded;
 }
Ejemplo n.º 20
0
 public function updateCategory()
 {
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     $input = JRequest::get('post');
     $category_data = $input['jform'];
     $languages = JeproshopLanguageModelLanguage::getLanguages();
     $context = JeproshopContext::getContext();
     if (!$context->controller->has_errors) {
         $category_id = (int) $app->input->get('category_id');
         /** update category  */
         if (isset($category_id) && !empty($category_id)) {
             //$category = new JeproshopCategoryModelCategory($category_id);
             if (JeproshopTools::isLoadedObject($this, 'category_id')) {
                 if ($this->category_id == $this->parent_id) {
                     $context->controller->has_errors = true;
                     JError::_(500, JText::_('COM_JEPROSHOP_A_CATEGORY_CANNOT_BE_ITS_OWN_PARENT_LABEL'));
                 }
                 if ($this->is_root_category) {
                     $this->parent_id = JeproshopSettingModelSetting::getValue('root_category');
                 }
                 // Update group selection
                 $this->updateGroup($this->groupBox);
                 $this->depth_level = $this->calculateDepthLevel();
                 // If the parent category was changed, we don't want to have 2 categories with the same position
                 if ($this->getDuplicatedPosition()) {
                     if ($category_data['check_box_shop_associated_category']) {
                         foreach ($category_data['check_box_shop_associated_category'] as $associated_category_id => $row) {
                             foreach ($row as $shop_id => $value) {
                                 $this->addPosition(JeproshopCategoryModelCategory::getLastPosition((int) $this->parent_id, (int) $shop_id), (int) $shop_id);
                             }
                         }
                     } else {
                         foreach (JeproshopShopModelShop::getShops(true) as $shop) {
                             $this->addPosition(max(1, JeproshopCategoryModelCategory::getLastPosition((int) $this->parent_id, $shop->shop_id)), $shop->shop_id);
                         }
                     }
                 }
                 $this->cleanPositions((int) $this->parent_id);
                 $this->clearCache();
                 $this->date_upd = date('Y-m-d H:i:s');
                 $shop_list_ids = JeproshopShopModelShop::getContextListShopIds();
                 if (count($this->shop_list_ids) > 0) {
                     $shop_list_ids = $this->shop_list_ids;
                 }
                 if (JeproshopShopModelShop::checkDefaultShopId('category') && !$this->default_shop_id) {
                     $this->default_shop_id = min($shop_list_ids);
                 }
                 $result = true;
                 $query = "UPDATE " . $db->quoteName('#__jeproshop_category') . " SET " . $db->quoteName('n_left') . " = " . (int) $this->n_left . ", ";
                 $query .= $db->quoteName('n_right') . " = " . (int) $this->n_right . ", " . $db->quoteName('depth_level') . " = " . (int) $this->depth_level;
                 $query .= ", " . $db->quoteName('published') . " = " . (int) $category_data['published'] . ", " . $db->quoteName('default_shop_id') . " = " . (int) $this->default_shop_id;
                 $query .= ", " . $db->quoteName('is_root_category') . " = " . (int) $category_data['is_root_category'] . ", " . $db->quoteName('position') . " = ";
                 $query .= (int) $this->position . ", " . $db->quoteName('date_upd') . " = " . $db->quote($this->date_upd) . " WHERE " . $db->quoteName('category_id');
                 $query .= " = " . (int) $this->category_id;
                 $db->setQuery($query);
                 $result &= $db->query();
                 foreach ($shop_list_ids as $shop_id) {
                     $where = " WHERE " . $db->quoteName('category_id') . " = " . (int) $this->category_id . " AND " . $db->quoteName('shop_id') . " = " . (int) $shop_id;
                     $select = "SELECT " . $db->quoteName('category_id') . " FROM " . $db->quoteName('#__jeproshop_category_shop') . $where;
                     $db->setQuery($select);
                     $shop_exist = $db->loadObject()->category_id > 0;
                     if ($shop_exist) {
                         $query = "UPDATE " . $db->quoteName('#__jeproshop_category_shop') . " SET " . $db->quoteName('position') . " = " . (int) $this->position . $where;
                         $db->setQuery($query);
                         $result &= $db->query();
                     } elseif (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
                         $query = "INSERT INTO " . $db->quoteName('#__jeproshop_category_shop') . "(" . $db->quoteName('category_id') . ", " . $db->quoteName('shop_id') . ", " . $db->quoteName('position');
                         $query .= ") VALUES (" . (int) $this->category_id . ", " . (int) $shop_id . ", " . (int) $this->position . ")";
                         $db->setQuery($query);
                         $result &= $db->query();
                     }
                     foreach ($languages as $language) {
                         $where = " WHERE " . $db->quoteName('category_id') . " = " . (int) $this->category_id . " AND " . $db->quoteName('shop_id');
                         $where .= " = " . (int) $shop_id . " AND " . $db->quoteName('lang_id') . " = " . (int) $language->lang_id;
                         $select = "SELECT COUNT(*) FROM " . $db->quoteNAme('#__jeproshop_category_lang') . $where;
                         $db->setQuery($select);
                         $lang_exist = $db->loadResult();
                         if ($lang_exist) {
                             $query = "UPDATE " . $db->quoteName('#__jeproshop_category_lang') . " SET " . $db->quoteName('name') . " = " . $db->quote($category_data['name_' . $language->lang_id]) . ", ";
                             $query .= $db->quoteName('description') . " = " . $db->quote($category_data['description_' . $language->lang_id]) . ", " . $db->quoteName('link_rewrite') . " = ";
                             $query .= $db->quote($category_data['link_rewrite_' . $language->lang_id]) . ", " . $db->quoteName('meta_title') . " = " . $db->quote($category_data['meta_title_' . $language->lang_id]);
                             $query .= ", " . $db->quoteName('meta_keywords') . " = " . $db->quote($category_data['meta_keywords_' . $language->lang_id]) . ", " . $db->quoteName('meta_description');
                             $query .= " = " . $db->quote($category_data['meta_description_' . $language->lang_id]) . $where;
                         } else {
                             $query = "INSERT INTO " . $db->quoteName('#__jeproshop_category_lang') . " (" . $db->quoteName('name') . ", " . $db->quoteName('description') . ", " . $db->quoteName('link_rewrite');
                             $query .= ", " . $db->quoteName('meta_title') . ", " . $db->quoteName('meta_keywords') . ", " . $db->quoteName('meta_description') . ") VALUES (" . $db->quote($category_data['name_' . $language->lang_id]);
                             $query .= ", " . $db->quote($category_data['description_' . $language->lang_id]) . ", " . $db->quote($category_data['link_rewrite_' . $language->lang_id]) . ", ";
                             $query .= $db->quote($category_data['meta_title_' . $language->lang_id]) . ", " . $db->quote($category_data['meta_keywords_' . $language->lang_id]) . ", ";
                             $query .= $db->quote($category_data['meta_description_' . $language->lang_id]) . ") " . $where;
                         }
                         $db->setQuery($query);
                         $result &= $db->query();
                     }
                 }
                 if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree) {
                     JeproshopCategoryModelCategory::regenerateEntireNestedtree();
                     $this->recalculateLevelDepth($this->category_id);
                 }
             }
             $message = '';
             $link = 'index.php?option=com_jeproshop&view=category&category_id=' . (int) $this->category_id . '&task=edit' . JeproshopTools::getCategoryToken();
         } else {
             $message = '';
             $link = 'index.php?option=com_jeproshop&view=category&category_id=' . (int) $this->category_id . '&task=edit' . JeproshopTools::getCategoryToken();
         }
         $app->redirect($link, $message);
     }
 }
Ejemplo n.º 21
0
 /**
  * Load class supplier using identifier in $_GET (if possible)
  * otherwise return an empty supplier, or die
  *
  * @param boolean $opt Return an empty supplier if load fail
  * @return supplier|boolean
  */
 public function loadTaxRuleGroup($opt = false)
 {
     $app = JFactory::getApplication();
     $tax_rules_group_id = (int) $app->input->get('tax_rules_group_id');
     if ($tax_rules_group_id && JeproshopTools::isUnsignedInt($tax_rules_group_id)) {
         if (!$this->tax_rules_group) {
             $this->tax_rules_group = new JeproshopTaxRulesGroupModelTaxRulesGroup($tax_rules_group_id);
         }
         if (JeproshopTools::isLoadedObject($this->tax_rules_group, 'tax_rules_group_id')) {
             return true;
         }
         // throw exception
         JError::raiseError(500, 'The tax rules group cannot be loaded (or not found)');
         return false;
     } elseif ($opt) {
         if (!$this->tax_rules_group) {
             $this->tax_rules_group = new JeproshopTaxRulesGroupModelTaxRulesGroup();
         }
         return true;
     } else {
         $this->context->controller->has_errors = true;
         JError::raiseError(500, 'The tax cannot be loaded (the identifier is missing or invalid)');
         return false;
     }
 }
Ejemplo n.º 22
0
 public function delete()
 {
     if (!JeproshopTools::isUnsignedInt($this->customer_thread_id)) {
         return false;
     }
     $return = true;
     $db = JFactory::getDBO();
     $query = "SELECT " . $db->quoteNAme('customer_message_id') . " FROM " . $db->quoteName('#__jeproshop_customer_message') . " WHERE " . $db->quoteName('customer_thread_id') . " = " . (int) $this->customer_thread_id;
     $db->setQuery($query);
     $results = $db->loadObjectList();
     if (count($results)) {
         foreach ($results as $result) {
             $message = new JeproshopCustomerMessageModelCustomerMessage((int) $result->customer_message_id);
             if (!JeproshopTools::isLoadedObject($message, 'customer_thread_id')) {
                 $return = false;
             } else {
                 $return &= $message->delete();
             }
         }
     }
     $return &= parent::delete();
     return $return;
 }
Ejemplo n.º 23
0
 /**
  * Load list of groups and shops, and cache it
  *
  * @param bool $refresh
  */
 public static function cacheShops($refresh = false)
 {
     if (!is_null(self::$shops) && !$refresh) {
         return;
     }
     self::$shops = array();
     $db = JFactory::getDBO();
     $from = "";
     $where = "";
     $employee = JeproshopContext::getContext()->employee;
     // If the profile isn't a superAdmin
     if (JeproshopTools::isLoadedObject($employee, 'employee_id') && $employee->profile_id != _PS_ADMIN_PROFILE_) {
         $from .= " LEFT JOIN " . $db->quoteName('#__jeproshop_employee_shop') . " AS employee_shop ON employee_shop.shop_id = shop.shop_id";
         $where .= " AND employee_shop.employee_id = " . (int) $employee->employee_id;
     }
     $query = "SELECT shop_group.*, shop.*, shop_group.name AS group_name, shop.shop_name AS shop_name, ";
     $query .= " shop.published, shop_url.domain, shop_url.ssl_domain, shop_url.physical_uri, shop_url.";
     $query .= "virtual_uri FROM " . $db->quoteName('#__jeproshop_shop_group') . " AS shop_group LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_shop') . " AS shop ON shop.shop_group_id = shop_group.shop_group_id ";
     $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_shop_url') . " AS shop_url ON shop.shop_id =";
     $query .= " shop_url.shop_id AND shop_url.main = 1 " . $from . " WHERE shop.deleted = 0 AND shop_group.";
     $query .= "deleted = 0 " . $where . " ORDER BY shop_group.name, shop.shop_name";
     $db->setQuery($query);
     $results = $db->loadObjectList();
     if ($results) {
         foreach ($results as $row) {
             if (!isset(self::$shops[$row->shop_group_id])) {
                 self::$shops[$row->shop_group_id] = array('shop_group_id' => $row->shop_group_id, 'name' => $row->group_name, 'share_customer' => $row->share_customer, 'share_order' => $row->share_order, 'share_stock' => $row->share_stock, 'shops' => array());
                 self::$shops[$row->shop_group_id]['shops'][$row->shop_id] = $row;
                 /*array(
                 				'shop_id' => $row->shop_id,
                 				'shop_group_id' => $row->shop_group_id,
                 				'name' => $row->shop_name,
                 				'theme_id' => $row->theme_id,
                 				'category_id' => $row->category_id,
                 				'domain' => $row->domain,
                 				'ssl_domain' =>	$row->ssl_domain,
                 				'uri' =>  $row->physical_uri . $row->virtual_uri,
                 				'published' => $row->published
                 		);*/
             }
         }
     }
 }
Ejemplo n.º 24
0
 /**
  * Load class object using identifier in $_GET (if possible)
  * otherwise return an empty object, or die
  *
  * @param boolean $opt Return an empty object if load fail
  * @return object|boolean
  */
 public function loadObject($opt = false)
 {
     /*if (!isset($this->customer) || empty($this->customer))
     			return true;
     		*/
     $app = JFactory::getApplication();
     $customer_id = (int) $app->input->get('customer_id');
     if ($customer_id && JeproshopTools::isUnsignedInt($customer_id)) {
         if (!$this->customer) {
             $this->customer = new JeproshopCustomerModelCustomer($customer_id);
         }
         if (JeproshopTools::isLoadedObject($this->customer, 'customer_id')) {
             return $this->customer;
         }
         // throw exception
         //$this->errors[] = Tools::displayError('The object cannot be loaded (or found)');
         return false;
     } elseif ($opt) {
         if (!$this->customer) {
             $this->customer = new JeproshopCustomerModelCustomer();
         }
         return $this->customer;
     } else {
         $this->errors[] = Tools::displayError('The object cannot be loaded (the identifier is missing or invalid)');
         return false;
     }
 }
Ejemplo n.º 25
0
$context->language = $language;
$currency_id = $context->cookie->currency_id ? $context->cookie->currency_id : JeproshopSettingModelSetting::getValue('default_currency');
$context->currency = new JeproshopCurrencyModelCurrency($currency_id);
if (isset($context->cookie->customer_id) && (int) $context->customer_id) {
    $customer = new JeproshopCustomerModelCustomer($context->cookie->customer_id);
    if (!JeproshopTools::isLoadedObject($customer)) {
        $context->cookie->logout();
    } else {
        $customer->logged = TRUE;
        if ($customer->lang_id != $context->language->lang_id) {
            $customer->lang_id = $context->language->lang_id;
            $customer->update();
        }
    }
}
if (!isset($customer) || !JeproshopTools::isLoadedObject($customer)) {
    $customer = new JeproshopCustomerModelCustomer();
    if (JeproshopGroupModelGroup::isFeaturePublished()) {
        $customer->default_group_id = (int) JeproshopSettingModelSetting::getValue('unidentified_group');
    }
}
$customer->guest_id = $context->cookie->guest_id;
$context->customer = $customer;
/** controller and redirection */
$controller = JFactory::getApplication()->input->get('view');
if ($controller) {
    if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php')) {
        require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controller.php';
        require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php';
    } else {
        $controller = '';
Ejemplo n.º 26
0
 public function initOrderDetails()
 {
     $this->context->controller->init();
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
     //$this->initContent();
     $app = JFactory::getApplication();
     $order_id = $app->input->get('order_id');
     if (!$order_id || !JeproshopTools::isUnsignedInt($order_id)) {
         $this->errors[] = Tools::displayError('Order ID required');
     } else {
         $order = new JeproshopOrderModelOrder($order_id);
         if (JeproshopTools::isLoadedObject($order, 'order_id') && $order->customer_id == $this->context->customer->customer_id) {
             $order_status_id = (int) $order->getCurrentState();
             $carrier = new JeproshopCarrierModelCarrier((int) $order->carrier_id, (int) $order->lang_id);
             $invoiceAddress = new JeproshopAddressModelAddress((int) $order->address_invoice_id);
             $deliveryAddress = new JeproshopAddressModelAddress((int) $order->address_delivery_id);
             $invoice_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($invoiceAddress->country_id);
             $delivery_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($deliveryAddress->country_id);
             $invoiceAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($invoiceAddress, $invoice_address_fields);
             $deliveryAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($deliveryAddress, $delivery_address_fields);
             if ($order->total_discounts > 0) {
                 $oldTotal = (double) ($order->total_paid - $order->total_discounts);
                 $this->assignRef('old_total', $oldTotal);
             }
             $products = $order->getProducts();
             /* DEPRECATED: customizedDatas @since 1.5 */
             $customizedDatas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $order->cart_id);
             JeproshopProductModelProduct::addCustomizationPrice($products, $customizedDatas);
             JeproshopOrderReturnModelOrderReturn::addReturnedQuantity($products, $order->order_id);
             $customer = new JeproshopCustomerModelCustomer($order->customer_id);
             $this->assignRef('order', $order);
             $isReturnable = (int) $order->isReturnable();
             $this->assignRef('return_allowed', $isReturnable);
             $this->assignRef('currency', new JeproshopCurrencyModelCurrency($order->currency_id));
             $order_status_id = (int) $order_status_id;
             $this->assignRef('order_status_id', $order_status_id);
             $invoiceAllowed = (int) JeproshopSettingModelSetting::getValue('invoice_allowed');
             $this->assignRef('invoice_allowed', $invoiceAllowed);
             $invoice = JeproshopOrderStatusModelOrderStatus::invoiceAvailable($order_status_id) && count($order->getInvoicesCollection());
             $this->assignRef('invoice', $invoice);
             $this->assignRef('order_history', $order->getHistory($this->context->language->lang_id, false, true));
             $this->assignRef('products', $products);
             $this->assignRef('discounts', $order->getCartRules());
             $this->assignRef('carrier', $carrier);
             $this->assignRef('invoice_address', $invoiceAddress);
             $this->assignRef('invoice_status', JeproshopTools::isLoadedObject($invoiceAddress, 'address_id') && $invoiceAddress->state_id ? new JeproshopStatusModelStatus($invoiceAddress->state_id) : false);
             $this->assignRef('delivery_address', $deliveryAddress);
             $this->assignRef('invoice_address_fields', $invoice_address_fields);
             $this->assignRef('delivery_address_fields', $delivery_address_fields);
             $this->assignRef('invoice_address_format_values', $invoiceAddressFormatValues);
             $this->assignRef('delivery_address_format_values', $deliveryAddressFormatValues);
             $this->assignRef('delivery_status', JeproshopTools::isLoadedObject($deliveryAddress, 'address_id') && $deliveryAddress->state_id ? new JeproshopStatusModelStatus($deliveryAddress->state_id) : false);
             $this->assignRef('messages', JeproshopCustomerMessageModelCustomerMessage::getMessagesByOrderId((int) $order->order_id, false));
             $files = JeproshopProductModelProduct::CUSTOMIZE_FILE;
             $this->assignRef('CUSTOMIZE_FILE', $files);
             $text_fields = JeproshopProductModelProduct::CUSTOMIZE_TEXT_FIELD;
             $this->assignRef('CUSTOMIZE_TEXT_FIELD', $text_fields);
             //$this->assignRef('isRecyclable', JeproshopSettingModelSetting::getValue('PS_RECYCLABLE_PACK'));
             $this->assignRef('use_tax', JeproshopSettingModelSetting::getValue('use_tax'));
             $group_use_tax = JeproshopGroupModelGroup::getPriceDisplayMethod($customer->default_group_id) == COM_JEPROSHOP_TAX_INCLUDED;
             $this->assignRef('group_use_tax', $group_use_tax);
             $this->assignRef('display_price', JeproshopSettingModelSetting::getValue('display_price'));
             /* DEPRECATED: customizedDatas @since 1.5 */
             $this->assignRef('customizedDatas', $customizedDatas);
             $reordering_allowed = (int) JeproshopSettingModelSetting::getValue('enable_history_reordering');
             $this->assignRef('reordering_allowed', $reordering_allowed);
             /*
                             $this->context->smarty->assign(array(
                                 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->state_id) ? new State($addressDelivery->id_state) : false,
                                 'is_guest' => false,
                                 'messages' => CustomerMessage::getMessagesByOrderId((int)($order->id), false),
                                 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
                                 'CUSTOMIZE_TEXT_FIELD' => Product::CUSTOMIZE_TEXT_FIELD,
                                 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'),
                                 'use_tax' => Configuration::get('PS_TAX'),
                                 'group_use_tax' => (Group::getPriceDisplayMethod($customer->default_group_id) == PS_TAX_INC),
                                 /* DEPRECATED: customizedDatas @since 1.5 * /
                                 'customizedDatas' => $customizedDatas,
                                 /* DEPRECATED: customizedDatas @since 1.5 * /
             
                             )); */
             if ($carrier->url && $order->shipping_number) {
                 $this->assignRef('followup', str_replace('@', $order->shipping_number, $carrier->url));
             }
             /*               $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order)));
                             Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order)); */
             unset($carrier, $addressInvoice, $addressDelivery);
         } else {
             $this->errors[] = Tools::displayError('This order cannot be found.');
         }
         unset($order);
     }
     //$this->setTemplate(_PS_THEME_DIR_.'order-detail.tpl');
 }
Ejemplo n.º 27
0
 public function update_message()
 {
     $app = JFactory::getApplication();
     $order_id = $app->input->get('order_id');
     $customer_id = $app->input->get('customer_id');
     $order = new JeproshopOrderModelOrder($order_id);
     if (isset($order)) {
         if ($this->viewAccess()) {
             $customer = new JeproshopCustomerModelCustomer($customer_id);
             if (!JeproshopTools::isLoadedObject($customer, 'customer_id')) {
                 JError::raiseError(JText::_('COM_JEPROSHOP_CUSTOMER_IS_INVALID_MESSAGE'));
             } elseif (!$inputMessage) {
                 JError::raiseError(JText::_('COM_JEPROSHOP_THE_MESSAGE_CANNOT_BE_BLANK_MESSAGE'));
             } else {
                 /** Get Message rules anf check fields validity */
                 $rules = JeproshopMessageModelMessage::getValidationRules();
                 foreach ($rules->required as $field) {
                     $value = $app->input->get($field) == false;
                     if ($value && (string) $value != '0') {
                         if ($order_id || $field != 'passwd') {
                             JError::raiseError($field . ' ' . JText::_('COM_JEPROSHOP_IS_REQUIRED_FIELD_MESSAGE'));
                         }
                     }
                 }
                 foreach ($rules->size as $field => $maxLength) {
                     if ($app->input->get($field) && strlen($field) > $maxLength) {
                         JError::raiseError($field . ' ' . JText::_('COM_JEPROSHOP_FIELD_IS_TOO_LONG_LABEL') . ' ' . $maxLength . ' ' . JText::_('COM_JEPROSHOP_MAX_CHARS_LABEL'));
                     }
                 }
                 foreach ($rules->validate as $field => $function) {
                     if ($app->input->get($field)) {
                         if (!JeproshopTools::$function()) {
                             JError::raiseError(JText::_('COm_JEPROSHOP_FIELD_IS_INVALID_LABEL'));
                         }
                     }
                 }
                 if (12) {
                     $customer_thread_id = JeproshopCustomerThreadModelCustomerThread::getCustomerThreadIdByEmailAndOrderId($customer->email, $order->order_id);
                     if (!$customer_thread_id) {
                         $customerThread = new JeproshopCustomerThreadModelCustomerThread();
                         $customerThread->contact_id = 0;
                         $customerThread->customer_id = (int) $order->customer_id;
                         $customerThread->shop_id = (int) $context->shop->shop_id;
                         $customerThread->order_id = (int) $order->order_id;
                         $customerThread->lang_id = (int) $context->language->lang_id;
                         $customerThread->email = $customer->email;
                         $customerThread->status = 'open';
                         $customerThread->token = JeproshopTools::passwdGen(12);
                         $customerThread->add();
                     } else {
                         $customerThread = new JeproshopCustomerThreadModelCustomerThread((int) $customer_thread_id);
                     }
                     $customerMessage = new JeproshopCustomerMessageModelCustomerMessage();
                     $customerMessage->customer_thread_id = $customerThread->customer_thread_id;
                     $customerMessage->employee_id = (int) $context->employee->employee_id;
                     $customerMessage->message = $app->input->get('message');
                     $customerMessage->private = $app->input->get('visibility');
                     if (!$customerMessage->add()) {
                         JError::raiseError(JText::_('COM_JEPROSHOP_AN_ERROR_WHILE_'));
                     } elseif ($customerMessage->private) {
                         $app->redirect('index.php?option=com_jeproshop&view=order&task=view&order_id=' . (int) $order->order_id);
                     } else {
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 28
0
 public static function getTotalCart($cart_id, $use_tax_display = false, $type = JeproshopCartModelCart::BOTH)
 {
     $cart = new JeproshopCartModelCart($cart_id);
     if (!JeproshopTools::isLoadedObject($cart, 'cart_id')) {
         die(Tools::displayError());
     }
     $with_taxes = $use_tax_display ? $cart->_taxCalculationMethod != COM_JEPROSHOP_TAX_EXCLUDED : true;
     return JeproshopTools::displayPrice($cart->getOrderTotal($with_taxes, $type), JeproshopCurrencyModelCurrency::getCurrencyInstance((int) $cart->currency_id), false);
 }
Ejemplo n.º 29
0
 /**
  * Load class supplier using identifier in $_GET (if possible)
  * otherwise return an empty supplier, or die
  *
  * @param boolean $opt Return an empty supplier if load fail
  * @return supplier|boolean
  */
 public function loadObject($opt = false)
 {
     $app = JFactory::getApplication();
     $manufacturer_id = (int) $app->input->get('manufacturer_id');
     if ($manufacturer_id && JeproshopTools::isUnsignedInt($manufacturer_id)) {
         if (!$this->manufacturer) {
             $this->manufacturer = new JeproshopManufacturerModelManufacturer($manufacturer_id);
         }
         if (JeproshopTools::isLoadedObject($this->manufacturer, 'manufacturer_id')) {
             return $this->manufacturer;
         }
         // throw exception
         JError::raiseError(500, 'The manufacturer cannot be loaded (or found)');
         return false;
     } elseif ($opt) {
         if (!$this->manufacturer) {
             $this->manufacturer = new JeproshopManufacturerModelManufacturer();
         }
         return $this->manufacturer;
     } else {
         $this->errors[] = Tools::displayError('The manufacturer cannot be loaded (the identifier is missing or invalid)');
         return false;
     }
 }
Ejemplo n.º 30
0
 /**
  * Process submit on an account
  */
 public function register()
 {
     $app = JFactory::getApplication();
     $context = JeproshopContext::getContext();
     $view = $app->input->get('view');
     $viewClass = $this->getView($view, JFactory::getDocument()->getType());
     $input = JRequest::get('get');
     $jsonData = array("success" => true);
     $errors = array();
     $task = $app->input->get('task');
     if (isset($task) && $task == 'register') {
         $emailCreate = 1;
         $viewClass->assign('email_create', 1);
     }
     $isNewCustomer = isset($input['is_new_customer']) ? 1 : 0;
     if (!$isNewCustomer && !JeproshopSettingModelSetting::getValue('enable_guest_checkout')) {
         $this->has_errors = true;
         $errors[] = JText::_('You cannot create a guest account..');
     }
     $guestEmail = isset($input['guest_email']) ? $input['guest_email'] : '';
     $email = isset($input['email']) ? $input['email'] : '';
     if (isset($guestEmail) && $guestEmail) {
         $email = $guestEmail;
     }
     // Checked the user address in case he changed his email address
     if (JeproshopTools::isEmail($email) && !empty($email)) {
         if (JeproshopCustomerModelCustomer::customerExists($email)) {
             $this->has_errors = true;
             $errors[] = JText::_('An account using this email address has already been registered.');
             //, false);
         }
     }
     // Preparing customer
     $customer = new JeproshopCustomerModelCustomer();
     $lastNameAddress = isset($input['lastname']) ? $input['lastname'] : '';
     $firstNameAddress = isset($input['firstname']) ? $input['firstname'] : '';
     $lastname = isset($input['customer_lastname']) ? $input['customer_lastname'] : $lastNameAddress;
     $firstname = isset($input['customer_firstname']) ? $input['customer_firstname'] : $firstNameAddress;
     $addresses_types = array('address');
     $inputInvoiceAddress = isset($input['invoice_address']) ? $input['invoice_address'] : 0;
     if (JeproshopSettingModelSetting::getValue('order_process_type') == 'standard' && JeproshopSettingModelSetting::getValue('enable_guest_checkout') && $inputInvoiceAddress) {
         $addresses_types[] = 'invoice_address';
     }
     $error_phone = false;
     $phone = isset($input['phone']) ? $input['phone'] : null;
     $phone_mobile = isset($input['phone_mobile']) ? $input['phone_mobile'] : null;
     if (JeproshopSettingModelSetting::getValue('one_phone_at_least')) {
         if ($task == 'submitGuestAccount' || !$isNewCustomer) {
             if (!$phone && !$phone_mobile) {
                 $error_phone = true;
             }
         } elseif ((JeproshopSettingModelSetting::getValue('registration_process_type') != 'account_only' && JeproshopSettingModelSetting::getValue('order_process_type') != 'standard' || JeproshopSettingModelSetting::getValue('order_process_type') != 'standard' && !$viewClass->email_create || JeproshopSettingModelSetting::getValue('registration_process_type') != 'account_only' && $viewClass->email_create) && (!$phone && !$phone_mobile)) {
             $error_phone = true;
         }
     }
     if ($error_phone) {
         $this->has_errors = true;
         $errors[] = JText::_('You must register at least one phone number.');
     }
     $errors = array_unique(array_merge($errors, $customer->validateController()));
     if (JeproshopSettingModelSetting::getValue('registration_process_type') == 'account_only' && !$this->use_ajax && !Tools::isSubmit('submitGuestAccount')) {
         if (!$this->has_errors) {
             if (isset($input['newsletter']) && $input['newsletter']) {
                 $this->processCustomerNewsletter($customer);
             }
             $customer->firstname = JeproshopTools::ucwords($customer->firstname);
             $customer->birthday = empty($input['year']) ? '' : (int) $input['year'] . '-' . (int) $input['month'] . '-' . (int) $input['day'];
             if (!JeproshopTools::isBirthDate($customer->birthday)) {
                 $this->has_errors = true;
                 $errors[] = JText::_('Invalid date of birth.');
             }
             // New Guest customer
             $customer->is_guest = isset($isNewCustomer) ? !$isNewCustomer : 0;
             $customer->published = 1;
             if (!$this->has_errors) {
                 if ($customer->add()) {
                     if (!$customer->is_guest) {
                         if (!$this->sendConfirmationMail($customer)) {
                             $this->has_errors = true;
                             $errors[] = JText::_('The email cannot be sent.');
                         }
                     }
                     $this->updateContext($customer);
                     $context->cart->update();
                     Hook::exec('actionCustomerAccountAdd', array('_POST' => $_POST, 'newCustomer' => $customer));
                     if ($this->use_ajax) {
                         $return = array('hasError' => $this->has_errors, 'errors' => $errors, 'isSaved' => true, 'customer_id' => (int) $context->cookie->customer_id, 'delivery_address_id' => $context->cart->delivery_address_id, 'invoice_address_id' => $context->cart->invoice_address_id, 'token' => Tools::getToken(false));
                         echo json_encode($return);
                         $app->close();
                     }
                     if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) {
                         $app->redirect(html_entity_decode($back));
                     }
                     // redirection: if cart is not empty : redirection to the cart
                     if (count($context->cart->getProducts(true)) > 0) {
                         $app->redirect('index.php?option=com_jeproshop&view=order&multi-shipping=' . (int) Tools::getValue('multi-shipping'));
                     } else {
                         Tools::redirect('index.php?controller=' . ($this->authRedirection !== false ? urlencode($this->authRedirection) : 'my-account'));
                     }
                 } else {
                     $this->has_errors = true;
                     JText::_('An error occurred while creating your account.');
                 }
             }
         }
     } else {
         // if registration type is in one step, we save the address
         $input['lastname'] = $lastNameAddress;
         $input['firstname'] = $firstNameAddress;
         $post_back = $_POST;
         // Preparing addresses
         foreach ($addresses_types as $addresses_type) {
             $address_type = new JeproshopAddressModelAddress();
             $address_type->customer_id = 1;
             if ($addresses_type == 'invoice_address') {
                 foreach ($input as $key => &$post) {
                     if (isset($input['invoice_' . $key])) {
                         $post = $input['invoice_' . $key];
                     }
                 }
             }
             $this->has_errors = true;
             $errors = array_unique(array_merge($errors, $address_type->validateController()));
             if ($addresses_type == 'invoice_address') {
                 $_POST = $post_back;
             }
             if (!($country = new JeproshopCountryModelCountry($address_type->country_id)) || !JeproshopTools::isLoadedObject($country, 'country_id')) {
                 $this->has_errors = true;
                 $errors[] = JText::_('Country cannot be loaded with address->id_country');
             }
             if (!$country->published) {
                 $this->has_errors = true;
                 $errors[] = JText::_('This country is not active.');
             }
             $postcode = isset($input['postcode']) ? $input['postcode'] : '';
             /* Check zip code format */
             if ($country->zip_code_format && !$country->checkZipCode($postcode)) {
                 $this->has_errors = true;
                 $errors[] = JText::_('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s');
                 //, str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))));
             } elseif (empty($postcode) && $country->need_zip_code) {
                 $this->has_errors = true;
                 $errors[] = JText::_('A Zip / Postal code is required.');
             } elseif ($postcode && !JeproshopTools::isPostCode($postcode)) {
                 $this->has_errors = true;
                 $errors[] = JText::_('The Zip / Postal code is invalid.');
             }
             $identificationNumber = isset($input['dni']) ? $input['dni'] : '';
             if ($country->need_identification_number && (!$identificationNumber || !JeproshopTools::isDniLite($identificationNumber))) {
                 $this->has_errors = true;
                 $errors[] = JText::_('The identification number is incorrect or has already been used.');
             } elseif (!$country->need_identification_number) {
                 $address_type->dni = null;
             }
             if ($task == 'register' || $task == 'submitGuestAccount') {
                 if (!($country = new JeproshopCountryModelCountry($address_type->country_id, JeproshopSettingModelSetting::getValue('default_lang'))) || !JeproshopTools::isLoadedObject($country, 'country_id')) {
                     $this->has_errors = true;
                     $errors[] = JText::_('Country is invalid');
                 }
             }
             $contains_state = isset($country) && is_object($country) ? (int) $country->contains_states : 0;
             $state_id = isset($address_type) && is_object($address_type) ? (int) $address_type->state_id : 0;
             if (($task == 'register' || $task == 'submitGuestAccount') && $contains_state && !$state_id) {
                 $this->has_errors = true;
                 $errors[] = JText::_('This country requires you to choose a State.');
             }
         }
     }
     $days = isset($input['day']) ? $input['day'] : '';
     $months = isset($input['month']) ? $input['month'] : '';
     $years = isset($input['year']) ? $input['year'] : '';
     if (!@checkdate($months, $days, $years) && !($months == '' && $days == '' && $years == '')) {
         $this->has_errors = true;
         $errors[] = JText::_('Invalid date of birth');
     }
     if ($this->has_errors) {
         //todo set negation
         $email = isset($input['email']) ? $input['email'] : '';
         if (JeproshopCustomerModelCustomer::customerExists($email)) {
             $this->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. ');
         }
         if (isset($input['newsletter'])) {
             $this->processCustomerNewsletter($customer);
         }
         $customer->birthday = empty($years) ? '' : (int) $years . '-' . (int) $months . '-' . (int) $days;
         if (!JeproshopTools::isBirthDate($customer->birthday)) {
             $this->has_errors = true;
             $errors[] = JText::_('Invalid date of birth');
         }
         echo $input['passwd'] . ' on line ' . __LINE__;
         if ($this->has_errors) {
             //todo reset negation
             $customer->published = 1;
             // New Guest customer
             if (isset($isNewCustomer)) {
                 $customer->is_guest = !$isNewCustomer ? 1 : 0;
             } else {
                 $customer->is_guest = 0;
             }
             if (!$customer->add()) {
                 $this->has_errors = true;
                 $errors[] = JText::_('An error occurred while creating your account.');
             } else {
                 foreach ($addresses_types as $addresses_type) {
                     $address_type->customer_id = (int) $customer->customer_id;
                     if ($addresses_type == 'invoice_address') {
                         foreach ($input as $key => &$post) {
                             if (isset($input['invoice_' . $key])) {
                                 $post = $input['invoice_' . $key];
                             }
                         }
                     }
                     $errors = array_unique(array_merge($errors, $address_type->validateController()));
                     if ($address_type == 'invoice_address') {
                         $input = $post_back;
                     }
                     if (!$this->has_errors && (JeproshopSettingModelSetting::getValue('registration_process_type') || $this->use_ajax || $task == 'submitGuestAccount') && !$address_type->add()) {
                         $this->has_errors = true;
                         $errors[] = JText::_('An error occurred while creating your address.');
                     }
                 }
                 if (!$this->has_errors) {
                     if (!$customer->is_guest) {
                         $context->customer = $customer;
                         $customer->cleanGroups();
                         // we add the guest customer in the default customer group
                         $customer->addGroups(array((int) JeproshopSettingModelSetting::getValue('customer_group')));
                         if (!$this->sendConfirmationMail($customer)) {
                             $this->has_errors = true;
                         }
                         $errors[] = JText::_('The email cannot be sent.');
                     } else {
                         $customer->cleanGroups();
                         // we add the guest customer in the guest customer group
                         $customer->addGroups(array((int) JeproshopSettingModelSetting::getValue('guest_group')));
                     }
                     $this->updateContext($customer);
                     $context->cart->delivery_address_id = (int) JeproshopAddressModelAddress::getCustomerFirstAddressId((int) $customer->customer_id);
                     $context->cart->invice_address_id = (int) JeproshopAddressModelAddress::getCustomerFirstAddressId((int) $customer->customer_id);
                     if (isset($invoice_address) && JeproshopTools::isLoadedObject($invoice_address, 'address_id')) {
                         $context->cart->invoice_address_id = (int) $invoice_address->address_id;
                     }
                     if ($this->use_ajax && JeproshopSettingModelSetting::getValue('order_process_type') != 'standard') {
                         $delivery_option = array((int) $context->cart->delivery_address_id => (int) $context->cart->carrier_id . ',');
                         $context->cart->setDeliveryOption($delivery_option);
                     }
                     // If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
                     $context->cart->update();
                     // Avoid articles without delivery address on the cart
                     $context->cart->autosetProductAddress();
                     Hook::exec('actionCustomerAccountAdd', array('_POST' => $_POST, 'newCustomer' => $customer));
                     if ($this->use_ajax) {
                         $return = array('hasError' => $this->has_errors, 'errors' => $errors, 'isSaved' => true, 'customer_id' => (int) $context->cookie->customer_id, 'id_address_delivery' => $context->cart->delivery_address_id, 'id_address_invoice' => $context->cart->invoice_address_id, 'token' => Tools::getToken(false));
                         echo json_encode($return);
                         $app->close();
                     }
                     // if registration type is in two steps, we redirect to register address
                     if (JeproshopSettingModelSetting::getValue('registration_process_type') == 'account_only' && !$this->use_ajax && $task != 'submitGuestAccount') {
                         $app->redirect('index.php?option=com_jeproshop&view=address');
                     }
                     if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) {
                         Tools::redirect(html_entity_decode($back));
                     }
                     // redirection: if cart is not empty : redirection to the cart
                     if (count($context->cart->getProducts(true)) > 0) {
                         $app->redirect('index.php?option=com_jeproshop&view=order&multi-shipping=' . (int) $input['multi-shipping']);
                         // else : redirection to the account
                     } else {
                         //todo$app->redirect('index.php?controller=' . (($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
                     }
                 }
             }
         }
     }
     if ($this->has_errors) {
         //for retro compatibility to display guest account creation form on authentication page
         if ($task == 'guest_account') {
             $_GET['display_guest_checkout'] = 1;
         }
         if (!$isNewCustomer) {
             unset($_POST['passwd']);
         }
         if ($this->use_ajax) {
             $return = array('hasError' => $this->has_errors, 'errors' => $errors, 'isSaved' => false, 'customer_id' => 0);
             echo json_encode($return);
             $app->close();
         }
         $viewClass->assign('account_error', $this->has_errors);
     }
     echo json_encode($jsonData);
     $app->close();
 }