Esempio n. 1
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     /*
     		$price_auth = ($this->params->get('price_restrict', '0') == '1' && $user->guest) ? false : true;
     		
     		if (!$price_auth) {
     			$return_url = base64_encode(DJCatalogHelperRoute::getCartRoute());
     			$app->redirect(JRoute::_('index.php?option=com_users&view=login&return='.$return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
     			return true;
     		}*/
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     $this->total = $this->basket->getTotal();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
Esempio n. 2
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     /*
     		$price_auth = ($this->params->get('price_restrict', '0') == '1' && $user->guest) ? false : true;
     		
     		if (!$price_auth) {
     			$return_url = base64_encode(DJCatalogHelperRoute::getCartRoute());
     			$app->redirect(JRoute::_('index.php?option=com_users&view=login&return='.$return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
     			return true;
     		}*/
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     $this->total = $this->basket->getTotal();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if (count($this->items)) {
         JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
         $itemsModel = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
         $parents = array();
         foreach ($this->items as $item) {
             if ($item->parent_id > 0) {
                 $parents[] = $item->parent_id;
             }
         }
         if (count($parents) > 0) {
             $state = $itemsModel->getState();
             $itemsModel->setState('list.start', 0);
             $itemsModel->setState('list.limit', 0);
             $itemsModel->setState('filter.catalogue', false);
             $itemsModel->setState('list.ordering', 'i.name');
             $itemsModel->setState('list.direction', 'asc');
             $itemsModel->setState('filter.parent', '*');
             $itemsModel->setState('filter.state', '3');
             $itemsModel->setState('filter.item_ids', $parents);
             $parentItems = $itemsModel->getItems();
             foreach ($this->items as $id => $item) {
                 if ($item->parent_id > 0 && isset($parentItems[$item->parent_id])) {
                     $this->items[$id]->parent = $parentItems[$item->parent_id];
                 } else {
                     $this->items[$id]->parent = false;
                 }
             }
         }
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
Esempio n. 3
0
 /**
  * 
  * Retrieves or creates DJCatalog2HelperCart object
  * @param bool $from_storage
  * @param array $cart_items
  * @return DJCatalog2HelperCart
  */
 public static function getInstance($from_storage = true, $cart_items = array())
 {
     $app = JFactory::getApplication();
     if ($from_storage) {
         $stored_items = $app->getUserState('com_djcatalog2.cart.items', array());
         if (empty($cart_items) && !empty($stored_items)) {
             $cart_items = $stored_items;
         }
     }
     $hash = md5(serialize($cart_items));
     if (isset(self::$baskets[$hash])) {
         return self::$baskets[$hash];
     }
     $basket = new Djcatalog2HelperCart();
     if (!empty($cart_items)) {
         JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
         $model = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
         $state = $model->getState();
         $model->setState('list.start', 0);
         $model->setState('list.limit', 0);
         $user = Djcatalog2Helper::getUserProfile();
         if (isset($user->user_group_id)) {
             $model->setState('filter.customergroup', $user->user_group_id);
         }
         $model->setState('filter.catalogue', false);
         $model->setState('list.ordering', 'i.name');
         $model->setState('list.direction', 'asc');
         $model->setState('filter.parent', '*');
         $model->setState('filter.state', '3');
         $item_ids = array_keys($cart_items);
         $model->setState('filter.item_ids', $item_ids);
         $basket->items = $model->getItems();
         $basket->quantities = $cart_items;
     }
     $basket->recalculate();
     self::$baskets[$hash] = $basket;
     return self::$baskets[$hash];
 }
Esempio n. 4
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $this->model = $this->getModel();
     if ($this->params->get('cart_query_enabled', '1') != '1') {
         throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $auth = $this->params->get('cart_query_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->form = $this->get('Form');
     $data = JArrayHelper::fromObject($user_profile, false);
     $post_data = (array) $app->getUserState('com_djcatalog2.query.data', array());
     if (!empty($post_data)) {
         foreach ($post_data as $k => $v) {
             $data[$k] = $v;
         }
     }
     $this->user_valid = $this->model->validate($this->form, array('djcatalog2profile' => $data));
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     $this->_prepareDocument();
     parent::display($tpl);
 }
Esempio n. 5
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $price_auth = $this->params->get('price_restrict', '0') == '1' && $user->guest ? false : true;
     if (!$price_auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getCartRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     if (empty($user_profile) || empty($user_profile->id)) {
         $return_url = base64_encode(DJCatalogHelperRoute::getCheckoutRoute());
         $app->setUserState('com_users.edit.profile.redirect', DJCatalogHelperRoute::getCheckoutRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=profile&layout=edit&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_FILLIN_BILLING_DETAILS'));
         return true;
     }
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
Esempio n. 6
0
 protected function allowQuery()
 {
     $app = JFactory::getApplication();
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     $params = JComponentHelper::getParams('com_djcatalog2');
     if ($params->get('cart_query_enabled', '1') != '1') {
         throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $auth = $params->get('cart_query_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return false;
     }
     $basket = Djcatalog2HelperCart::getInstance(true);
     $basket->recalculate();
     if (empty($basket) || !$basket->getItems()) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return false;
     }
     return true;
 }
Esempio n. 7
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $model = JModelLegacy::getInstance('Order', 'Djcatalog2Model', array());
     $this->setModel($model, true);
     $this->model = $this->getModel();
     if ($this->params->get('cart_enabled', '1') != '1') {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     $auth = $this->params->get('cart_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getCheckoutRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     foreach ($this->basket->items as $item) {
         if ($item->_prices['base']['display'] == 0.0 || !$item->onstock || floatval($item->stock) == 0.0) {
             $app->redirect(JRoute::_(DJCatalogHelperRoute::getCartRoute(), false), JText::sprintf('COM_DJCATALOG2_CHECKOUT_EMPTY_PRICES', JRoute::_('index.php?option=com_djcatalog2&task=cart.clearfree')));
             return true;
         }
     }
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     if (count($this->items)) {
         JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
         $itemsModel = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
         $parents = array();
         foreach ($this->items as $item) {
             if ($item->parent_id > 0) {
                 $parents[] = $item->parent_id;
             }
         }
         if (count($parents) > 0) {
             $state = $itemsModel->getState();
             $itemsModel->setState('list.start', 0);
             $itemsModel->setState('list.limit', 0);
             $itemsModel->setState('filter.catalogue', false);
             $itemsModel->setState('list.ordering', 'i.name');
             $itemsModel->setState('list.direction', 'asc');
             $itemsModel->setState('filter.parent', '*');
             $itemsModel->setState('filter.state', '3');
             $itemsModel->setState('filter.item_ids', $parents);
             $parentItems = $itemsModel->getItems();
             foreach ($this->items as $id => $item) {
                 if ($item->parent_id > 0 && isset($parentItems[$item->parent_id])) {
                     $this->items[$id]->parent = $parentItems[$item->parent_id];
                 } else {
                     $this->items[$id]->parent = false;
                 }
             }
         }
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->form = $this->get('Form');
     $data = JArrayHelper::fromObject($user_profile, false);
     $postOrder = (array) $app->getUserState('com_djcatalog2.order.data', array());
     if (!empty($postOrder)) {
         foreach ($postOrder as $k => $v) {
             $data[$k] = $v;
         }
     }
     $this->user_valid = $this->model->validate($this->form, array('djcatalog2profile' => $data), 'djcatalog2profile');
     $this->billing_valid = $this->model->validate($this->form, array('djcatalog2billing' => $data), 'djcatalog2billing');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('djcatalog2payment');
     JPluginHelper::importPlugin('djcatalog2delivery');
     $deliveryMethods = $model->getDeliveryMethods();
     $paymentMethods = $model->getPaymentMethods('*');
     $deliveryRes = array();
     $paymentRes = array();
     foreach ($deliveryMethods as &$deliveryObject) {
         $params = new JRegistry();
         $params->loadString($deliveryObject->params, 'JSON');
         $deliveryObject->params = $params;
         $deliveryRes[$deliveryObject->id] = $dispatcher->trigger('onDJC2CheckoutDetailsDisplay', array('com_djcatalog2.checkout.delivery', $deliveryObject));
     }
     unset($deliveryObject);
     foreach ($paymentMethods as &$paymentObject) {
         $params = new JRegistry();
         $params->loadString($paymentObject->params, 'JSON');
         $paymentObject->params = $params;
         $paymentRes[$paymentObject->id] = $dispatcher->trigger('onDJC2CheckoutDetailsDisplay', array('com_djcatalog2.checkout.payment', $paymentObject));
     }
     unset($paymentObject);
     $this->delivery_info = $deliveryRes;
     $this->payment_info = $paymentRes;
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     $this->product_total = $this->basket->getProductTotal();
     $this->_prepareDocument();
     parent::display($tpl);
 }
Esempio n. 8
0
 * (at your option) any later version.
 *
 * DJ-Catalog2 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with DJ-Catalog2. If not, see <http://www.gnu.org/licenses/>.
 *
 */
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
$user = JFactory::getUser();
$cart = Djcatalog2HelperCart::getInstance();
$items = $cart->getItems();
//print_r($items);
?>

<?php 
//if ($this->params->get( 'show_page_heading', 1)) {
?>
<h1 class="componentheading<?php 
echo $this->params->get('pageclass_sfx');
?>
">
	<?php 
echo $this->escape($this->params->get('page_heading'));
?>
</h1>
Esempio n. 9
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $this->model = $this->getModel();
     if ($this->params->get('cart_query_enabled', '1') != '1') {
         throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $auth = $this->params->get('cart_query_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     if (count($this->items)) {
         JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
         $itemsModel = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
         $parents = array();
         foreach ($this->items as $item) {
             if ($item->parent_id > 0) {
                 $parents[] = $item->parent_id;
             }
         }
         if (count($parents) > 0) {
             $state = $itemsModel->getState();
             $itemsModel->setState('list.start', 0);
             $itemsModel->setState('list.limit', 0);
             $itemsModel->setState('filter.catalogue', false);
             $itemsModel->setState('list.ordering', 'i.name');
             $itemsModel->setState('list.direction', 'asc');
             $itemsModel->setState('filter.parent', '*');
             $itemsModel->setState('filter.state', '3');
             $itemsModel->setState('filter.item_ids', $parents);
             $parentItems = $itemsModel->getItems();
             foreach ($this->items as $id => $item) {
                 if ($item->parent_id > 0 && isset($parentItems[$item->parent_id])) {
                     $this->items[$id]->parent = $parentItems[$item->parent_id];
                 } else {
                     $this->items[$id]->parent = false;
                 }
             }
         }
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->form = $this->get('Form');
     $data = JArrayHelper::fromObject($user_profile, false);
     $post_data = (array) $app->getUserState('com_djcatalog2.query.data', array());
     if (!empty($post_data)) {
         foreach ($post_data as $k => $v) {
             $data[$k] = $v;
         }
     }
     $this->user_valid = $this->model->validate($this->form, array('djcatalog2profile' => $data), 'djcatalog2profile');
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     $this->_prepareDocument();
     parent::display($tpl);
 }