function getCart() { Citruscart::load('CitruscartHelperCarts', 'helpers.carts'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_citruscart/models'); // determine whether we're working with a session or db cart $suffix = CitruscartHelperCarts::getSuffix(); $model = JModelLegacy::getInstance('Carts', 'CitruscartModel'); $session = JFactory::getSession(); $user = JFactory::getUser(); $model->setState('filter_user', $user->id); if (empty($user->id)) { $model->setState('filter_session', $session->getId()); } $list = $model->getList(false, false); Citruscart::load('Citruscart', 'defines'); $config = Citruscart::getInstance(); $show_tax = $config->get('display_prices_with_tax'); $this->using_default_geozone = false; if ($show_tax) { Citruscart::load('CitruscartHelperUser', 'helpers.user'); $geozones = CitruscartHelperUser::getGeoZones(JFactory::getUser()->id); if (empty($geozones)) { // use the default $this->using_default_geozone = true; $table = JTable::getInstance('Geozones', 'CitruscartTable'); $table->load(array('geozone_id' => Citruscart::getInstance()->get('default_tax_geozone'))); $geozones = array($table); } Citruscart::load("CitruscartHelperProduct", 'helpers.product'); foreach ($list as &$item) { $taxtotal = CitruscartHelperProduct::getTaxTotal($item->product_id, $geozones); $item->product_price = $item->product_price + $taxtotal->tax_total; $item->taxtotal = $taxtotal; } } return $list; }
/*------------------------------------------------------------------------ # com_citruscart # ------------------------------------------------------------------------ # author Citruscart Team - Citruscart http://www.citruscart.com # copyright Copyright (C) 2014 Citruscart.com All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://citruscart.com # Technical Support: Forum - http://citruscart.com/forum/index.html -------------------------------------------------------------------------*/ /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); $app = JFactory::getApplication(); $form = $this->form; $row = $this->row; $helper_product = new CitruscartHelperProduct(); ?> <legend> <?php echo JText::_('COM_CITRUSCART_BASIC_INFORMATION'); ?> </legend> <div style="float: left; margin: 5px;"> <table class="table table-striped table-bordered"> <tr> <td style="width: 100px; text-align: right;" class="dsc-key"><?php echo JText::_('COM_CITRUSCART_NAME'); ?> :</td> <td class="dsc-value"><input type="text" name="product_name" id="product_name" value="<?php
$display_gp = $this->defines->get('display_google_plus1', '1'); if ($display_fb || $display_gp || $display_tw) { ?> <div class="product_share_buttons_wishlist pull-left" > <?php } if ($display_fb) { ?> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like show_faces="false" width="375"></fb:like> <?php } if ($display_tw) { ?> <a href="http://twitter.com/share" class="twitter-share-button" data-text="<?php echo Citruscart::getInstance()->get('display_tweet_message', 'Check this out!') . ' ' . CitruscartHelperProduct::getSocialBookMarkUri(); ?> " data-count="horizontal">Tweet</a> <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> <?php } if ($display_gp) { $google_plus1_size = Citruscart::getInstance()->get('display_google_plus1_size', 'medium'); ?> <g:plusone <?php if (strlen($google_plus1_size)) { echo 'size="' . $google_plus1_size . '"'; } ?> ></g:plusone> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<?php echo JText::_('COM_CITRUSCART_PRICE'); ?> : <?php echo CitruscartHelperBase::currency($item->product_price); ?> <?php } ?> <?php if ($config->product_review_enable) { ?> <br/> <?php echo CitruscartHelperProduct::getRatingImage($item->product_rating); ?> <?php } ?> <br/> <?php if (!empty($this->onDisplayCartItem) && !empty($this->onDisplayCartItem[$i])) { ?> <div class='onDisplayCartItem_wrapper_<?php echo $i; ?> '> <?php echo $this->onDisplayCartItem[$i];
foreach ($items as $item) { ?> <tr> <td style="text-align: left;"> <?php echo $item->product_name; ?> </td> <td style="text-align: left;"> <?php echo $item->product_sku; ?> </td> <td style="text-align: center;"> <?php echo CitruscartHelperProduct::dispayPriceWithTax($item->product_price, $item->tax, $item->showtax); ?> </td> <td style="text-align: center;"> <input type="text" name="quantities[<?php echo $item->product_id; ?> ]" value="1" size="5" /> </td> </tr> <?php $k = 1 - $k; ?> <?php } ?>
/** * Migrate a single product files * * param CitruscartTableProduct $product * param array $data */ private function _migrateFiles($product_id, $files) { foreach ($files->children() as $file) { // Add the File $table = JTable::getInstance('ProductFiles', 'CitruscartTable'); $table->bind($this->simpleXml2Array($file)); $table->product_id = $product_id; // Now the files on the zip have to be linked $dest_dir = CitruscartHelperProduct::getFilePath($product_id); $source_dir = $this->_temp_dir . DIRECTORY_SEPARATOR . 'files' . DS; $filename = $table->productfile_name; $path = $dest_dir . DIRECTORY_SEPARATOR . $filename; $namebits = explode('.', $filename); $extension = $namebits[count($namebits) - 1]; $table->productfile_extension = $extension; $table->productfile_path = $path; // If the files exists & the copy is successfull, save the file if (JFile::exists($source_dir . $filename)) { if (JFile::copy($source_dir . $filename, $dest_dir . DIRECTORY_SEPARATOR . $filename)) { $table->save(); } } } }
"><?php echo $product->product_name; ?> </a></h5> <?php } ?> <?php if ($params->get('display_price', '1') != '0') { ?> <span class="product_price"> <strong> <h5> <?php echo $prices = CitruscartHelperProduct::dispayPriceWithTax($product->price, $product->tax, Citruscart::getInstance()->get('display_prices_with_tax')); ?> </h5> </strong> </span> <?php } ?> </span><!-- popular product options span ends --> <!-- <?php if ($params->get('display_description', '1') != '0' && $product->product_description_short != null) { ?> <p class="product_description"><?php echo $product->product_description_short;
echo CitruscartHelperProduct::getImage($item->product_id, 'id', $item->product_name, 'thumb', false, false, array('width' => 64)); ?> </td> <td style="text-align: left;"> <?php echo $item->product_name; ?> </td> <td style="text-align: left;"> <?php echo $item->product_sku; ?> </td> <td style="text-align: center;"> <?php echo CitruscartHelperProduct::dispayPriceWithTax($item->product_price, $item->tax, $this->product_relations_data->show_tax); ?> </td> <td style="text-align: center;"> <div id='product_quantity_input_<?php echo $item->product_id; ?> ' class="product_quantity_input"> <?php if ($item->full_object->product_parameters->get('hide_quantity_input') == '1') { ?> <input type="hidden" name="quantities[<?php echo $item->product_id; ?> ]" value="<?php echo $item->full_object->product_parameters->get('default_quantity', '1');
/** * Run function when deleting * @see Citruscart/admin/tables/CitruscartTable#save() */ function delete($oid = null, $doReconciliation = true) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } if ($doReconciliation) { $pa = JTable::getInstance('ProductAttributes', 'CitruscartTable'); if ($oid) { $row = JTable::getInstance('ProductAttributeOptions', 'CitruscartTable'); $row->load($oid); $pa->load($row->productattribute_id); } else { $pa->load($this->productattribute_id); } $product_id = $pa->product_id; } if ($return = parent::delete($oid)) { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('ProductAttributeOptionValues', 'CitruscartModel'); $model->setState('filter_option', $this->{$k}); if ($items = $model->getList()) { $table = $model->getTable(); foreach ($items as $item) { if (!$table->delete($item->productattributeoptionvalue_id)) { $this->setError($table->getError()); } } } if ($doReconciliation) { Citruscart::load("CitruscartHelperProduct", 'helpers.product'); CitruscartHelperProduct::doProductQuantitiesReconciliation($product_id); } } return parent::check(); }
?> <?php } ?> </span> <?php } ?> <!--attribute options--> <div id='product_attributeoptions_<?php echo $item->product_id; ?> ' class="product_attributeoptions"> <?php $attributes = CitruscartHelperProduct::getAttributes($item->product_id); foreach ($attributes as $attribute) { ?> <div class="pao" id='productattributeoption_<?php echo $attribute->productattribute_id; ?> '> <?php echo "<span>" . $attribute->productattribute_name . " : </span>"; $key = 'attribute_' . $attribute->productattribute_id; $selected = !empty($values[$key]) ? $values[$key] : ''; Citruscart::load('CitruscartSelect', 'library.select'); /* $attribs = array('class' => 'inputbox', 'size' => '1', 'onchange'=>"Citruscart.UpdateAddToCart( 'product','product_buy_".$item->product_id."', document.".$formName.", ".$working_image.", '".JText::_('COM_CITRUSCART_UPDATING_ATTRIBUTES')."' );"
public function isAvailable() { // create cart object out of item properties $item = new JObject(); $item->user_id = $this->user_id; $item->product_id = (int) $this->product_id; $item->product_qty = !empty($this->product_quantity) ? $this->product_quantity : '1'; $item->product_attributes = $this->product_attributes; $item->vendor_id = $this->vendor_id; $item->cartitem_params = $this->wishlistitem_params; DSCTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); $product = DSCTable::getInstance('Products', 'CitruscartTable'); $product->load(array('product_id' => $this->product_id)); if (empty($product->product_enabled) || empty($product->product_id)) { $this->setError(JText::_('COM_CITRUSCART_INVALID_PRODUCT')); return false; } if ($product->product_notforsale) { $this->setError(JText::_('COM_CITRUSCART_PRODUCT_NOT_FOR_SALE')); return false; } Citruscart::load('CitruscartHelperProduct', 'helpers.product'); $product_helper = new CitruscartHelperProduct(); $availableQuantity = $product_helper->getAvailableQuantity($item->product_id, $item->product_attributes); if ($availableQuantity->product_check_inventory && $item->product_qty > $availableQuantity->quantity) { $this->setError(JText::sprintf("COM_CITRUSCART_NOT_AVAILABLE_QUANTITY", $availableQuantity->product_name, $item->product_qty)); return false; } $results = array(); $dispatcher = JDispatcher::getInstance(); $results = JFactory::getApplication()->triggerEvent("onIsWishlistItemAvailable", array(&$item)); for ($i = 0; $i < count($results); $i++) { $result = $results[$i]; if (!empty($result->error)) { $this->setError($result->message); return false; } } return true; }
/** * Change the default image * @return unknown_type */ function updateDefaultImage() { $app = JFactory::getApplication(); $response = array(); $response['default_image'] = ''; $response['default_image_name'] = ''; $product_id = $app->input->getInt('product_id'); Citruscart::load('CitruscartUrl', 'library.url'); Citruscart::load("CitruscartHelperProduct", 'helpers.product'); $row = JTable::getInstance('Products', 'CitruscartTable'); $row->load($product_id); $response['default_image'] = CitruscartHelperProduct::getImage($row->product_id, 'id', $row->product_name, 'full', false, false, array('height' => 80)); $response['default_image_name'] = $row->product_full_image; echo json_encode($response); // Close the application. JFactory::getApplication()->close(); }
/** * Creates a file from disk and redirects * * @return unknown_type */ function createfilefromdisk() { JPluginHelper::importPlugin('citruscart'); $app = JFactory::getApplication(); $this->set('suffix', 'productfiles'); $model = $this->getModel($this->get('suffix')); $file = $app->input->get('createproductfileserver_file'); $row = $model->getTable(); $row->product_id = $app->input->get('id'); $row->productfile_name = $app->input->get('createproductfileserver_name'); $row->productfile_enabled = $app->input->get('createproductfileserver_enabled'); $row->purchase_required = $app->input->get('createproductfileserver_purchaserequired'); $row->max_download = $app->input->getInt('createproductfileserver_max_download', -1); if (empty($row->productfile_name)) { $row->productfile_name = $file; } Citruscart::load("CitruscartHelperProduct", 'helpers.product'); $path = CitruscartHelperProduct::getFilePath($row->product_id) . DS . $file; $namebits = explode('.', $file); $extension = $namebits[count($namebits) - 1]; $row->productfile_extension = $extension; $row->productfile_path = $path; if ($row->save()) { $model->clearCache(); $app->triggerEvent('onAfterSave' . $this->get('suffix'), array($row)); $this->messagetype = 'notice'; $this->message = JText::_('COM_CITRUSCART_UPLOAD_WAS_SUCCESSFULL'); } else { $this->messagetype = 'notice'; $this->message = JText::_('COM_CITRUSCART_SAVE_FAILED') . " - " . $row->getError(); } $redirect = "index.php?option=com_citruscart&view=products&task=setfiles&id={$row->product_id}&tmpl=component"; $redirect = JRoute::_($redirect, false); $this->setRedirect($redirect, $this->message, $this->messagetype); }
/** * Gets all the product's user reviews * @param $product_id * @return unknown_type */ function getComments($product_id) { $input = JFactory::getApplication()->input; $html = ''; $view = $this->getView('products', 'html'); JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = JModelLegacy::getInstance('productcomments', 'CitruscartModel'); $selectsort = $input->get('default_selectsort', ''); $model->setstate('order', $selectsort); $limitstart = $input->getInt('limitstart', 0); $model->setId($product_id); $model->setstate('limitstart', $limitstart); $model->setstate('filter_product', $product_id); $model->setstate('filter_enabled', '1'); $reviews = $model->getList(); $count = count($reviews); $view->set('_controller', 'products'); $view->set('_view', 'products'); $view->set('_doTask', true); $view->set('hidemenu', true); $view->setModel($model, true); $view->setLayout('product_comments'); $view->assign('product_id', $product_id); $view->assign('count', $count); $view->assign('reviews', $reviews); $user_id = JFactory::getUser()->id; $productreview = CitruscartHelperProduct::getUserAndProductIdForReview($product_id, $user_id); $purchase_enable = Citruscart::getInstance()->get('purchase_leave_review_enable', '0'); $login_enable = Citruscart::getInstance()->get('login_review_enable', '0'); $product_review_enable = Citruscart::getInstance()->get('product_review_enable', '0'); $result = 1; if ($product_review_enable == '1') { $review_enable = 1; } else { $review_enable = 0; } if ($login_enable == '1') { if ($user_id) { $order_enable = '1'; if ($purchase_enable == '1') { $orderexist = CitruscartHelperProduct::getOrders($product_id); if (!$orderexist) { $order_enable = '0'; } } if ($order_enable != '1' || !empty($productreview)) { $result = 0; } } else { $result = 0; } } $view->assign('review_enable', $review_enable); $view->assign('result', $result); $view->assign('click', 'index.php?option=com_citruscart&controller=products&view=products&task=addReview'); $view->assign('selectsort', $selectsort); ob_start(); $view->display(); $html = ob_get_contents(); ob_end_clean(); return $html; }
/*------------------------------------------------------------------------ # com_citruscart # ------------------------------------------------------------------------ # author Citruscart Team - Citruscart http://www.citruscart.com # copyright Copyright (C) 2014 Citruscart.com All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://citruscart.com # Technical Support: Forum - http://citruscart.com/forum/index.html # Fork of Tienda # @license GNU/GPL Based on Tienda by Dioscouri Design http://www.dioscouri.com. -------------------------------------------------------------------------*/ /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); $form = @$this->form; $row = @$this->row; $helper_product = new CitruscartHelperProduct(); ?> <table class="table table-striped table-bordered"> <?php if (empty($row->product_id)) { // doing a new product, so display a notice ?> <tr> <td class="dsc-key"><?php echo JText::_('COM_CITRUSCART_PRODUCT_FILES'); ?> :</td> <td> <div class="note well"> <?php
/** * Add review * */ function addReview() { $input = JFactory::getApplication()->input; JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); Citruscart::load('CitruscartHelperProduct', 'helpers.product'); $productreviews = JTable::getInstance('productcomments', 'CitruscartTable'); $post = $input->getArray($_POST); $product_id = $post['product_id']; $Itemid = $post['Itemid']; $user = JFactory::getUser(); $valid = true; $this->messagetype = 'message'; $productcomment = CitruscartHelperProduct::strip_html_tags($post['productcomment_text']); //set in case validation fails $linkAdd = ''; $linkAdd .= '&rn=' . base64_encode($post['user_name']); $linkAdd .= '&re=' . base64_encode($post['user_email']); $linkAdd .= '&rc=' . base64_encode($productcomment); if (!$user->id) { if (empty($post['user_name']) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_NAME_FIELD_IS_REQUIRED'); $this->messagetype = 'notice'; } jimport('joomla.mail.helper'); if (!JMailHelper::isEmailAddress($post['user_email']) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_PLEASE_ENTER_A_CORRECT_EMAIL_ADDRESS'); $this->messagetype = 'notice'; } if (in_array($post['user_email'], CitruscartHelperProduct::getUserEmailForReview($post['product_id'])) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_YOU_ALREADY_SUBMITTED_A_REVIEW_CAN_ONLY_SUBMIT_REVIEW_ONCE'); $this->messagetype = 'notice'; } } else { if (in_array($user->email, CitruscartHelperProduct::getUserEmailForReview($post['product_id'])) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_YOU_ALREADY_SUBMITTED_A_REVIEW_CAN_ONLY_SUBMIT_REVIEW_ONCE'); $this->messagetype = 'notice'; } } if (empty($post['productcomment_rating']) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_RATING_IS_REQUIRED'); $this->messagetype = 'notice'; } if (empty($productcomment) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_COMMENT_FIELD_IS_REQUIRED'); $this->messagetype = 'notice'; } $captcha = true; if (Citruscart::getInstance()->get('use_captcha', '0') && $valid) { $privatekey = "6LcAcbwSAAAAANZOTZWYzYWRULBU_S--368ld2Fb"; $captcha = false; if ($_POST["recaptcha_response_field"]) { Citruscart::load('CitruscartRecaptcha', 'library.recaptcha'); $recaptcha = new CitruscartRecaptcha(); $resp = $recaptcha->recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $post['recaptcha_challenge_field'], $post['recaptcha_response_field']); if ($resp->is_valid) { $captcha = true; } } } if (!$captcha && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_INCORRECT_CAPTCHA'); $this->messagetype = 'notice'; } if ($valid) { $date = JFactory::getDate(); $productreviews->bind($post); $productreviews->created_date = $date->toSql(); $productreviews->productcomment_enabled = Citruscart::getInstance()->get('product_reviews_autoapprove', '0'); if (!$productreviews->save()) { $this->message = JText::_('COM_CITRUSCART_UNABLE_TO_SAVE_REVIEW') . " :: " . $productreviews->getError(); $this->messagetype = 'notice'; } else { $dispatcher = JDispatcher::getInstance(); JFactory::getApplication()->triggerEvent('onAfterSaveProductComments', array($productreviews)); $this->message = JText::_('COM_CITRUSCART_SUCCESSFULLY_SUBMITTED_REVIEW'); //successful $linkAdd = ''; } } $redirect = "index.php?option=com_citruscart&view=products&task=view&id=" . $product_id . $linkAdd . "&Itemid=" . $Itemid; $redirect = JRoute::_($redirect); $this->setRedirect($redirect, $this->message, $this->messagetype); }
/** * Do the migration * * @return array */ function _migrate($datas) { $queries = array(); $results = array(); $n = 0; // Loop though the rows foreach ($datas as $data) { // Check for product_name. Explode() could have generated an empty row if (!empty($data['product_name'])) { $isNew = false; if (!$data['product_id']) { $data['product_id'] = 0; $isNew = true; } JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_citruscart' . DS . 'tables'); $product = JTable::getInstance('Products', 'CitruscartTable'); if (!$isNew) { if (!$product->load($data['product_id'])) { $isNew = true; $data['product_id'] = 0; } } // If is a new product, use product->create() if ($isNew) { $product->product_price = 0; $product->product_quantity = 0; $product->bind($data); if ($product->product_full_image) { Citruscart::load('CitruscartFile', 'library.file'); // Do the same cleaning to the image title that the image helper does $name = explode('.', $product->product_full_image); $name = CitruscartFile::cleanTitle($name[0]) . '.' . $name[count($name) - 1]; $product->product_full_image = $name; } $product->create(); $this->_migrateAttributes($product->product_id, $data['product_attributes']); } else { $product->bind($data); //check if normal price exists Citruscart::load("CitruscartHelperProduct", 'helpers.product'); $prices = CitruscartHelperProduct::getPrices($product->product_id); $quantities = CitruscartHelperProduct::getProductQuantities($product->product_id); if ($product->save()) { $product->product_id = $product->id; // New price? if (empty($prices)) { // set price if new or no prices set $price = JTable::getInstance('Productprices', 'CitruscartTable'); $price->product_id = $product->id; $price->product_price = $data['product_price']; $price->group_id = Citruscart::getInstance()->get('default_user_group', '1'); $price->save(); } else { // set price if new or no prices set $price = JTable::getInstance('Productprices', 'CitruscartTable'); $price->load($prices[0]->product_price_id); $price->product_price = $data['product_price']; $price->group_id = Citruscart::getInstance()->get('default_user_group', '1'); $price->save(); } // New quantity? if (empty($quantities)) { // save default quantity $quantity = JTable::getInstance('Productquantities', 'CitruscartTable'); $quantity->product_id = $product->id; $quantity->quantity = $data['product_quantity']; $quantity->save(); } else { // save default quantity $quantity = JTable::getInstance('Productquantities', 'CitruscartTable'); $quantity->load($quantities[0]->productquantity_id); $quantity->product_id = $product->id; $quantity->quantity = $data['product_quantity']; $quantity->save(); } } } // at this point, the product is saved, so now do additional relationships // such as categories if (!empty($product->product_id) && !empty($data['product_categories'])) { foreach ($data['product_categories'] as $category_id) { // This is probably not the best way to do it // Numeric = id, string = category name if (!is_numeric($category_id)) { // check for existance JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_citruscart' . DS . 'models'); $model = JModelLegacy::getInstance('Categories', 'CitruscartModel'); $model->setState('filter_name', $category_id); $matches = $model->getList(); $matched = false; if ($matches) { foreach ($matches as $match) { // is a perfect match? if (strtolower($category_id) == strtolower($match->category_name)) { $category_id = $match->category_id; $matched = true; } } } // Not matched, create category if (!$matched) { $category = JTable::getInstance('Categories', 'CitruscartTable'); $category->category_name = $category_id; $category->parent_id = 1; $category->category_enabled = 1; $category->save(); $category_id = $category->category_id; } } // save xref in every case $xref = JTable::getInstance('ProductCategories', 'CitruscartTable'); $xref->product_id = $product->product_id; $xref->category_id = $category_id; $xref->save(); } } $results[$n]->title = $product->product_name; $results[$n]->query = ""; $results[$n]->error = implode('\\n', $product->getErrors()); $results[$n]->affectedRows = 1; $n++; $this->_migrateImages($product->product_id, $data['product_images'], $results); } } return $results; }
/** * update the productprices default user group * As of v0.5.6 * * return boolean */ function updatePriceUserGroups() { // if this has already been done, don't repeat if (Citruscart::getInstance()->get('updatePriceUserGroups', '0')) { return true; } Citruscart::load('CitruscartHelperProduct', 'helpers.product'); $helper = new CitruscartHelperProduct(); if ($helper->updatePriceUserGroups()) { // Update config to say this has been done already JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); $config = JTable::getInstance('Config', 'CitruscartTable'); $config->load(array('config_name' => 'updatePriceUserGroups')); $config->config_name = 'updatePriceUserGroups'; $config->value = '1'; $config->save(); return true; } return false; }
<div class="dsc-wrap product_buy" style="" id="product_buy_<?php echo $item->product_id; ?> "> <?php echo CitruscartHelperProduct::getCartButton($item->product_id); ?> </div> <?php } ?> <!-------------------------------- Triggering the share Button -------------------------> <?php echo CitruscartHelperProduct::getProductShareButtons($this, $item->product_id); ?> <?php echo $this->onBeforeDisplayProductDescription; ?> <div class="citruscart_product_desc"> <?php echo $this->product_description_short; ?> </div> <!-------------------------------- Triggering the share Button -------------------------> <div class="citruscart_product_shareButtons"> <?php echo $this->onAfterDisplayProductDescription;
/** * Sample use of the products model for getting products with certain properties * See admin/models/products.php for all the filters currently built into the model * * @param $parameters * @return unknown_type */ function getProducts() { // Check the registry to see if our Citruscart class has been overridden if (!class_exists('Citruscart')) { JLoader::register("Citruscart", JPATH_ADMINISTRATOR . "/components/com_citruscart/defines.php"); } // load the config class Citruscart::load('Citruscart', 'defines'); Citruscart::load('CitruscartHelperProduct', 'helpers.product'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_citruscart/models'); // get the model $model = JModelLegacy::getInstance('Products', 'CitruscartModel'); // setting the model's state tells it what items to return $model->setState('filter_published', '1'); $date = JFactory::getDate(); $model->setState('filter_published_date', $date->toSql()); $model->setState('filter_enabled', '1'); // Set category state if ($this->params->get('category', '1') != '1') { $model->setState('filter_category', $this->params->get('category', '1')); } // Set manufacturer state if ($this->params->get('manufacturer', '') != '') { $model->setState('filter_manufacturer', $this->params->get('manufacturer', '')); } // Set id set state if ($this->params->get('id_set', '') != '') { $params_id_set = $this->params->get('id_set'); $id_array = explode(',', $params_id_set); $id_set = "'" . implode("', '", $id_array) . "'"; $model->setState('filter_id_set', $id_set); } // set the states based on the parameters $model->setState('limit', $this->params->get('max_number', '10')); if ($this->params->get('price_from', '-1') != '-1') { $model->setState('filter_price_from', $this->params->get('price_from', '-1')); } if ($this->params->get('price_to', '-1') != '-1') { $model->setState('filter_price_to', $this->params->get('price_to', '-1')); } $order = $this->params->get('order'); $direction = $this->params->get('direction', 'ASC'); switch ($order) { case "2": case "name": $model->setState('order', 'tbl.product_name'); break; case "1": case "created": $model->setState('order', 'tbl.created_date'); break; case "0": case "ordering": default: $model->setState('order', 'tbl.ordering'); break; } if ($this->params->get('random', '0') == '1') { $model->setState('order', 'RAND()'); } $model->setState('direction', $direction); $config = Citruscart::getInstance(); $show_tax = $config->get('display_prices_with_tax'); $default_user_group = Citruscart::getInstance()->get('default_user_group'); $user_groups_array = $this->getUserGroups(); $overide_price = false; if (count($user_groups_array) > 1 && $user_groups_array[0] != $default_user_group) { $overide_price = true; } // using the set filters, get a list of products if ($products = $model->getList(true, false)) { if ($show_tax) { Citruscart::load('CitruscartHelperUser', 'helpers.user'); $geozones = CitruscartHelperUser::getGeoZones(JFactory::getUser()->id); if (empty($geozones)) { // use the default $table = JTable::getInstance('Geozones', 'CitruscartTable'); $table->load(array('geozone_id' => Citruscart::getInstance()->get('default_tax_geozone'))); $geozones = array($table); } } foreach ($products as $product) { if ($overide_price) { $filter_group = CitruscartHelperUser::getUserGroup(JFactory::getUser()->id, $product->product_id); $price = CitruscartHelperProduct::getPrice($product->product_id, '1', $filter_group); $product->price = $price->product_price; } $product->taxtotal = 0; $product->tax = 0; if ($show_tax) { $taxtotal = CitruscartHelperProduct::getTaxTotal($product->product_id, $geozones); $product->taxtotal = $taxtotal; $product->tax = $taxtotal->tax_total; } $product->filter_category = ''; $categories = CitruscartHelperProduct::getCategories($product->product_id); if (!empty($categories)) { $product->link .= "&filter_category=" . $categories[0]; $product->filter_category = $categories[0]; } $itemid = Citruscart::getClass("CitruscartHelperRoute", 'helpers.route')->category($product->filter_category, true); if (empty($itemid)) { $product->itemid = $this->params->get('itemid'); } else { $product->itemid = $itemid; } } } return $products; }
echo JText::_('COM_CITRUSCART_NO_MATCHING_ITEMS_FOUND'); ?> <?php } else { ?> <ul id="citruscart_search_product_main"> <?php foreach ($items as $item) { ?> <li class="citruscart_search_product_list" > <a href="<?php echo JRoute::_($item->link); ?> "> <?php echo CitruscartHelperProduct::getImage($item->product_id); ?> </a> <br/> <strong><?php echo CitruscartHelperBase::currency($item->price); ?> </strong> </li> <?php } ?> </ul> <?php } echo $this->form['validate'];
# author Citruscart Team - Citruscart http://www.citruscart.com # copyright Copyright (C) 2014 Citruscart.com All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://citruscart.com # Technical Support: Forum - http://citruscart.com/forum/index.html -------------------------------------------------------------------------*/ /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); $app = JFactory::getApplication(); $gallery_data = $this->gallery_data; $product_id = $app->input->getInt('id'); $doc = JFactory::getDocument(); $doc->addScript(JUri::root() . 'media/citruscart/js/jquery.zoom.js'); $doc->addStyleSheet(JUri::root(true) . '/media/citruscart/css/imagezoom.css'); $product_image = CitruscartHelperProduct::getImage($product_id, '', '', 'full', true, false, array(), true); $product_image_thumb = CitruscartHelperProduct::getImage($product_id, '', '', 'thumb', true, false, array(), true); ?> <?php if ($gallery_data->show_gallery) { ?> <!--<div class="dsc-wrap product_gallery" id="product_gallery"> --> <!-- <div id="product_gallery_header" class="citruscart_header dsc-wrap"> <span><?php // echo JText::_('COM_CITRUSCART_IMAGES'); ?> </span> </div> --> <?php $i = 1;
$changed_attr = isset($values['changed_attr']) ? $values['changed_attr'] : -1; $changed_pao = -1; if ($changed_attr > -1) { $changed_pao = $values['attribute_' . $changed_attr]; } Citruscart::load('CitruscartHelperBase', 'helpers._base'); $js_strings = array('COM_CITRUSCART_UPDATING_ATTRIBUTES'); CitruscartHelperBase::addJsTranslationStrings($js_strings); $helper_product = CitruscartHelperBase::getInstance('Product'); // Selected attribute options (for child attributes) $selected_opts = !empty($this->selected_opts) ? json_decode($this->selected_opts) : 0; if (!count($selected_opts)) { $selected_opts = 0; } $attributes = CitruscartHelperProduct::getAttributes($row->product_id, $selected_opts); $default = CitruscartHelperProduct::getDefaultAttributeOptions($attributes); // First view of the page: select the first value in the list if (!$selected_opts) { $selected_opts = $default; $selected_opts[] = 0; } foreach ($attributes as $attribute) { ?> <div class="pao" id='productattributeoption_<?php echo $attribute->productattribute_id; ?> '> <?php echo "<span>" . $attribute->productattribute_name . " : </span>"; $key = 'attribute_' . $attribute->productattribute_id; $selected = !empty($values[$key]) ? $values[$key] : $default[$attribute->productattribute_id];
?> </div> </td> <td style="text-align: left;"> <a href="<?php echo $item->link; ?> "> <?php echo JText::_($item->user_name); ?> </a> </td> <td style="text-align: center;"> <?php echo CitruscartHelperProduct::getRatingImage($item->productcomment_rating, $this); ?> </td> <td style="text-align: center;"> <a href="<?php echo $item->link; ?> "> <?php echo JText::_($item->helpful_votes); ?> </a> ( <a href="<?php echo $item->link; ?>
echo JRoute::_($item->link . "&filter_category=" . $this->cat->category_id . "&Itemid=" . $item->itemid); ?> "> <?php echo $item->product_name; ?> </a> </span> <br/> <h6> <span id="product_price_<?php echo $item->product_id; ?> " class="product_price"> <?php echo CitruscartHelperProduct::dispayPriceWithTax($item->price, @$item->tax, @$this->show_tax); ?> <!-- For UE States, we should let the admin choose to show (+19% vat) and (link to the shipping rates) --> <br /> <?php if (Citruscart::getInstance()->get('display_prices_with_shipping') && !empty($item->product_ships)) { ?> <?php echo CitruscartUrl::popup(JRoute::_($this->shipping_cost_link . '&tmpl=component'), JText::_('COM_CITRUSCART_LINK_TO_SHIPPING_COST')); ?> <?php } ?> </span></h6> </li> <!-- manufacturers unorder list ends -->
public function getList($refresh = false, $getEav = true, $options = array()) { static $pa, $pao; if (empty($pa)) { $pa = array(); } if (empty($pao)) { $pao = array(); } Citruscart::load("CitruscartHelperUser", 'helpers.user'); Citruscart::load('CitruscartHelperSubscription', 'helpers.subscription'); $user_helper = CitruscartHelperBase::getInstance('User'); $product_helper = CitruscartHelperBase::getInstance('Product'); if (empty($this->_list)) { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); $items = parent::getList($refresh); // If no item in the list, return an array() if (empty($items)) { return array(); } foreach ($items as $item) { $filter_group = $user_helper->getUserGroup(JFactory::getUser()->id, $item->product_id); // at this point, ->product_price holds the default price for the product, // but the user may qualify for a discount based on volume or date, so let's get that price override $item->product_price_override = $product_helper->getPrice($item->product_id, $item->product_qty, $filter_group, JFactory::getDate()->toSql()); //checking if we do price override isset($item->product_price_override->override) ? $item->product_price_override = true : ""; if (!empty($item->product_price_override)) { $item->product_price = isset($item->product_price_override->product_price) ? $item->product_price_override->product_price : ""; } if ($item->product_recurs) { $item->recurring_price = $item->product_price; if ($item->subscription_prorated) { $result = CitruscartHelperSubscription::calculateProRatedTrial($item->subscription_prorated_date, $item->subscription_prorated_term, $item->recurring_period_unit, $item->recurring_trial_price, $item->subscription_prorated_charge); $item->product_price = $result['price']; $item->recurring_trial_price = $result['price']; $item->recurring_trial_period_interval = $result['interval']; $item->recurring_trial_period_unit = $result['unit']; $item->recurring_trial = $result['trial']; } else { if ($item->recurring_trial) { $item->product_price = $item->recurring_trial_price; } } } $item->product_parameters = new DSCParameter($item->product_params); $item->orderitem_attributes_price = '0.00000'; $item->orderitem_attributes_weight = '0.00000'; $attributes_names = array(); if (!empty($item->product_attributes)) { $item->attributes = array(); // array of each selected attribute's object $attibutes_array = explode(',', $item->product_attributes); foreach ($attibutes_array as $attrib_id) { if (empty($pao[$attrib_id])) { // load the attrib's object $pao[$attrib_id] = JTable::getInstance('ProductAttributeOptions', 'CitruscartTable'); $pao[$attrib_id]->load($attrib_id); } $table = $pao[$attrib_id]; // update the price // + or - if ($table->productattributeoption_prefix != '=') { $item->product_price = $item->product_price + floatval("{$table->productattributeoption_prefix}" . "{$table->productattributeoption_price}"); // store the attribute's price impact $item->orderitem_attributes_price = $item->orderitem_attributes_price + floatval("{$table->productattributeoption_prefix}" . "{$table->productattributeoption_price}"); //$item->product_price_override->override = true; $item->product_price_override = true; } else { // assign the product attribute price as the product price //then set the orderitem_attributes_price to 0.0000 $item->product_price = $table->productattributeoption_price; // // store the attribute's price impact $item->orderitem_attributes_price = "0.00000"; $item->product_price_override->override = false; } // update the weight // + or - if ($table->productattributeoption_prefix_weight != '=') { $item->product_weight = $item->product_weight + floatval("{$table->productattributeoption_prefix_weight}" . "{$table->productattributeoption_weight}"); // store the attribute's price impact $item->orderitem_attributes_weight = $item->orderitem_attributes_weight + floatval("{$table->productattributeoption_prefix_weight}" . "{$table->productattributeoption_weight}"); } else { // assign the product attribute price as the product price //then set the orderitem_attributes_price to 0.0000 $item->product_weight = $table->productattributeoption_weight; // // store the attribute's price impact $item->orderitem_attributes_weight = "0.00000"; } // update product values based on the selected option $m_values = DSCModel::getInstance('ProductAttributeOptionValues', 'CitruscartModel'); $m_values->setState('filter_option', $attrib_id); $list_values = $m_values->getList(); if (count($list_values)) { foreach ($list_values as $val) { switch ($val->productattributeoptionvalue_field) { case 'product_model': case 'product_sku': $field = $val->productattributeoptionvalue_field; switch ($val->productattributeoptionvalue_operator) { case 'prepend': $item->{$field} = $val->productattributeoptionvalue_value . $item->{$field}; break; case 'append': $item->{$field} = $item->{$field} . $val->productattributeoptionvalue_value; break; case 'replace': $item->{$field} = $val->productattributeoptionvalue_value; break; } break; } } } $item->orderitem_attributes_price = number_format($item->orderitem_attributes_price, '5', '.', ''); $item->orderitem_attributes_weight = number_format($item->orderitem_attributes_weight, '5', '.', ''); // store a csv of the attrib names, built by Attribute name + Attribute option name if (empty($pa[$table->productattribute_id])) { $pa[$table->productattribute_id] = JTable::getInstance('ProductAttributes', 'CitruscartTable'); $pa[$table->productattribute_id]->load($table->productattribute_id); } $atable = $pa[$table->productattribute_id]; if (!empty($atable->productattribute_id)) { $name = JText::_($atable->productattribute_name) . ': ' . JText::_($table->productattributeoption_name); $attributes_names[] = $name; } else { $attributes_names[] = JText::_($table->productattributeoption_name); } } // Generate Product Sku based upon attributes $item->product_sku = CitruscartHelperProduct::getProductSKU($item, $attibutes_array); // Could someone explain to me why this is necessary? if ($item->orderitem_attributes_price >= 0) { // formatted for storage in the DB $item->orderitem_attributes_price = "+{$item->orderitem_attributes_price}"; } } $item->attributes_names = implode(', ', $attributes_names); $this->prepareItem($item, 0, $refresh); } $this->_list = $items; } return $this->_list; }
"> <td style="width: 20px; text-align: center;"> <input type="checkbox" id="cb<?php echo $i; ?> " name="cid[<?php echo $item->cart_id; ?> ]" value="<?php echo $item->product_id; ?> " onclick="isChecked(this.checked);" /> </td> <td style="text-align: center; width: 50px;"> <?php echo CitruscartHelperProduct::getImage($item->product_id, 'id', $item->product_name, 'full', false, false, array('width' => 48)); ?> </td> <td> <a href="<?php echo $link; ?> "> <?php echo $item->product_name; ?> </a> <br/> <?php if (!empty($item->attributes_names)) {
function getFilters() { $filters = array(); if (!empty($this->_filter_category) && !empty($this->category_current)) { $catObj = new stdClass(); $catObj->label = JText::_('COM_CITRUSCART_CATEGORY'); $catObj->value = $this->category_current->category_name; $catObj->link = $this->_link . '&filter_category='; $filters[] = $catObj; } if (!empty($this->_filter_price_from) || !empty($this->_filter_price_to)) { $priceObj = new stdClass(); $priceObj->label = JText::_('COM_CITRUSCART_PRICE'); $priceObj->value = CitruscartHelperBase::currency($this->_filter_price_from) . ' - ' . CitruscartHelperBase::currency($this->_filter_price_to); $priceObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_price_from=0&filter_price_to='; $filters[] = $priceObj; } if (!empty($this->_filter_attribute_set)) { $options = explode(',', $this->_filter_option_set); $session = JFactory::getSession(); $saveOptions = $session->get('options', array(), 'Citruscart_layered_nav'); $trackOpts = array(); $link = ''; $newOPT = array(); $listPAO = array(); $listPA = array(); if (isset($saveOptions[$this->_filter_category])) { foreach ($saveOptions[$this->_filter_category] as $saveOption) { if (in_array($saveOption->productattributeoption_id, $options)) { $listPAO[] = $saveOption->productattributeoption_id; $listPA[] = $saveOption->productattribute_id; $newOPT[$saveOption->productattributeoption_name]->istopa[] = $saveOption->productattribute_id; $newOPT[$saveOption->productattributeoption_name]->istopao[] = $saveOption->productattributeoption_id; } } } foreach ($options as $option) { if (empty($this->_options[$option])) { continue; } $combination = $this->_options[$option]->attributename . '::' . $this->_options[$option]->productattributeoption_name; if (!in_array($combination, $trackOpts)) { $trackOpts[] = $combination; $attriObj = new stdClass(); $attriObj->label = $this->_options[$option]->attributename; $attriObj->value = $this->_options[$option]->productattributeoption_name; //create option set $option_set = array_diff($listPAO, $newOPT[$attriObj->value]->istopao); //create attribute set $attribute_set = array_diff($listPA, $newOPT[$attriObj->value]->istopa); $attriObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_attribute_set=' . implode(',', $attribute_set) . '&filter_option_set=' . implode(',', $option_set); $filters[] = $attriObj; } } } if ($this->_filter_rating && $this->_params->get('filter_rating')) { $ratingObj = new stdClass(); $ratingObj->label = JText::_('COM_CITRUSCART_RATING'); $ratingObj->value = CitruscartHelperProduct::getRatingImage((double) $this->_filter_rating) . ' ' . JText::_('COM_CITRUSCART_AND_UP'); $ratingObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_rating=0'; $filters[] = $ratingObj; } if ($this->_multi_mode) { if (!empty($this->_filter_manufacturer_set)) { $brandSet = explode(',', $this->_filter_manufacturer_set); foreach ($brandSet as $brand) { $brandObj = new stdClass(); $brandObj->label = JText::_('COM_CITRUSCART_MANUFACTURER'); $brandObj->value = $this->brands[$brand]; $brandObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_manufacturer_set=' . implode(',', array_diff($brandSet, array($brand))); $filters[] = $brandObj; } } } else { if (!empty($this->_filter_manufacturer)) { $brandObj = new stdClass(); $brandObj->label = JText::_('COM_CITRUSCART_MANUFACTURER'); $brandObj->value = $this->brands[$this->_filter_manufacturer]; $brandObj->link = $this->_link . '&filter_category=' . $this->_filter_category . '&filter_manufacturer='; $filters[] = $brandObj; } } return $filters; }
</td> <td> <h3><?php echo $row->product_name; ?> </h3> <p><?php echo $row->product_description_short; ?> </p> </td> <td> <div id="product_buy"> <?php $values = array('user_id' => JFactory::getSession()->get('user_id', '', 'citruscart_pos')); echo CitruscartHelperProduct::getCartButton($row->product_id, 'viewproduct_addtocart', $values); ?> </div> </td> </tr> <tr > <td colspan="3"> <div style="text-align: left;"> <a href="index.php?option=com_citruscart&view=pos&task=addproducts&tmpl=component"> <?php echo JText::_('COM_CITRUSCART_RETURN_TO_SEARCH_RESULTS'); ?> </a> </div> </td> </tr>
<?php /*------------------------------------------------------------------------ # com_citruscart # ------------------------------------------------------------------------ # author Citruscart Team - Citruscart http://www.citruscart.com # copyright Copyright (C) 2014 Citruscart.com All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://citruscart.com # Technical Support: Forum - http://citruscart.com/forum/index.html -------------------------------------------------------------------------*/ /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); $form = $this->form; $row = $this->row; $helper_product = new CitruscartHelperProduct(); ?> <div style="float: left; width: 50%;"> <div class="well options" id="product-pricing"> <legend> <?php echo JText::_('COM_CITRUSCART_PRICES_AND_INVENTORY'); ?> </legend> <table class="table table-striped table-bordered"> <tr> <td class="dsc-key"> <?php echo JText::_('COM_CITRUSCART_ITEM_NOT_FOR_SALE');