function fetchElement($name, $value, &$node, $control_name) { $output = ' <input type="text" class="text_area" value="" id="pluginstiendaproductPrice" name="plugins[tiendaproductPrice]"> <span class="k2Note">' . JText::_('Set Normal Price Now Special Prices Later') . '</span> '; $id = JRequest::getInt('cid'); if ($id) { $K2Item = JTable::getInstance('K2Item', 'Table'); $K2Item->load($id); $params = new K2Parameter($K2Item->plugins, JPATH_PLUGINS . '/k2/tienda.xml', 'tienda'); $productID = $params->get('productID'); if ($productID) { Tienda::load('TiendaUrl', 'library.url'); Tienda::load("TiendaHelperProduct", 'helpers.product'); $prices = TiendaHelperProduct::getPrices($productID); if (count($prices)) { $output = '<div class="tiendaButton">' . TiendaUrl::popup("index.php?option=com_tienda&controller=products&task=setprices&id=" . $productID . "&tmpl=component", JText::_('COM_TIENDA_SET_PRICES')) . '</div>'; $output .= '<div>'; foreach (@$prices as $price) { $output .= ' <div> <span>' . TiendaHelperBase::currency($price->product_price) . '</span> <div class="tiendaButton"><a href="' . $price->link_remove . '&return=' . base64_encode("index.php?option=com_k2&view=item&cid=" . $id) . '">' . JText::_('Remove') . '</a></div> </div>'; } $output .= '</div>'; } } } return $output; }
/** * Checks row for data integrity. * Assumes working dates have been converted to local time for display, * so will always convert working dates to GMT * * @return unknown_type */ function check() { if (empty($this->product_id)) { $this->setError(JText::_('COM_TIENDA_PRODUCT_ASSOCIATION_REQUIRED')); return false; } $offset = JFactory::getConfig()->getValue('config.offset'); if (isset($this->publishing_date)) { $this->publishing_date = date('Y-m-d H:i:s', strtotime(TiendaHelperBase::getOffsetDate($this->publishing_date, -$offset))); } $nullDate = $this->_db->getNullDate(); Tienda::load('TiendaHelperBase', 'helpers._base'); if (empty($this->created_date) || $this->created_date == $nullDate) { $date = JFactory::getDate(); $this->created_date = $date->toMysql(); } $date = JFactory::getDate(); $this->modified_date = $date->toMysql(); $act = strtotime(Date('Y-m-d', strtotime($this->publishing_date))); $db = $this->_db; if (empty($this->product_issue_id)) { $q = 'SELECT `publishing_date` FROM `#__tienda_productissues` WHERE `product_id`=' . $this->product_id . ' ORDER BY `publishing_date` DESC LIMIT 1'; $db->setQuery($q); $next = $db->loadResult(); if ($next === null) { return true; } $next = strtotime($next); if ($act <= $next) { $this->setError(JText::_('COM_TIENDA_PUBLISHING_DATE_IS_NOT_PRESERVING_ISSUE_ORDER') . ' - ' . $this->publishing_date); return false; } } else { $q = 'SELECT `publishing_date` FROM `#__tienda_productissues` WHERE `product_issue_id`=' . $this->product_issue_id; $db->setQuery($q); $original = $db->loadResult(); if ($act == strtotime(Date('Y-m-d', strtotime($original)))) { return true; } $q = 'SELECT `publishing_date` FROM `#__tienda_productissues` WHERE `product_id`=' . $this->product_id . ' AND `publishing_date` < \'' . $original . '\' ORDER BY `publishing_date` DESC LIMIT 1'; $db->setQuery($q); $prev = $db->loadResult(); $q = 'SELECT `publishing_date` FROM `#__tienda_productissues` WHERE `product_id`=' . $this->product_id . ' AND `publishing_date` > \'' . $original . '\' ORDER BY `publishing_date` ASC LIMIT 1'; $db->setQuery($q); $next = $db->loadResult(); if ($prev === null) { $prev = 0; } else { $prev = strtotime($prev); } if ($next) { $next = strtotime($next); } if ($prev >= $act || $next && $next <= $act) { $this->setError(JText::_('COM_TIENDA_PUBLISHING_DATE_IS_NOT_PRESERVING_ISSUE_ORDER') . ' - ' . $this->publishing_date); return false; } } return true; }
/** * 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); } }
/** * 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; }
/** * Checks row for data integrity. * Assumes working dates have been converted to local time for display, * so will always convert working dates to GMT * * @return unknown_type */ function check() { if (empty($this->product_id)) { $this->setError(JText::_('COM_TIENDA_PRODUCT_ASSOCIATION_REQUIRED')); return false; } $nullDate = $this->_db->getNullDate(); Tienda::load('TiendaHelperBase', 'helpers._base'); $TiendaHelperBase = new TiendaHelperBase(); $this->product_price_startdate = $this->product_price_startdate != $nullDate ? $TiendaHelperBase->getOffsetDate($this->product_price_startdate) : $this->product_price_startdate; $this->product_price_enddate = $this->product_price_enddate != $nullDate ? $TiendaHelperBase->getOffsetDate($this->product_price_enddate) : $this->product_price_enddate; if (empty($this->created_date) || $this->created_date == $nullDate) { $date = JFactory::getDate(); $this->created_date = $date->toMysql(); } $date = JFactory::getDate(); $this->modified_date = $date->toMysql(); return true; }
/** * Method to get content article data for the frontpage * * @since 1.5 */ function getList() { $where = array(); $mainframe = JFactory::getApplication(); if (!empty($this->_list)) { return $this->_list; } // Initialize variables $db = $this->getDBO(); $filter = null; // Get some variables from the request // $sectionid = JRequest::getVar( 'sectionid', -1, '', 'int' ); // $redirect = $sectionid; // $option = JRequest::getCmd( 'option' ); $filter_order = $mainframe->getUserStateFromRequest('userelement.filter_order', 'filter_order', '', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest('userelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest('userelement.limitstart', 'limitstart', 0, 'int'); $search = $mainframe->getUserStateFromRequest('userelement.search', 'search', '', 'string'); $search = JString::strtolower($search); if (!$filter_order) { $filter_order = 'tbl.product_id'; } $order = ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir; $all = 1; // Keyword filter if ($search) { $where[] = 'LOWER( tbl.product_id ) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false); $where[] = 'LOWER( tbl.product_name ) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false); } // Build the where clause of the query $where = count($where) ? ' WHERE ' . implode(' OR ', $where) : ''; // Get the total number of records $query = 'SELECT COUNT(tbl.product_id)' . ' FROM #__tienda_products AS tbl' . $where; $db->setQuery($query); $total = $db->loadResult(); // Create the pagination object jimport('joomla.html.pagination'); $this->_page = new JPagination($total, $limitstart, $limit); // Get the products $query = 'SELECT tbl.*, pp.* ' . ' FROM #__tienda_products AS tbl' . ' LEFT JOIN #__tienda_productprices pp ON pp.product_id = tbl.product_id ' . $where . $order; $db->setQuery($query, $this->_page->limitstart, $this->_page->limit); $this->_list = $db->loadObjectList(); //currency formatting Tienda::load('TiendaHelperBase', 'helpers._base'); foreach ($this->_list as $item) { $item->product_price = TiendaHelperBase::currency($item->product_price); } // If there is a db query error, throw a HTTP 500 and exit if ($db->getErrorNum()) { JError::raiseError(500, $db->stderr()); return false; } return $this->_list; }
/** * 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; }
/** * * @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; }
/** * * @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; }
/** * Protected! Use the getInstance */ protected function TiendaHelperImage() { // Parent Helper Construction parent::__construct(); $config = Tienda::getInstance(); // Load default Parameters $this->product_img_height = $config->get('product_img_height'); $this->product_img_width = $config->get('product_img_width'); $this->category_img_height = $config->get('category_img_height'); $this->category_img_width = $config->get('category_img_width'); $this->manufacturer_img_width = $config->get('manufacturer_img_width'); $this->manufacturer_img_height = $config->get('manufacturer_img_height'); $this->product_img_path = Tienda::getPath('products_images'); $this->category_img_path = Tienda::getPath('categories_images'); $this->manufacturer_img_path = Tienda::getPath('manufacturers_images'); $this->product_thumb_path = Tienda::getPath('products_thumbs'); $this->category_thumb_path = Tienda::getPath('categories_thumbs'); $this->manufacturer_thumb_path = Tienda::getPath('manufacturers_thumbs'); }
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); }
public function store($updateNulls = false) { // Check the table activation status first if (!$this->active) { // Activate it with a default value $this->setType(''); } if ($this->getType() == 'datetime') { if (isset($this->eavvalue_value)) { $null_date = JFactory::getDbo()->getNullDate(); if ($this->eavvalue_value == $null_date || $this->eavvalue_value == '') { $this->eavvalue_value = $null_date; } else { $offset = JFactory::getConfig()->getValue('config.offset'); $this->eavvalue_value = date('Y-m-d H:i:s', strtotime(TiendaHelperBase::getOffsetDate($this->eavvalue_value, -$offset))); } } } return parent::store($updateNulls); }
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); }
<?php if ($show_addtocart) { ?> <div id="product_buy_<?php echo $item->product_id; ?> " class="product_buy"> <?php echo TiendaHelperProduct::getCartButton($item->product_id, 'product_buy', array()); ?> </div> <?php } else { ?> <?php echo TiendaHelperBase::currency($item->product_price); ?> <?php } ?> </td> <?php } ?> </tr> <?php } ?>
/** * 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; }
/** * * Enter description here ... * @return unknown_type */ public function deleteExpiredSessionProductCompared() { $db = JFactory::getDBO(); Tienda::load('TiendaQuery', 'library.query'); Tienda::load("TiendaHelperBase", 'helpers._base'); $helper = new TiendaHelperBase(); $query = new TiendaQuery(); $query->select("tbl.session_id"); $query->from("#__session AS tbl"); $db->setQuery((string) $query); $results = $db->loadAssocList(); $session_ids = $helper->getColumn($results, 'session_id'); $query = new TiendaQuery(); $query->delete(); $query->from("#__tienda_productcompare"); $query->where("`user_id` = '0'"); $query->where("`session_id` NOT IN('" . implode("', '", $session_ids) . "')"); $db->setQuery((string) $query); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } $date = JFactory::getDate(); $now = $date->toMySQL(); // Update config to say this has been done already JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); $config = JTable::getInstance('Config', 'TiendaTable'); $config->load(array('config_name' => 'last_deleted_expired_sessionproductscompared')); $config->config_name = 'last_deleted_expired_sessionproductscompared'; $config->value = $now; $config->save(); return true; }
/** * 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'); } } } }
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) : ''; }
echo $item->shipping_address_2 ? $item->shipping_address_2 . ", " : ""; echo $item->shipping_city . ", "; echo $item->shipping_zone_name . " "; echo $item->shipping_postal_code . " "; echo $item->shipping_country_name; } ?> <?php if (!empty($item->order_number)) { echo "<br/><b>" . JText::_('COM_TIENDA_ORDER_NUMBER') . "</b>: " . $item->order_number; } ?> </td> <td style="text-align: center;"> <?php echo TiendaHelperBase::currency($item->order_total, $item->currency); ?> <?php if (!empty($item->commissions)) { ?> <br/> <?php JHTML::_('behavior.tooltip'); ?> <a href="index.php?option=com_amigos&view=commissions&filter_orderid=<?php echo $item->order_id; ?> " target="_blank"> <img src='<?php echo JURI::root(true); ?>
/** * 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) : ''; }
/** * Method to add translation strings to JS translation object * * @param $strings Associative array with list of strings to translate * */ public static function addJsTranslationStrings($strings) { if (self::$added_strings === null) { self::$added_strings = array(); } JHTML::_('script', 'tienda_lang.js', 'media/com_tienda/js/'); $js_strings = array(); for ($i = 0, $c = count($strings); $i < $c; $i++) { if (in_array(strtoupper($strings[$i]), self::$added_strings) === false) { $js_strings[] = '"' . strtoupper($strings[$i]) . '":"' . JText::_($strings[$i]) . '"'; self::$added_strings[] = strtoupper($strings[$i]); } } if (count($js_strings)) { $doc = JFactory::getDocument(); $doc->addScriptDeclaration('Joomla.JText.load({' . implode(',', $js_strings) . '});'); } }
if (strlen($item->manufacturer_name)) { echo $item->manufacturer_name; } else { echo ' - ' . JText::_('COM_TIENDA_NO_MANUFACTURER') . ' - '; } ?> </td> <td style="text-align: center;"> <?php echo @$item->count_items; ?> </td> <td style="text-align: center;"> <?php echo @TiendaHelperBase::currency($item->price_total); ?> </td> </tr> <?php $k = 1 - $k; ?> <?php } ?> <?php if (!count(@$items)) { ?> <tr> <td colspan="10" align="center">
/** * 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; }
/** * * 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; }
<?php if ($display_credits) { ?> <div class="reset marginbot"></div> <?php if ($this->userinfo->credits_total > '0.00') { ?> <!-- STORE CREDITS --> <div id="credits_area" class="address"> <div id="credits_form"> <h3><?php echo JText::_('COM_TIENDA_STORE_CREDIT'); ?> </h3> <div id="credit_help"><?php echo sprintf(JText::_('COM_TIENDA_YOU_HAVE_STORE_CREDIT'), TiendaHelperBase::currency($this->userinfo->credits_total, Tienda::getInstance()->get('default_currencyid', 1))); ?> </div> <div id="credit_message"></div> <input type="text" name="apply_credit_amount" id="apply_credit_amount" value="" /> <input type="button" name="credit_submit" value="<?php echo JText::_('COM_TIENDA_APPLY_CREDIT_TO_ORDER'); ?> " onClick="tiendaAddCredit( document.adminForm );"/> </div> </div> <?php } ?> <div id='applied_credit' style="display: none;"></div> <?php
<?php defined('_JEXEC') or die('Restricted access'); JHTML::_('script', 'tienda.js', 'media/com_tienda/js/'); $state = @$this->state; $items = @$this->items; $citems = @$this->citems; Tienda::load('TiendaHelperProduct', 'helpers.product'); $config = Tienda::getInstance(); $product_compare = $config->get('enable_product_compare', '1'); $plugins_short_desc = $config->get('content_plugins_product_desc', '0'); $js_strings = array('COM_TIENDA_ADDING_PRODUCT_FOR_COMPARISON', 'COM_TIENDA_REMOVING_PRODUCT'); TiendaHelperBase::addJsTranslationStrings($js_strings); ?> <div id="tienda" class="products default"> <?php if ($this->level > 1 && $config->get('display_tienda_pathway')) { ?> <div id='tienda_breadcrumb'> <?php echo TiendaHelperCategory::getPathName($this->cat->category_id, 'links'); ?> </div> <?php } ?> <?php if ($product_compare) { ?> <?php
<tr> <th style="width: 100px;" class="key"> <?php echo JText::_('COM_TIENDA_SHIPPING_TAX'); ?> : </th> <td> <?php echo TiendaHelperBase::currency(@$this->shipping_total->shipping_tax_total); ?> </td> </tr> <tr> <th style="width: 100px;" class="key"> <label for="grand_total" style="color:#1432F2;font-size:16px;"> <?php echo JText::_('COM_TIENDA_GRAND_TOTAL'); ?> : </label> </th> <td style="color:#1432F2;font-size:16px;"> <?php echo TiendaHelperBase::currency(@$totals->order_total); ?> </td> </tr> </tbody> </table>
/** * 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; }
?> <tr> <td colspan="3" style="font-weight: bold; white-space: nowrap;"> <?php echo JText::_('COM_TIENDA_STORE_CREDIT'); ?> </td> <td colspan="3" style="text-align: right;"> - <?php echo TiendaHelperBase::currency($order->order_credit); ?> </td> </tr> <?php } ?> <tr> <td colspan="3" style="font-weight: bold; white-space: nowrap;"> <?php echo JText::_('COM_TIENDA_TOTAL'); ?> </td> <td colspan="3" style="text-align: right;"> <?php echo TiendaHelperBase::currency($order->order_total); ?> </td> </tr> </table> </div>
/** * Generates the xml for the update request * @param unknown_type $product * @param string $etag - etag of the product */ protected function getUpdateXML($product, $etag) { // perform the insertion Tienda::load('TiendaArrayToXML', 'library.xml'); // Populate the xml request $xml = array(); $xml['app:control']['sc:required_destination']['attributes']['dest'] = 'ProductSearch'; // Title, id and description $xml['title'] = $product->product_name; $xml['content']['attributes']['type'] = 'text/html'; $xml['content'] = $product->product_description; $xml['sc:id'] = $product->product_id; // Link to the product Tienda::load('TiendaHelperRoute', 'helpers.route'); $xml['link']['attributes']['rel'] = 'alternate'; $xml['link']['attributes']['type'] = 'text/html'; $baseurl = str_replace("/administrator/", "/", JURI::base()); $xml['link']['attributes']['href'] = $baseurl . TiendaHelperRoute::product($product->product_id); //$xml['link']['attributes']['href'] = 'http://www.weble.it/products/'.$product->product_id; // Condition $xml['scp:condition'] = 'new'; // Price $currency_id = Tienda::getInstance()->get('default_currencyid', '1'); Tienda::load('TiendaTableCurrencies', 'tables.currencies'); $currency = JTable::getInstance('Currencies', 'TiendaTable'); $currency->load((int) $currency_id); $xml['scp:price']['attributes']['unit'] = trim(strtoupper($currency->currency_code)); $xml['scp:price']['@value'] = TiendaHelperBase::number(TiendaHelperProduct::getPrice($product->product_id)->product_price, array('num_decimals', '0')); // Manufacturer Tienda::load('TiendaTableManufacturers', 'tables.manufacturers'); $manufacturer = JTable::getInstance('Manufacturers', 'TiendaTable'); if ($manufacturer->load($product->manufacturer_id)) { $xml['scp:brand'] = $manufacturer->manufacturer_name; } $xml['entry']['attributes']['gd:etag'] = $etag; // Create the request $null = null; $helper = new TiendaArrayToXML(); $ns = array(array('name' => 'app', 'url' => "http://www.w3.org/2007/app"), array('name' => 'gd', 'url' => "http://schemas.google.com/g/2005"), array('name' => 'sc', 'url' => "http://schemas.google.com/structuredcontent/2009"), array('name' => 'scp', 'url' => "http://schemas.google.com/structuredcontent/2009/products")); $xml = $helper->toXml($xml, 'entry', $null, $ns, "http://www.w3.org/2005/Atom"); return $xml; }