Exemplo n.º 1
0
 public function initialize()
 {
     parent::initialize();
     // Check if we can add a customer
     if (JeproshopShopModelShop::isFeaturePublished() && (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_ALL || JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_GROUP)) {
         $this->can_add_customer = false;
     }
 }
Exemplo n.º 2
0
 public function initialize()
 {
     parent::initialize();
     /*if (!Tools::getIsset('step') && $context->customer->isLogged() && !$this->use_ajax)
                 Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
     
             if (Tools::getValue('create_account'))
                 $this->create_account = true;*/
 }
Exemplo n.º 3
0
 public function initialize()
 {
     parent::initialize();
     // Send noindex to avoid ghost carts by bots
     header("X-Robots-Tag: noindex, nofollow", true);
     if ($this->has_errors) {
         echo 'mon cul';
     }
     $app = JFactory::getApplication();
     $this->product_id = (int) $app->input->get('product_id', null);
     $this->product_id = (int) $app->input->get('product_attribute_id', 0);
     $this->customization_id = (int) $app->input->get('customization_id');
     $this->quantity = (int) $app->input->get('quantity', 1);
     $this->address_delivery_id = (int) $app->input->get('address_delivery_id');
 }
Exemplo n.º 4
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');
         }
     }
 }
Exemplo n.º 5
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');
     }
 }
Exemplo 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')));*/
 }