Esempio n. 1
0
 /**
  * downloads a file
  *
  * @return void
  */
 function downloadFile()
 {
     $user = JFactory::getUser();
     $productfile_id = intval(JRequest::getvar('id', '', 'request', 'int'));
     $product_id = intval(JRequest::getvar('product_id', '', 'request', 'int'));
     $link = 'index.php?option=com_tienda&view=products&task=edit&id=' . $product_id;
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $helper = TiendaHelperBase::getInstance('ProductDownload', 'TiendaHelper');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_tienda' . DS . 'tables');
     $productfile = JTable::getInstance('ProductFiles', 'TiendaTable');
     $productfile->load($productfile_id);
     if (empty($productfile->productfile_id)) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_TIENDA_INVALID FILE');
         $this->setRedirect($link, $this->message, $this->messagetype);
         return false;
     }
     // log and download
     Tienda::load('TiendaFile', 'library.file');
     // geting the ProductDownloadId to updated for which productdownload_max  is greater then 0
     $productToDownload = $helper->getProductDownloadInfo($productfile->productfile_id, $user->id);
     if ($downloadFile = TiendaFile::download($productfile)) {
         $link = JRoute::_($link, false);
         $this->setRedirect($link);
     }
 }
Esempio n. 2
0
 /**
  * Run function after saving 
  */
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     if ($return = parent::save($src, $orderingFilter, $ignore)) {
         Tienda::load("TiendaHelperProduct", 'helpers.product');
         $helper = TiendaHelperBase::getInstance('product');
         $helper->doProductQuantitiesReconciliation($this->product_id, '0');
     }
     return $return;
 }
 /**
  * Run function when saving
  * @see tienda/admin/tables/TiendaTable#save()
  */
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     if ($return = parent::save($src, $orderingFilter, $ignore)) {
         $pa = JTable::getInstance('ProductAttributes', 'TiendaTable');
         $pa->load($this->productattribute_id);
         Tienda::load("TiendaHelperProduct", 'helpers.product');
         $helper = TiendaHelperBase::getInstance('product');
         $helper->doProductQuantitiesReconciliation($pa->product_id);
     }
     return $return;
 }
Esempio n. 4
0
 /**
  * 
  * @param unknown_type $updateNulls
  * @return unknown_type
  */
 function store($updateNulls = false)
 {
     if ($return = parent::store($updateNulls)) {
         if ($this->notify_customer == '1') {
             Tienda::load("TiendaHelperBase", 'helpers._base');
             $helper = TiendaHelperBase::getInstance('Email');
             $model = Tienda::getClass("TiendaModelSubscriptions", "models.subscriptions");
             $model->setId($this->subscription_id);
             $subscription = $model->getItem();
             $helper->sendEmailNotices($subscription, 'subscription');
         }
     }
     return $return;
 }
Esempio n. 5
0
 /**
  * 
  * @param unknown_type $updateNulls
  * @return unknown_type
  */
 function store($updateNulls = false)
 {
     if ($return = parent::store($updateNulls)) {
         if ($this->notify_customer == '1') {
             Tienda::load("TiendaHelperBase", 'helpers._base');
             $helper = TiendaHelperBase::getInstance('Email');
             $model = Tienda::getClass("TiendaModelOrders", "models.orders");
             $model->setId($this->order_id);
             // this isn't necessary because you specify the requested PK id as a getItem() argument
             $order = $model->getItem($this->order_id, true);
             $helper->sendEmailNotices($order, 'order');
         }
     }
     return $return;
 }
Esempio n. 6
0
 function display($cachable = false, $urlparams = false)
 {
     $uri = JURI::getInstance();
     $view = $this->getView($this->get('suffix'), JFactory::getDocument()->getType());
     $view->set('hidemenu', false);
     $view->set('_doTask', true);
     $view->setLayout('default');
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $url = "index.php?option=com_users&view=user&task=user.edit";
     } else {
         $url = "index.php?option=com_user&view=user&task=edit";
     }
     Tienda::load("TiendaHelperBase", 'helpers._base');
     $helper = TiendaHelperBase::getInstance('Ambra');
     if ($helper->isInstalled()) {
         $url = "index.php?option=com_ambra&view=users&task=edit&return=" . base64_encode($uri->toString());
     }
     $view->assign('url_profile', $url);
     parent::display($cachable, $urlparams);
 }
Esempio n. 7
0
 protected function _buildQueryFields(&$query)
 {
     Tienda::load('TiendaHelperUser', 'helpers.user');
     $date = JFactory::getDate()->toMysql();
     $filter_product = $this->getState('filter_product');
     $user = TiendaHelperBase::getInstance('user');
     if (strlen($filter_product)) {
         $default_group = $user->getUserGroup(JFactory::getUser()->id, (int) $filter_product);
     } else {
         $default_group = Tienda::getInstance()->get('default_user_group', '1');
     }
     $fields = array();
     $fields[] = " p_from.product_name as product_name_from ";
     $fields[] = " p_from.product_sku as product_sku_from ";
     $fields[] = " p_from.product_model as product_model_from ";
     $fields[] = "\n            (\n            SELECT \n                prices.product_price\n            FROM\n                #__tienda_productprices AS prices \n            WHERE \n                prices.product_id = tbl.product_id_from \n                AND prices.group_id = '{$default_group}'\n                AND prices.product_price_startdate <= '{$date}' \n                AND (prices.product_price_enddate >= '{$date}' OR prices.product_price_enddate = '0000-00-00 00:00:00' )\n                ORDER BY prices.price_quantity_start ASC\n            LIMIT 1\n            ) \n        AS product_price_from ";
     $fields[] = " p_to.product_name as product_name_to ";
     $fields[] = " p_to.product_sku as product_sku_to ";
     $fields[] = " p_to.product_model as product_model_to ";
     $fields[] = "\n            (\n            SELECT \n                prices.product_price\n            FROM\n                #__tienda_productprices AS prices \n            WHERE \n                prices.product_id = tbl.product_id_to \n                AND prices.group_id = '{$default_group}'\n                AND prices.product_price_startdate <= '{$date}' \n                AND (prices.product_price_enddate >= '{$date}' OR prices.product_price_enddate = '0000-00-00 00:00:00' )\n                ORDER BY prices.price_quantity_start ASC\n            LIMIT 1\n            ) \n        AS product_price_to ";
     $query->select($this->getState('select', 'tbl.*'));
     $query->select($fields);
 }
Esempio n. 8
0
 /**
  * Processes the sale payment
  *
  * @param array $data Google Respnse data
  * @return boolean Did the Response Validate ?
  * @access protected
  */
 function _processSale($data, $error = '', $payment_details)
 {
     /*
      * validate the payment data
      */
     $errors = array();
     if (!empty($error)) {
         $errors[] = $error;
     }
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $googleOrderNumber = $data['google-order-number']['VALUE'];
     // Loading the order payment on ht basis of the google-order-number
     $orderpayment->load(array('transaction_id' => $googleOrderNumber));
     if (empty($orderpayment->orderpayment_id)) {
         $errors[] = JText::_('COM_TIENDA_GOOGLECHECKOUT_INVALID_GOOGLE_CHECKOUT_ORDER_ID');
         return count($errors) ? implode("\n", $errors) : '';
     }
     //	Svaing Financial order state
     $orderpayment->transaction_details = $payment_details;
     // Svaing payment status Completed
     $orderpayment->transaction_status = "Completed";
     // set the order's new status and update quantities if necessary
     Tienda::load('TiendaHelperOrder', 'helpers.order');
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($orderpayment->order_id);
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // update the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // update the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     return count($errors) ? implode("\n", $errors) : '';
 }
 function _process($data)
 {
     $post = JRequest::get('post');
     $orderpayment_id = @$data['ssl_invoice_number'];
     $errors = array();
     $send_email = false;
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load($orderpayment_id);
     if (empty($orderpayment_id) || empty($orderpayment->orderpayment_id)) {
         $errors[] = JText::_('VIRTUALMERCHANT MESSAGE INVALID ORDERPAYMENTID');
         return count($errors) ? implode("\n", $errors) : '';
     }
     $orderpayment->transaction_details = $data['ssl_result_message'];
     $orderpayment->transaction_id = $data['ssl_txn_id'];
     $orderpayment->transaction_status = $data['ssl_result'];
     // check the stored amount against the payment amount
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $stored_amount = TiendaHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
     $respond_amount = TiendaHelperBase::number($data['ssl_amount'], array('thousands' => ''));
     if ($stored_amount != $respond_amount) {
         $errors[] = JText::_('VIRTUALMERCHANT MESSAGE AMOUNT INVALID');
         $errors[] = $stored_amount . " != " . $respond_amount;
     }
     // set the order's new status and update quantities if necessary
     Tienda::load('TiendaHelperOrder', 'helpers.order');
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($orderpayment->order_id);
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // save the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     return count($errors) ? implode("\n", $errors) : '';
     return true;
 }
Esempio n. 10
0
 /**
  *
  * Adds a product relationship
  */
 function addRelationship()
 {
     $response = array();
     $response['msg'] = '';
     $response['error'] = '';
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $helper = TiendaHelperBase::getInstance();
     // get elements from post
     $elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', JRequest::getVar('elements', '', 'post', 'string')));
     // convert elements to array that can be binded
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $helper = TiendaHelperBase::getInstance();
     $submitted_values = $helper->elementsToArray($elements);
     $product_id = $submitted_values['new_relationship_productid_from'];
     $product_to = $submitted_values['new_relationship_productid_to'];
     $relation_type = $submitted_values['new_relationship_type'];
     // verify product id exists
     $product = JTable::getInstance('Products', 'TiendaTable');
     $product->load($product_to, true, false);
     if (empty($product->product_id) || $product_id == $product_to) {
         $response['error'] = '1';
         $response['msg'] = $helper->generateMessage(JText::_('COM_TIENDA_INVALID_PRODUCT'));
         $response['msg'] .= $this->getRelationshipsHtml(null, $product_id);
         echo json_encode($response);
         return;
     }
     // and that relationship doesn't already exist
     $producthelper = TiendaHelperBase::getInstance('Product');
     if ($producthelper->relationshipExists($product_id, $product_to, $relation_type)) {
         $response['error'] = '1';
         $response['msg'] = $helper->generateMessage(JText::_('COM_TIENDA_RELATIONSHIP_ALREADY_EXISTS'));
         $response['msg'] .= $this->getRelationshipsHtml(null, $product_id);
         echo json_encode($response);
         return;
     }
     switch ($relation_type) {
         case "child":
         case "required_by":
             // for these two, we must flip to/from
             switch ($relation_type) {
                 case "child":
                     $rtype = 'parent';
                     break;
                 case "required_by":
                     $rtype = 'requires';
                     break;
             }
             // check existence of required_by relationship
             if ($producthelper->relationshipExists($product_to, $product_id, $rtype)) {
                 $response['error'] = '1';
                 $response['msg'] = $helper->generateMessage(JText::_('COM_TIENDA_RELATIONSHIP_ALREADY_EXISTS'));
                 $response['msg'] .= $this->getRelationshipsHtml(null, $product_id);
                 echo json_encode($response);
                 return;
             }
             // then add it, need to flip to/from
             $table = JTable::getInstance('ProductRelations', 'TiendaTable');
             $table->product_id_from = $product_to;
             $table->product_id_to = $product_id;
             $table->relation_type = $rtype;
             $table->save();
             break;
         default:
             $table = JTable::getInstance('ProductRelations', 'TiendaTable');
             $table->product_id_from = $product_id;
             $table->product_id_to = $product_to;
             $table->relation_type = $relation_type;
             $table->save();
             break;
     }
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('ProductRelations', 'TiendaModel');
     $model->clearCache();
     $response['error'] = '0';
     $response['msg'] = $this->getRelationshipsHtml(null, $product_id);
     echo json_encode($response);
     // Close the application.
     JFactory::getApplication()->close();
 }
Esempio n. 11
0
 /**
  * Get the URL to the path to images
  * @return unknown_type
  */
 function getImageUrl()
 {
     // Check where we should upload the file
     // This is the default one
     $dir = Tienda::getPath('products_images');
     $url = Tienda::getUrl('products_images');
     $helper = TiendaHelperBase::getInstance();
     // is the image path overridden?
     if (!empty($this->product_images_path) && $helper->checkDirectory($this->product_images_path, false)) {
         $url = str_replace(JPATH_SITE . DS, JURI::root(), $this->product_images_path);
     } else {
         // try with the SKU
         if (Tienda::getInstance()->get('sha1_images', '0')) {
             if (!empty($this->product_sku)) {
                 $subdirs = $this->getSha1Subfolders($this->product_sku, '/');
                 $image_dir = $url . $subdirs . $this->product_sku . '/';
             }
         } else {
             $image_dir = $url . $this->product_sku . '/';
         }
         // try with the SKU
         if (!empty($this->product_sku)) {
             $url = $image_dir;
         } else {
             if (Tienda::getInstance()->get('sha1_images', '0')) {
                 $subdirs = $this->getSha1Subfolders($this->product_id, '/');
                 $image_dir = $url . $subdirs . $this->product_id . '/';
             } else {
                 $image_dir = $url . $this->product_id . '/';
             }
             $url = $image_dir;
         }
     }
     return $url;
 }
Esempio n. 12
0
 /**
  * Adds an item to a User's Product Compare
  * whether in the session or the db
  *
  */
 function addProductToCompare()
 {
     // saving the session id which will use to update the cart
     $session = JFactory::getSession();
     $userid = JFactory::getUser()->id;
     // After login, session_id is changed by Joomla, so store this for reference
     $session->set('old_sessionid', $session->getId());
     $response = array();
     $response['msg'] = '';
     $response['error'] = '';
     $product_id = JRequest::getVar('product_id');
     $add = JRequest::getVar('add', 1);
     //deleting product to compare
     if (!$add) {
         $db = JFactory::getDBO();
         Tienda::load('TiendaQuery', 'library.query');
         $query = new TiendaQuery();
         $query->delete();
         $query->from("#__tienda_productcompare");
         $query->where("`product_id` = '{$product_id}' ");
         $query->where("`session_id` = '" . $session->getId() . "' ");
         $query->where("`user_id` = '{$userid}'");
         $db->setQuery((string) $query);
         if (!$db->query()) {
             $response['msg'] = $helper->generateMessage($db->getErrorMsg());
             $response['error'] = '1';
             return false;
         }
     } else {
         Tienda::load('TiendaHelperProductCompare', 'helpers.productcompare');
         $compare_helper = new TiendaHelperProductCompare();
         //check limit
         $compareLimit = $compare_helper->checkLimit();
         if (!$compareLimit) {
             Tienda::load('TiendaHelperBase', 'helpers._base');
             $helper = TiendaHelperBase::getInstance();
             $limit = Tienda::getInstance()->get('compared_products', '5');
             $response['msg'] = $helper->generateMessage(JText::sprintf("COM_TIENDA_ONLY_N_PRODUCTS_CAN_BE_ADDED_TO_COMPARE", $limit));
             $response['error'] = '1';
             echo json_encode($response);
             return;
         }
         // create cart object out of item properties
         $item = new JObject();
         $item->user_id = $userid;
         $item->product_id = (int) $product_id;
         // add the item to the product comparison
         $compare_item = $compare_helper->addItem($item);
     }
     //load user compared items
     $model = $this->getModel($this->get('suffix'));
     $model->setState('filter_user', $userid);
     if (empty($user->id)) {
         $model->setState('filter_session', $session->getId());
     }
     $items = $model->getList();
     //TODO: make it to call a view
     $response['msg'] .= '<ul>';
     foreach ($items as $item) {
         $table = JTable::getInstance('Products', 'TiendaTable');
         $table->load(array('product_id' => $item->product_id));
         $response['msg'] .= '<li>';
         $response['msg'] .= '<a href="' . JRoute::_('index.php?option=com_tienda&view=products&task=view&id=' . $item->product_id) . '">';
         $response['msg'] .= $table->product_name;
         $response['msg'] .= '</a>';
         $response['msg'] .= '</li>';
     }
     $response['msg'] .= '</ul>';
     echo json_encode($response);
     return;
 }
Esempio n. 13
0
 /**
  * Processes the sale payment
  *
  * @param array $data IPN data
  * @return boolean Did the IPN Validate?
  * @access protected
  */
 function _processSale($data, $ipnValidationFailed = '')
 {
     $send_email = false;
     /*
      * validate the payment data
      */
     $errors = array();
     if (!empty($ipnValidationFailed)) {
         $errors[] = $ipnValidationFailed;
     }
     // is the recipient correct?
     if (empty($data['receiver_email']) || $data['receiver_email'] != $this->_getParam('merchant_email')) {
         $errors[] = JText::_('PAYPAL MESSAGE RECEIVER INVALID');
     }
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load($data['custom']);
     $orderpayment->transaction_details = $data['transaction_details'];
     $orderpayment->transaction_id = $data['txn_id'];
     $orderpayment->transaction_status = $data['payment_status'];
     // check the stored amount against the payment amount
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $stored_amount = TiendaHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
     $respond_amount = TiendaHelperBase::number($data['mc_gross'], array('thousands' => ''));
     if ($stored_amount != $respond_amount) {
         $errors[] = JText::_('PAGSEGURO MESSAGE PAYMENT AMOUNT INVALID');
         $errors[] = $stored_amount . " != " . $respond_amount;
     }
     // check the payment status
     if (empty($data['payment_status']) || $data['payment_status'] != 'Completed' && $data['payment_status'] != 'Pending') {
         $errors[] = JText::sprintf('PAYPAL MESSAGE STATUS INVALID', @$data['payment_status']);
     }
     // set the order's new status and update quantities if necessary
     JLoader::import('com_tienda.helpers.order', JPATH_ADMINISTRATOR . '/components');
     JLoader::import('com_tienda.helpers.carts', JPATH_ADMINISTRATOR . '/components');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($orderpayment->order_id);
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
     } elseif (@$data['payment_status'] == 'Pending') {
         // if the transaction has the "pending" status,
         $order->order_state_id = Tienda::getInstance('pending_order_state', '1');
         // PENDING
         // Update quantities for echeck payments
         TiendaHelperOrder::updateProductQuantities($orderpayment->order_id, '-');
         // remove items from cart
         TiendaHelperCarts::removeOrderItems($orderpayment->order_id);
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // save the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     return count($errors) ? implode("\n", $errors) : '';
 }
Esempio n. 14
0
 /**
  *
  * @return HTML
  */
 function _process()
 {
     $send_email = false;
     $data = JRequest::getVar('DATA', '', 'post');
     // Invalidate data if it is in the wrong format
     if (!preg_match(':^[a-zA-Z0-9]+$:', $data)) {
         $data = '';
     }
     $this->os_info = $this->_getOperatingSystemInfo();
     // set sips checkout type
     // Next line is there to help me to debug
     // should not be removed
     //$data = '2020333732603028502c2360532d5328532d2360522d4360502c4360502c3334502c3330512d2324562d5334592c3324512c33242a2c2360532c2360502d2324502c23602a2c2360552c2360502d433c552e3328572c4048512c2334502c23605435444533303048502c2338502c2324542c4360512c2360582c4344502e3334582d233c2a2c3360532c2360502d4324512d3344502c5048512c2330502c2360582c4360512c2360582c43442a2c3360512c2360502c4360505c224324502c4360502c3360512c4340532c233c552e3330535c224324502c2360502c2338502d5334592d232c2a2c2328582c2360502c4639525c224360522e3360502c2329463c4048502c2340502c2360532e333c585c224324502d4360502c233c512c3324512b4360505c224324512d2360502c2338522c2324522c23242a2c2360592c2360502c4639525c224360532c2360502c4321413b26255438364c512c232160383651413d26254b2b4659453d6048502c3338502c23605334552d2c5c224360502d5360502c2328502c4048502c5340502c2360522e33382a2c2330502c2360512d2425353524412f34455d2330352134353529255c224360532e3360502c2324505c224324502e3360502c23292e335048512c3360502c236051334048512c3324502c2360522c23602a2c2328562c2360502d5344572d3344522d53282adc970880f8cf2717';
     //
     // Récupération de la variable cryptée DATA
     $message = "message=" . $data;
     $pathfile .= " pathfile=" . $this->_getPathfileFileName($this->params->get('pathfile'));
     $bin_response = $this->_getBinPath("response");
     $parm = $message . " " . $pathfile;
     $result = exec("{$bin_response} {$parm}");
     $sips_response_array = explode("!", $result);
     list(, $code, $error, $merchant_id, $merchant_country, $amount, $transaction_id, $payment_means, $transmission_date, $payment_time, $payment_date, $response_code, $payment_certificate, $authorisation_id, $currency_code, $card_number, $cvv_flag, $cvv_response_code, $bank_response_code, $complementary_code, $complementary_info, $return_context, $caddie, $receipt_complement, $merchant_language, $language, $customer_id, $orderpayment_id, $customer_email, $customer_ip_address, $capture_day, $capture_mode, $data) = $sips_response_array;
     if ($code != 0) {
         $errors[] = JText::_('TIENDA_SIPS_RETURN_CODE_INVALID') . " " . $code;
     } elseif ($error != 0) {
         $errors[] = JText::_('TIENDA_SIPS_RETURN_ERROR') . " " . $sips_error;
     } elseif ($merchant_id != $this->params->get('merchant_id')) {
         $errors[] = JText::_('TIENDA_SIPS_MERCHANT_ID_RECEIVED_INVALID');
     } else {
         // load the orderpayment record and set some values
         JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_tienda' . DS . 'tables');
         $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
         $orderpayment->load($orderpayment_id);
         if (empty($orderpayment_id) || empty($orderpayment->orderpayment_id)) {
             $errors[] = JText::_('TIENDA_SIPS_INVALID ORDERPAYMENTID');
         }
     }
     if (count($errors)) {
         echo $errors;
         print_r($errors);
         $this->_sendErrorEmail($errors, $sips_response_array);
         return false;
     }
     // check the stored amount against the payment amount
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $stored_amount = TiendaHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
     $respond_amount = TiendaHelperBase::number($amount, array('thousands' => ''));
     if ($stored_amount != $respond_amount) {
         $errors[] = JText::_('TIENDA_SIPS_AMOUNT_INVALID');
         $errors[] = $stored_amount . " != " . $respond_amount;
     }
     // set the order's new status and update quantities if necessary
     Tienda::load('TiendaHelperOrder', 'helpers.order');
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($orderpayment->order_id);
     if (count($errors) or $response_code != '00') {
         if ($response_code != '00') {
             $orderpayment->transaction_details = JText::_('TIENDA_SIPS_RESPONSE_CODE') . $response_code . "\n" . JText::_('TIENDA_SIPS_RESPONSE_CODE_SIPS_ERROR') . constant('TIENDA_SIPS_RESPONSE_' . $response['response_code']) . "\n" . JText::_('TIENDA_SIPS_READ_SIPS_DOCUMENTATION');
         } else {
             $orderpayment->transaction_details = implode(" ", $errors);
         }
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
         // save the order
         if (!$order->save()) {
             $errors[] = $order->getError();
         }
         $send_email = false;
     } else {
         define($credit_card_type, $payment_means);
         $credit_card = split('\\.', $card_number);
         $credit_card_number = $credit_card[0] . ' #### #### ##' . $credit_card[1];
         // TO DO: DECODE TIME AND DATE
         $orderpayment->transaction_details = JText::_('TIENDA_SIPS_TRANSMISSION_DATE') . $transmission_date . "\n" . JText::_('TIENDA_SIPS_RESPONSE_PAYMENT_TIME') . " : " . $payment_time . "\n" . JText::_('TIENDA_SIPS_RESPONSE_PAYMENT_DATE') . " : " . $payment_date . "\n" . JText::_('TIENDA_SIPS_RESPONSE_PAYMENT_CERTIFICATE') . " : " . $payment_certificate . "\n" . JText::_('TIENDA_SIPS_RESPONSE_AUTHORIZATION_ID') . $authorisation_id . "\n" . JText::_('TIENDA_SIPS_RESPONSE_CREDIT_CARD_TYPE') . " : " . constant($credit_card_type) . "\n" . JText::_('TIENDA_SIPS_RESPONSE_CREDIT_CARD_NUMBER') . " : " . $credit_card_number;
         $orderpayment->transaction_id = $transaction_id;
         $orderpayment->transaction_status = $response_code;
         // ???
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // save the order
         if (!$order->save()) {
             $errors[] = $order->getError();
         }
         // PAYMENT RECEIVED
         $this->setOrderPaymentReceived($orderpayment->order_id);
         // send email
         $send_email = true;
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     return count($errors) ? implode("\n", $errors) : 'processed';
 }
Esempio n. 15
0
 /**
  * Checks that a password and password2 match
  * @return unknown_type
  */
 function checkPassword2()
 {
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $helper = TiendaHelperBase::getInstance();
     $response = array();
     $response['msg'] = '';
     $response['error'] = '';
     // get elements from post
     $elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', JRequest::getVar('elements', '', 'post', 'string', 'string')));
     // convert elements to array that can be binded
     $values = TiendaHelperBase::elementsToArray($elements);
     $password = $values['password'];
     $password2 = $values['password2'];
     if (empty($password)) {
         $response['msg'] = $helper->validationMessage("COM_TIENDA_PASSWORD_CANNOT_BE_EMPTY", 'fail');
         $response['error'] = '1';
         echo json_encode($response);
         return;
     }
     if (empty($password2)) {
         $response['msg'] = $helper->validationMessage("COM_TIENDA_PASSWORD_VERIFY_CANNOT_BE_EMPTY", 'fail');
         $response['error'] = '1';
         echo json_encode($response);
         return;
     }
     $message = "";
     if ($password != $password2) {
         $message .= $helper->validationMessage('COM_TIENDA_PASSWORD_DO_NOT_MATCH', 'fail');
     } else {
         // no error
         $message .= $helper->validationMessage('COM_TIENDA_PASSWORD_VALID', 'success');
     }
     $response['msg'] = $message;
     $response['error'] = '1';
     echo json_encode($response);
     return;
 }
Esempio n. 16
0
<?php

/**
 * @version    1.5
 * @package    Tienda
 * @author     Dioscouri Design
 * @link     http://www.dioscouri.com
 * @copyright Copyright (C) 2009 Dioscouri Design. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
/** ensure this file is being included by a parent file */
defined('_JEXEC') or die('Restricted access');
Tienda::load('TiendaHelperBase', 'helpers._base');
Tienda::load('TiendaSelect', 'library.select');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
$helper = TiendaHelperBase::getInstance();
$url = JRoute::_('index.php?option=com_tienda&view=products&task=setCurrency&return=' . base64_encode(JURI::getInstance()->toString()), false);
// Check the currently selected currency
$selected = TiendaHelperBase::getSessionVariable('currency_id', Tienda::getInstance()->get('default_currencyid', 1));
?>

<div id="currency">
    <form action="<?php 
echo $url;
?>
" method="post" name="currencySwitch">
        <?php 
echo JText::_('COM_TIENDA_SELECT_CURRENCY') . ': ';
?>
        <?php 
$attribs = array('onChange' => 'document.currencySwitch.submit(); ');
Esempio n. 17
0
 /**
  * Set basic properties for the item, whether in a list or a singleton
  *
  * @param unknown_type $item
  * @param unknown_type $key
  * @param unknown_type $refresh
  */
 protected function prepareItem(&$item, $key = 0, $refresh = false)
 {
     $getEav = $this->_getEav;
     $options = $this->_getEavOptions;
     $eavStates = count($this->getEavState()->getProperties());
     if (!empty($getEav) || $eavStates > 0) {
         $app = JFactory::getApplication();
         $editable_by = method_exists('isAdmin', $app) && $app->isAdmin() ? 1 : 2;
         // CLI fix
         Tienda::load('TiendaModelEavAttributes', 'models.eavattributes');
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $eav_helper = TiendaHelperBase::getInstance('Eav');
         $entity = $this->getTable()->get('_suffix');
         $tbl_key = $this->getTable()->getKeyName();
         $entity_id = $item->{$tbl_key};
         // add the custom fields as properties
         $eavs = $eav_helper->getAttributes($entity, $entity_id, false, $editable_by);
         // Mirrored table?
         if (!count($eavs) && strlen($this->getTable()->getLinkedTable())) {
             $entity = $this->getTable()->getLinkedTable();
             $entity_id = $item->{$this->getTable()->getLinkedTableKeyName()};
             $eavs = $eav_helper->getAttributes($entity, $entity_id, false, $editable_by);
         }
         foreach ($eavs as $eav) {
             $key = $eav->eavattribute_alias;
             $add = true;
             // Include Mode: Fetch only these fields
             if (array_key_exists('include', $options)) {
                 foreach ($options['include'] as $k) {
                     if ($key != $k) {
                         $add = false;
                     }
                 }
             } else {
                 // Exclude Mode: Fetch everything except these fields
                 if (array_key_exists('exclude', $options)) {
                     foreach ($options['exclude'] as $k) {
                         if ($key == $k) {
                             $add = false;
                         }
                     }
                 }
                 // Default Mode: Fetch Everything
             }
             if ($add) {
                 $value = $eav_helper->getAttributeValue($eav, $this->getTable()->get('_suffix'), $item->{$tbl_key}, true, true);
                 // Do NOT ovveride properties
                 if (!property_exists($item, $key)) {
                     $item->{$key} = $value;
                 }
             }
         }
     }
     parent::prepareItem($item, $key, $refresh);
 }
Esempio n. 18
0
 /**
  *  this is updating the transaction id and staus in case of not completed state
  *	@param  data Array of response
  *	@param  error
  */
 function _saveTransaction($data, $error = '')
 {
     $send_email = false;
     $errors = array();
     if (!empty($error)) {
         $errors[] = $error;
     }
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load($data->orderpayment_id);
     //	Svaing Financial order state
     $orderpayment->transaction_details = $data->payment_details;
     // Svaing payment status Completed
     $orderpayment->transaction_status = "Payment Declined";
     // Svaing payment status Completed
     $orderpayment->transaction_status = $data->transactionId;
     // update the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     return count($errors) ? implode("\n", $errors) : '';
 }
Esempio n. 19
0
 /**
  * Processing the payment
  * 
  * @param $data     array form post data
  * @return string   HTML to display
  */
 function _process($data)
 {
     $errors = array();
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment_id = $data['orderpayment_id'];
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load($orderpayment_id);
     $orderpayment->transaction_details = $data['orderpayment_type'];
     $orderpayment->transaction_id = $data['orderpayment_id'];
     $orderpayment->transaction_status = "Payment Incomplete";
     // check the stored amount against the payment amount
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $stored_amount = TiendaHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
     $respond_amount = TiendaHelperBase::number($data['orderpayment_amount'], array('thousands' => ''));
     if ($stored_amount != $respond_amount) {
         $errors[] = JText::_('TIENDA ALPHAUSERPOINTS PAYMENT MESSAGE AMOUNT INVALID');
         $errors[] = $stored_amount . " != " . $respond_amount;
     }
     // check if user has enough points
     $userpoints = $this->getUserpoints();
     if ($data['amount_points'] > $userpoints) {
         $errors[] = JText::_('TIENDA ALPHAUSERPOINTS PAYMENT MESSAGE NOT ENOUGH POINTS');
     }
     // set the order's new status and update quantities if necessary
     Tienda::load('TiendaHelperOrder', 'helpers.order');
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($orderpayment->order_id);
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
         $setOrderPaymentReceived = false;
         $send_email = false;
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         $orderpayment->transaction_status = "Payment Received";
         //reduce number of alphauserpoints
         $errors[] = $this->reduceUserpoints($data['amount_points']);
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // save the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     return count($errors) ? implode("\n", $errors) : '';
 }
Esempio n. 20
0
 /**
  *
  * Enter description here ...
  * @param $data
  * @return unknown_type
  */
 public function _processSubscriptionPayment($data)
 {
     // if we're here, a successful payment has been made.
     // the normal notice that requires action.
     // create a subscription_id if no subscr_id record exists
     // set expiration dates
     // add a sub history entry, email the user?
     $errors = array();
     // Check that custom (orderpayment_id) is present, we need it for payment amount verification
     if (empty($data['custom'])) {
         $this->setError(JText::_('PAYPAL MESSAGE INVALID ORDERPAYMENTID'));
         return false;
     }
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load($data['custom']);
     if (empty($data['custom']) || empty($orderpayment->orderpayment_id)) {
         $this->setError(JText::_('PAYPAL MESSAGE INVALID ORDERPAYMENTID'));
         return false;
     }
     $orderpayment->transaction_details = $data['transaction_details'];
     $orderpayment->transaction_id = $data['txn_id'];
     $orderpayment->transaction_status = $data['payment_status'];
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($data['item_number']);
     $items = $order->getItems();
     // Update orderitem_status
     $order_item = $order->getRecurringItem();
     $orderitem = JTable::getInstance('OrderItems', 'TiendaTable');
     $orderitem->orderitem_id = $order_item->orderitem_id;
     $orderitem->orderitem_status = '1';
     $orderitem->save();
     // TODO Here we need to verify the payment amount
     // if no subscription exists for this subscr_id,
     // create new subscription for the user
     $subscription = JTable::getInstance('Subscriptions', 'TiendaTable');
     $subscription->load(array('transaction_id' => $data['subscr_id']));
     if (empty($subscription->subscription_id)) {
         $date = JFactory::getDate();
         // create new subscription
         // if recurring trial, set it
         // for the order's recurring_trial_period_interval
         // using its recurring_trial_period_unit
         // otherwise, do the normal recurring_period_interval
         // and the recurring_period_unit
         $recurring_period_unit = $order->recurring_period_unit;
         $recurring_period_interval = $order->recurring_period_interval;
         if (!empty($order->recurring_trial)) {
             $recurring_period_unit = $order->recurring_trial_period_unit;
             $recurring_period_interval = $order->recurring_trial_period_interval;
         }
         $subscription->user_id = $order->user_id;
         $subscription->order_id = $order->order_id;
         $subscription->product_id = $orderitem->product_id;
         $subscription->orderitem_id = $orderitem->orderitem_id;
         $subscription->transaction_id = $data['subscr_id'];
         $subscription->created_datetime = $date->toMySQL();
         $subscription->subscription_enabled = '1';
         switch ($recurring_period_unit) {
             case "Y":
                 $period_unit = "YEAR";
                 break;
             case "M":
                 $period_unit = "MONTH";
                 break;
             case "W":
                 $period_unit = "WEEK";
                 break;
             case "D":
             default:
                 $period_unit = "DAY";
                 break;
         }
         $database = JFactory::getDBO();
         $query = " SELECT DATE_ADD('{$subscription->created_datetime}', INTERVAL {$recurring_period_interval} {$period_unit} ) ";
         $database->setQuery($query);
         $subscription->expires_datetime = $database->loadResult();
         if (!$subscription->save()) {
             $this->setError($subscription->getError());
             return false;
         }
         // add a sub history entry, email the user?
         $subscriptionhistory = JTable::getInstance('SubscriptionHistory', 'TiendaTable');
         $subscriptionhistory->subscription_id = $subscription->subscription_id;
         $subscriptionhistory->subscriptionhistory_type = 'creation';
         $subscriptionhistory->created_datetime = $date->toMySQL();
         $subscriptionhistory->notify_customer = '0';
         // notify customer of new trial subscription?
         $subscriptionhistory->comments = JText::_('NEW SUBSCRIPTION CREATED');
         $subscriptionhistory->save();
     } else {
         // subscription exists, just update its expiration date
         // based on normal interval and period
         switch ($order->recurring_period_unit) {
             case "Y":
                 $period_unit = "YEAR";
                 break;
             case "M":
                 $period_unit = "MONTH";
                 break;
             case "W":
                 $period_unit = "WEEK";
                 break;
             case "D":
             default:
                 $period_unit = "DAY";
                 break;
         }
         $database = JFactory::getDBO();
         $today = $date = JFactory::getDate();
         $query = " SELECT DATE_ADD('{$today}', INTERVAL {$order->recurring_period_interval} {$period_unit} ) ";
         $database->setQuery($query);
         $subscription->expires_datetime = $database->loadResult();
         if (!$subscription->save()) {
             $this->setError($subscription->getError());
             return false;
         }
         // add a sub history entry, email the user?
         $subscriptionhistory = JTable::getInstance('SubscriptionHistory', 'TiendaTable');
         $subscriptionhistory->subscription_id = $subscription->subscription_id;
         $subscriptionhistory->subscriptionhistory_type = 'payment';
         $subscriptionhistory->created_datetime = $date->toMySQL();
         $subscriptionhistory->notify_customer = '0';
         // notify customer of new trial subscription?
         $subscriptionhistory->comments = JText::_('NEW SUBSCRIPTION PAYMENT RECEIVED');
         $subscriptionhistory->save();
     }
     if (count($items) == '1') {
         // update order status
         Tienda::load('TiendaHelperOrder', 'helpers.order');
         Tienda::load('TiendaHelperCarts', 'helpers.carts');
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
         // save the order
         if (!$order->save()) {
             $errors[] = $order->getError();
         }
         if (!empty($setOrderPaymentReceived)) {
             $this->setOrderPaymentReceived($orderpayment->order_id);
         }
         if ($send_email) {
             // send notice of new order
             Tienda::load("TiendaHelperBase", 'helpers._base');
             $helper = TiendaHelperBase::getInstance('Email');
             $model = Tienda::getClass("TiendaModelOrders", "models.orders");
             $model->setId($orderpayment->order_id);
             $order = $model->getItem();
             $helper->sendEmailNotices($order, 'new_order');
         }
     }
     $error = count($errors) ? implode("\n", $errors) : '';
     if (!empty($error)) {
         $this->setError($error);
         return false;
     }
     return true;
 }
Esempio n. 21
0
 /**
  * Processes the payment form
  * and returns HTML to be displayed to the user
  * generally with a success/failed message
  *  
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _postPayment($data)
 {
     // Process the payment
     $vars = new JObject();
     $orderpayment_id = !empty($data['orderpayment_id']) ? $data['orderpayment_id'] : JRequest::getVar('orderpayment_id');
     $cardtype = !empty($data['cardtype']) ? $data['cardtype'] : JRequest::getVar('cardtype');
     $cardnum = !empty($data['cardnum']) ? $data['cardnum'] : JRequest::getVar('cardnum');
     $cardexp = !empty($data['cardexp']) ? $data['cardexp'] : JRequest::getVar('cardexp');
     $cardcvv = !empty($data['cardcvv']) ? $data['cardcvv'] : JRequest::getVar('cardcvv');
     $formatted = array('cardtype' => $cardtype, 'cardnum' => $cardnum, 'cardexp' => $cardexp, 'cardcvv' => $cardcvv);
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load($orderpayment_id);
     $orderpayment->transaction_details = implode("\n", $formatted);
     if ($orderpayment->save()) {
         // Don't remove order quantities until payment is actually received?
         if ($this->params->get('remove_quantities')) {
             Tienda::load('TiendaHelperOrder', 'helpers.order');
             TiendaHelperOrder::updateProductQuantities($orderpayment->order_id, '-');
         }
         // remove items from cart
         Tienda::load('TiendaHelperCarts', 'helpers.carts');
         TiendaHelperCarts::removeOrderItems($orderpayment->order_id);
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     // display the layout
     $html = $this->_getLayout('postpayment', $vars);
     // append the article with offline payment information
     $html .= $this->_displayArticle();
     return $html;
 }
Esempio n. 22
0
 function _process($data)
 {
     Tienda::load('TiendaModelOrders', 'models.orders');
     $model = new TiendaModelOrders();
     if (!$data['vs']) {
         // order is not valid
         return JText::_('TIENDA CARDPAY MESSAGE INVALID ORDER') . $this->_generateSignature($data, 2);
     }
     $errors = array();
     $send_email = false;
     if ($this->_generateSignature($data, 2) == $data['sign']) {
         switch ($data['res']) {
             case 'OK':
                 // OK
                 break;
             case 'TOUT':
                 // Time out
                 $errors[] = JText::_('TIENDA CARDPAY MESSAGE PAYMENT TIMEOUT');
                 break;
             default:
                 // something went wrong
             // something went wrong
             case 'FAIL':
                 // transaction failed
                 $errors[] = JText::_('TIENDA CARDPAY MESSAGE PAYMENT FAIL');
                 break;
         }
         $send_email = true;
         // send email!
     } else {
         $errors[] = JText::_('Tienda CARDPAY Message Invalid Signature');
     }
     // check that payment amount is correct for order_id
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load(array('order_id' => $data['vs']));
     unset($data['secure_key']);
     $orderpayment->transaction_details = Tienda::dump($data);
     $orderpayment->transaction_id = $data['vs'];
     $orderpayment->transaction_status = $data['res'];
     // set the order's new status and update quantities if necessary
     Tienda::load('TiendaHelperOrder', 'helpers.order');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($data['vs']);
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // save the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     if (empty($errors)) {
         $return = JText::_('TIENDA CARDPAY MESSAGE PAYMENT SUCCESS');
         return $return;
     }
     return count($errors) ? implode("\n", $errors) : '';
 }
Esempio n. 23
0
 /**
  * Formats and converts a number according to currency rules
  * As of v0.5.0 is a wrapper
  *
  * @param unknown_type $amount
  * @param unknown_type $currency
  * @return unknown_type
  */
 public static function currency($amount, $currency = '', $options = '')
 {
     $currency_helper = TiendaHelperBase::getInstance('Currency');
     $amount = $currency_helper->_($amount, $currency, $options);
     return $amount;
 }
Esempio n. 24
0
<?php

defined('_JEXEC') or die('Restricted access');
JHTML::_('script', 'tienda.js', 'media/com_tienda/js/');
$state = @$this->state;
$form = @$this->form;
$items = @$this->items;
Tienda::load('TiendaUrl', 'library.url');
$helper_category = TiendaHelperBase::getInstance('Category');
$helper_product = TiendaHelperBase::getInstance('Product');
?>



<form action="<?php 
echo JRoute::_(@$form['action']);
?>
" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">

	<?php 
echo TiendaGrid::pagetooltip(JRequest::getVar('view'));
?>
	<?php 
echo TiendaGrid::searchform(@$state->filter, JText::_('COM_TIENDA_SEARCH'), JText::_('COM_TIENDA_RESET'));
?>
	

	<table class="table table-striped table-bordered" style="clear: both;">
		<thead>
            <tr>
                <th style="width: 5px;">
Esempio n. 25
0
 /**
  * Returns a formatted path for the category
  * @param $id
  * @param $format
  * @return unknown_type
  */
 public static function getPathName($id, $format = 'flat', $linkSelf = false)
 {
     $name = '';
     if (empty($id)) {
         return $name;
     }
     if (isset($this) && is_a($this, 'TiendaHelperCategory')) {
         $helper = $this;
     } else {
         $helper = TiendaHelperBase::getInstance('Category');
     }
     if (empty($helper->categories[$id])) {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
         $helper->categories[$id] = JTable::getInstance('Categories', 'TiendaTable');
         $helper->categories[$id]->load($id);
     }
     $item = $helper->categories[$id];
     if (empty($item->category_id)) {
         return $name;
     }
     $path = $item->getPath();
     switch ($format) {
         case "array":
             $name = array();
             foreach (@$path as $cat) {
                 $include_root = Tienda::getInstance()->get('include_root_pathway', false);
                 if (!$cat->isroot || $include_root) {
                     $pathway_object = new JObject();
                     $pathway_object->name = $cat->category_name;
                     $slug = $cat->category_alias ? ":{$cat->category_alias}" : "";
                     $link = "index.php?option=com_tienda&view=products&filter_category=" . $cat->category_id . $slug;
                     $pathway_object->link = $link;
                     $pathway_object->id = $cat->category_id;
                     $name[] = $pathway_object;
                 }
             }
             // add the item
             $pathway_object = new JObject();
             $pathway_object->name = $item->category_name;
             $slug = $item->category_alias ? ":{$item->category_alias}" : "";
             $link = "index.php?option=com_tienda&view=products&filter_category=" . $item->category_id . $slug;
             $pathway_object->link = $link;
             $pathway_object->id = $item->category_id;
             $name[] = $pathway_object;
             break;
         case "bullet":
             foreach (@$path as $cat) {
                 if (!$cat->isroot) {
                     $name .= '&bull;&nbsp;&nbsp;';
                     $name .= JText::_($cat->category_name);
                     $name .= "<br/>";
                 }
             }
             $name .= '&bull;&nbsp;&nbsp;';
             $name .= JText::_($item->category_name);
             break;
         case 'links':
             // get the root category
             JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
             $root = JTable::getInstance('Categories', 'TiendaTable')->getRoot();
             $root_itemid = Tienda::getClass("TiendaHelperRoute", 'helpers.route')->category($root->category_id, true);
             $include_root = Tienda::getInstance()->get('include_root_pathway', false);
             if ($include_root) {
                 $link = JRoute::_("index.php?option=com_tienda&view=products&filter_category=" . $root->category_id . "&Itemid=" . $root_itemid, false);
                 $name .= " <a href='{$link}'>" . JText::_('COM_TIENDA_ALL_CATEGORIES') . '</a> ';
             }
             foreach (@$path as $cat) {
                 if (!$cat->isroot) {
                     if (!($itemid = Tienda::getClass("TiendaHelperRoute", 'helpers.route')->category($cat->category_id, true))) {
                         $itemid = $root_itemid;
                     }
                     $slug = $cat->category_alias ? ":{$cat->category_alias}" : "";
                     $link = JRoute::_("index.php?option=com_tienda&view=products&filter_category=" . $cat->category_id . $slug . "&Itemid=" . $itemid, false);
                     if (!empty($name)) {
                         $name .= " > ";
                     }
                     $name .= " <a href='{$link}'>" . JText::_($cat->category_name) . '</a> ';
                 }
             }
             if (!empty($name)) {
                 $name .= " > ";
             }
             if ($linkSelf) {
                 if (!($itemid = Tienda::getClass("TiendaHelperRoute", 'helpers.route')->category($item->category_id, true))) {
                     $itemid = $root_itemid;
                 }
                 $slug = $item->category_alias ? ":{$item->category_alias}" : "";
                 $link = JRoute::_("index.php?option=com_tienda&view=products&filter_category=" . $item->category_id . $slug . "&Itemid=" . $itemid, false);
                 $name .= " <a href='{$link}'>" . JText::_($item->category_name) . '</a> ';
             } else {
                 $name .= JText::_($item->category_name);
             }
             break;
         default:
             foreach (@$path as $cat) {
                 if (!$cat->isroot) {
                     $name .= " / ";
                     $name .= JText::_($cat->category_name);
                 }
             }
             $name .= " / ";
             $name .= JText::_($item->category_name);
             break;
     }
     return $name;
 }
Esempio n. 26
0
 function _process($data)
 {
     $errors = array();
     $user = JFactory::getUser();
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $orderpayment_id = $data['orderpayment_id'];
     $orderpayment = JTable::getInstance('OrderPayments', 'TiendaTable');
     $orderpayment->load($orderpayment_id);
     $orderpayment->transaction_details = $data['orderpayment_type'];
     $orderpayment->transaction_id = $data['orderpayment_id'];
     $orderpayment->transaction_status = "Incomplete";
     // check the stored amount against the payment amount thousand
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $stored_amount = TiendaHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
     $respond_amount = TiendaHelperBase::number($data['orderpayment_amount'], array('thousands' => ''));
     if ($stored_amount != $respond_amount) {
         $errors[] = JText::_('TIENDA AMBRAPOINTS PAYMENT MESSAGE AMOUNT INVALID');
         $errors[] = $stored_amount . " != " . $respond_amount;
     }
     // set the order's new status and update quantities if necessary
     Tienda::load('TiendaHelperOrder', 'helpers.order');
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     $order = JTable::getInstance('Orders', 'TiendaTable');
     $order->load($orderpayment->order_id);
     // check if user has enough points
     JLoader::import('com_ambra.helpers.user', JPATH_ADMINISTRATOR . '/components');
     $current_points = AmbraHelperUser::getPoints($order->user_id);
     if ($data['amount_points'] > $current_points) {
         $errors[] = JText::_('TIENDA AMBRAPOINTS PAYMENT MESSAGE NOT ENOUGH POINTS');
     }
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
         $send_email = false;
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         $orderpayment->transaction_status = "Payment Received";
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // save the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         $model = Tienda::getClass("TiendaModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     // substract spent points from user's ambra total points
     // successful payment
     // if here, all OK
     // create a pointhistory table object
     $pointhistory = JTable::getInstance('PointHistory', 'AmbraTable');
     // set properties
     $pointhistory->user_id = $user->id;
     $pointhistory->points = "-" . $data['amount_points'];
     $pointhistory->points_updated = 0;
     $pointhistory->pointhistory_enabled = 1;
     $pointhistory->pointhistory_name = JText::_('For making purchase in Tienda');
     $pointhistory->pointhistory_description = JText::_('COM_TIENDA_PAYMENT_ID') . ": " . $orderpayment_id . "\n" . JText::_('COM_TIENDA_TRANSACTION_ID') . ": " . $orderpayment->transaction_id;
     // save it and move on
     if (!$pointhistory->save()) {
         $errors[] = $pointhistory->getError();
         // if saving the record failed, disable sub?
     }
     return count($errors) ? implode("\n", $errors) : '';
 }
Esempio n. 27
0
 /**
  * Migrate the images
  * 
  * @param int $product_id
  * @param string $images
  */
 private function _migrateImages($product_id, $images)
 {
     Tienda::load('TiendaImage', 'library.image');
     foreach ($images->children() as $image) {
         $check = false;
         $multiple = false;
         $image = (string) $image;
         if (JURI::isInternal($image)) {
             $internal = true;
             $int_image = JPATH_SITE . DS . $image;
             if (is_dir($int_image)) {
                 $check = JFolder::exists($int_image);
                 $multiple = true;
             } else {
                 $check = JFile::exists($int_image);
             }
             // Now check the extracted images path
             if (!$check) {
                 $dir = $this->_temp_dir . DS . 'images' . DS;
                 if (is_dir($dir . $image)) {
                     $check = JFolder::exists($dir . $image);
                     $multiple = true;
                 } else {
                     $check = JFile::exists($dir . $image);
                 }
                 if ($check) {
                     $image = $dir . $image;
                 }
             } else {
                 $image = $int_image;
             }
         } else {
             $internal = false;
             $check = $this->url_exists($image);
         }
         // Add a single image
         if (!$multiple) {
             $images_to_copy = array($image);
         } else {
             // Fetch the images from the folder and add them
             $images_to_copy = Tienda::getClass("TiendaHelperProduct", 'helpers.product')->getGalleryImages($image);
             foreach ($images_to_copy as &$i) {
                 $i = $image . DS . $i;
             }
         }
         if ($check) {
             foreach ($images_to_copy as $image_to_copy) {
                 if ($internal) {
                     $img = new TiendaImage($image_to_copy);
                 } else {
                     $tmp_path = JFactory::getApplication()->getCfg('tmp_path');
                     $file = fopen($image_to_copy, 'r');
                     $file_content = stream_get_contents($file);
                     fclose($file);
                     $file = fopen($tmp_path . DS . $image_to_copy, 'w');
                     fwrite($file, $file_content);
                     fclose($file);
                     $img = new TiendaImage($tmp_path . DS . $image_to_copy);
                 }
                 Tienda::load('TiendaTableProducts', 'tables.products');
                 $product = JTable::getInstance('Products', 'TiendaTable');
                 $product->load($product_id);
                 $path = $product->getImagePath();
                 $type = $img->getExtension();
                 $img->load();
                 $img->setDirectory($path);
                 // Save full Image
                 $img->save($path . $img->getPhysicalName());
                 // Save Thumb
                 Tienda::load('TiendaHelperImage', 'helpers.image');
                 $imgHelper = TiendaHelperBase::getInstance('Image', 'TiendaHelper');
                 $imgHelper->resizeImage($img, 'product');
             }
         }
     }
 }
Esempio n. 28
0
 /**
  * Returning total amount value
  *
  * @return unknown_type
  */
 function totalAmountDue()
 {
     $elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', JRequest::getVar('elements', '', 'post', 'string')));
     // convert elements to array that can be binded
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $helper = TiendaHelperBase::getInstance();
     $values = $helper->elementsToArray($elements);
     $response = array();
     $response['msg'] = '';
     $response['error'] = '';
     // get the order object so we can populate it
     $order = $this->_order;
     // a TableOrders object (see constructor)
     // bind what you can from the post
     $order->bind($values);
     // set the currency
     $order->currency_id = Tienda::getInstance()->get('default_currencyid', '1');
     // USD is default if no currency selected
     // get the items and add them to the order
     Tienda::load("TiendaHelperBase", 'helpers._base');
     //$cart_helper = TiendaHelperBase::getInstance( 'Carts' );
     //$items = $cart_helper->getProductsInfo();
     //foreach ($items as $item)
     //{
     //$order->addItem( $item );
     //}
     // get all coupons and add them to the order
     if (!empty($values['coupons'])) {
         foreach ($values['coupons'] as $coupon_id) {
             $coupon = JTable::getInstance('Coupons', 'TiendaTable');
             $coupon->load(array('coupon_id' => $coupon_id));
             $order->addCoupon($coupon);
         }
     }
     // get the order totals
     $order->calculateTotals();
     // now get the summary
     $html = $this->getTotalAmountDue();
     $response = array();
     $response['msg'] = $html;
     $response['error'] = '';
     // encode and echo (need to echo to send back to browser)
     echo json_encode($response);
 }
Esempio n. 29
0
 /**
  * Batch resize of thumbs
  * @author Skullbock
  */
 function recreateThumbs()
 {
     $per_step = 100;
     $from_id = JRequest::getInt('from_id', 0);
     $to = $from_id + $per_step;
     Tienda::load('TiendaHelperCategory', 'helpers.category');
     Tienda::load('TiendaImage', 'library.image');
     $width = Tienda::getInstance()->get('category_img_width', '0');
     $height = Tienda::getInstance()->get('category_img_height', '0');
     $model = $this->getModel('Categories', 'TiendaModel');
     $model->setState('limistart', $from_id);
     $model->setState('limit', $to);
     $row = $model->getTable();
     $count = $model->getTotal();
     $categories = $model->getList();
     $i = 0;
     $last_id = $from_id;
     foreach ($categories as $p) {
         $i++;
         $image = $p->category_full_image;
         $path = Tienda::getPath('categories_images');
         if ($image != '') {
             $img = new TiendaImage($path . '/' . $image);
             $img->setDirectory(Tienda::getPath('categories_images'));
             // Thumb
             Tienda::load('TiendaHelperImage', 'helpers.image');
             $imgHelper = TiendaHelperBase::getInstance('Image', 'TiendaHelper');
             $imgHelper->resizeImage($img, 'category');
         }
         $last_id = $p->category_id;
     }
     if ($i < $count) {
         $redirect = "index.php?option=com_tienda&controller=categories&task=recreateThumbs&from_id=" . ($last_id + 1);
     } else {
         $redirect = "index.php?option=com_tienda&view=config";
     }
     $redirect = JRoute::_($redirect, false);
     $this->setRedirect($redirect, JText::_('COM_TIENDA_DONE'), 'notice');
     return;
 }
Esempio n. 30
0
 /**
  * Verifies the fields in a submitted form.
  * Then adds the item to the users cart
  *
  * @return unknown_type
  */
 function addChildrenToCart()
 {
     JRequest::checkToken() or jexit('Invalid Token');
     $product_id = JRequest::getInt('product_id');
     $quantities = JRequest::getVar('quantities', array(0), 'request', 'array');
     $filter_category = JRequest::getInt('filter_category');
     Tienda::load("TiendaHelperRoute", 'helpers.route');
     $router = new TiendaHelperRoute();
     if (!($itemid = $router->product($product_id, $filter_category, true))) {
         $itemid = $router->category(1, true);
     }
     // set the default redirect URL
     $redirect = "index.php?option=com_tienda&view=products&task=view&id={$product_id}&filter_category={$filter_category}&Itemid=" . $itemid;
     $redirect = JRoute::_($redirect, false);
     Tienda::load('TiendaHelperBase', 'helpers._base');
     $helper = TiendaHelperBase::getInstance();
     if (!Tienda::getInstance()->get('shop_enabled', '1')) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_TIENDA_SHOP_DISABLED');
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     $items = array();
     // this will collect the items to add to the cart
     // convert elements to array that can be binded
     $values = JRequest::get('post');
     $attributes_csv = '';
     $user = JFactory::getUser();
     $cart_id = $user->id;
     $id_type = "user_id";
     if (empty($user->id)) {
         $session = JFactory::getSession();
         $cart_id = $session->getId();
         $id_type = "session";
     }
     Tienda::load('TiendaHelperCarts', 'helpers.carts');
     $carthelper = new TiendaHelperCarts();
     $cart_recurs = $carthelper->hasRecurringItem($cart_id, $id_type);
     // TODO get the children
     // loop thru each child,
     // get the list
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('ProductRelations', 'TiendaModel');
     $model->setState('filter_product', $product_id);
     $model->setState('filter_relation', 'parent');
     if ($children = $model->getList()) {
         foreach ($children as $child) {
             $product_qty = $quantities[$child->product_id_to];
             // Integrity checks on quantity being added
             if ($product_qty < 0) {
                 $product_qty = '1';
             }
             // using a helper file to determine the product's information related to inventory
             $availableQuantity = Tienda::getClass('TiendaHelperProduct', 'helpers.product')->getAvailableQuantity($child->product_id_to, $attributes_csv);
             if ($availableQuantity->product_check_inventory && $product_qty > $availableQuantity->quantity) {
                 $this->messagetype = 'notice';
                 $this->message = JText::_(JText::sprintf("COM_TIENDA_NOT_AVAILABLE_QUANTITY", $availableQuantity->product_name, $product_qty));
                 $this->setRedirect($redirect, $this->message, $this->messagetype);
                 return;
             }
             // do the item's charges recur? does the cart already have a subscription in it?  if so, fail with notice
             $product = JTable::getInstance('Products', 'TiendaTable');
             $product->load(array('product_id' => $child->product_id_to));
             // if product notforsale, fail
             if ($product->product_notforsale) {
                 $this->messagetype = 'notice';
                 $this->message = JText::_('COM_TIENDA_PRODUCT_NOT_FOR_SALE');
                 $this->setRedirect($redirect, $this->message, $this->messagetype);
                 return;
             }
             if ($product->product_recurs && $cart_recurs) {
                 $this->messagetype = 'notice';
                 $this->message = JText::_('COM_TIENDA_CART_ALREADY_RECURS');
                 $this->setRedirect($redirect, $this->message, $this->messagetype);
                 return;
             }
             if ($product->product_recurs) {
                 $product_qty = '1';
             }
             // create cart object out of item properties
             $item = new JObject();
             $item->user_id = JFactory::getUser()->id;
             $item->product_id = (int) $child->product_id_to;
             $item->product_qty = (int) $product_qty;
             $item->product_attributes = $attributes_csv;
             $item->vendor_id = '0';
             // vendors only in enterprise version
             // does the user/cart match all dependencies?
             $canAddToCart = $carthelper->canAddItem($item, $cart_id, $id_type);
             if (!$canAddToCart) {
                 $this->messagetype = 'notice';
                 $this->message = JText::_('COM_TIENDA_CANNOT_ADD_ITEM_TO_CART') . " - " . $carthelper->getError();
                 $this->setRedirect($redirect, $this->message, $this->messagetype);
                 return;
             }
             // no matter what, fire this validation plugin event for plugins that extend the checkout workflow
             $results = array();
             $dispatcher = JDispatcher::getInstance();
             $results = $dispatcher->trigger("onBeforeAddToCart", array($item, $values));
             for ($i = 0; $i < count($results); $i++) {
                 $result = $results[$i];
                 if (!empty($result->error)) {
                     $this->messagetype = 'notice';
                     $this->message = $result->message;
                     $this->setRedirect($redirect, $this->message, $this->messagetype);
                     return;
                 }
             }
             // if here, add to cart
             $items[] = $item;
         }
     }
     if (!empty($items)) {
         Tienda::load('TiendaHelperCarts', 'helpers.carts');
         foreach ($items as $item) {
             // add the item to the cart
             $cart_helper = new TiendaHelperCarts();
             $cartitem = $cart_helper->addItem($item);
             // fire plugin event
             $dispatcher = JDispatcher::getInstance();
             $dispatcher->trigger('onAfterAddToCart', array($cartitem, $values));
         }
         $this->messagetype = 'message';
         $this->message = JText::_('COM_TIENDA_ITEMS_ADDED_TO_YOUR_CART');
     }
     // After login, session_id is changed by Joomla, so store this for reference
     $session = JFactory::getSession();
     $session->set('old_sessionid', $session->getId());
     // get the 'success' redirect url
     // TODO Enable redirect via base64_encoded urls?
     switch (Tienda::getInstance()->get('addtocartaction', 'redirect')) {
         case "redirect":
             $returnUrl = base64_encode($redirect);
             $itemid = $router->findItemid(array('view' => 'checkout'));
             $redirect = JRoute::_("index.php?option=com_tienda&view=carts&Itemid=" . $itemid, false);
             if (strpos($redirect, '?') === false) {
                 $redirect .= "?return=" . $returnUrl;
             } else {
                 $redirect .= "&return=" . $returnUrl;
             }
             break;
         case "0":
         case "none":
             break;
         case "lightbox":
         default:
             // TODO Figure out how to get the lightbox to display even after a redirect
             break;
     }
     $this->setRedirect($redirect, $this->message, $this->messagetype);
     return;
 }