Пример #1
0
 private function get_product_rows($ids, $use_search_and_filters = false, $pagination = null, $use_menu_params = false)
 {
     if ($ids != null && is_array($ids) == false) {
         $ids = array($ids);
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $model_options = WDFHelper::get_model('options');
     $options = $model_options->get_options();
     $module_filters = WDFInput::get('module_filters');
     $decimals = $options->option_show_decimals == 1 ? 2 : 0;
     $row_default_currency = WDFDb::get_row('currencies', $db->quoteName('default') . ' = 1');
     //get products data
     $query->clear();
     $query = $this->add_product_rows_query_select($query);
     $query = $this->add_product_rows_query_from($query);
     if ($ids != null) {
         $query = $this->add_product_rows_query_where_ids($query, $ids);
     }
     if ($use_search_and_filters == true) {
         $query = $this->add_product_rows_query_where_filter_name($query);
         $query = $this->add_product_rows_query_where_filter_category($query);
         if ($query === false) {
             WDFHelper::redirect('systempages', 'displayerror', '', 'code=2');
         }
         $query = $this->add_product_rows_query_where_filter_manufacturer($query);
         $query = $this->add_product_rows_query_where_filter_price($query);
         $query = $this->add_product_rows_query_where_filter_date_added($query);
         $query = $this->add_product_rows_query_where_filter_minimum_rating($query);
         $query = $this->add_product_rows_query_where_filter_tags($query);
         $query = $this->add_product_rows_query_order($query);
     } else {
         if ($use_menu_params == true) {
             $query = $this->add_product_rows_query_where_filter_menu_params($query);
         }
     }
     $query->where('T_PRODUCTS.published = 1');
     if ($pagination != null) {
         $db->setQuery($query, $pagination->limitstart, $pagination->limit);
     } else {
         $db->setQuery($query);
     }
     $product_rows = $db->loadObjectList();
     if ($db->getErrorNum()) {
         return false;
     }
     // additional data
     foreach ($product_rows as $product_row) {
         // url
         $product_row->url = JRoute::_('index.php?option=com_' . WDFHelper::get_com_name() . '&controller=products&task=displayproduct&product_id=' . $product_row->id);
         $product_row->url_absolute = WDFUrl::get_site_url() . 'index.php?option=com_' . WDFHelper::get_com_name() . '&controller=products&task=displayproduct&product_id=' . $product_row->id;
         // image
         $images = WDFJson::decode($product_row->images);
         $product_row->image = empty($images) == false ? $images[0] : '';
         //videos
         $product_row->videos = WDFJson::decode($product_row->videos);
         // label
         $label_thumbs = WDFJson::decode($product_row->label_thumb);
         $product_row->label_thumb = empty($label_thumbs) == false ? $label_thumbs[0] : '';
         // rating
         $product_row->rating_url = '';
         $product_row->rating_msg = '';
         if ($options->feedback_enable_guest_feedback == 0 && WDFHelper::is_user_logged_in() == false) {
             $product_row->can_rate = 0;
             $product_row->rating_msg = WDFText::get('MSG_LOG_IN_TO_RATE');
         } elseif ($product_row->can_rate == 0) {
             $product_row->rating_msg = WDFText::get('MSG_YOU_HAVE_ALREADY_RATED_THIS_PRODUCT');
         } else {
             $product_row->rating_url = WDFUrl::get_site_url() . 'index.php?option=com_' . WDFHelper::get_com_name() . '&controller=products&task=ajax_rate_product&product_id=' . $product_row->id;
         }
         // category
         $product_row->category_url = $product_row->category_id == 0 ? '' : JRoute::_('index.php?option=com_' . WDFHelper::get_com_name() . '&controller=categories&task=displaycategory&category_id=' . $product_row->category_id);
         // manufacturer
         $product_row->manufacturer_url = $product_row->manufacturer_id == 0 ? '' : JRoute::_('index.php?option=com_' . WDFHelper::get_com_name() . '&controller=manufacturers&task=displaymanufacturer&manufacturer_id=' . $product_row->manufacturer_id);
         $manufacturer_logos = WDFJson::decode($product_row->manufacturer_logo);
         $product_row->manufacturer_logo = empty($manufacturer_logos) == true ? '' : $manufacturer_logos[0];
         // prices
         $product_row->price_text = number_format($product_row->price, $decimals);
         $product_row->market_price_text = $product_row->market_price != '0.00' ? number_format($product_row->market_price, $decimals) : '';
         // currency symbols
         if ($row_default_currency->sign_position == 0) {
             $product_row->price_text = $row_default_currency->sign . $product_row->price_text;
             $product_row->market_price_text = $product_row->market_price != '0.00' ? $row_default_currency->sign . $product_row->market_price_text : '';
         } else {
             $product_row->price_text = $product_row->price_text . $row_default_currency->sign;
             $product_row->market_price_text = $product_row->market_price != '0.00' ? $product_row->market_price_text . $row_default_currency->sign : '';
         }
         $product_row->currency_sign = $row_default_currency->sign;
         // availability
         if ($product_row->unlimited == 1) {
             $product_row->is_available = true;
             $product_row->available_msg = WDFText::get('IN_STOCK');
             $product_row->stock_class = 'class="wd_in_stock"';
         } elseif ($product_row->amount_in_stock > 0) {
             $product_row->is_available = true;
             $product_row->available_msg = WDFText::get('IN_STOCK') . ': ' . $product_row->amount_in_stock;
             $product_row->stock_class = 'class="wd_in_stock"';
         } else {
             $product_row->is_available = false;
             $product_row->available_msg = WDFText::get('OUT_OF_STOCK');
             $product_row->stock_class = 'class="wd_out_of_stock"';
         }
         // checkout privileges
         $products_in_stock = $product_row->amount_in_stock > 0 || $product_row->unlimited == 1 ? true : false;
         $product_row->can_checkout = $products_in_stock == true ? true : false;
         // compare url
         $product_row->compare_url = JRoute::_('index.php?option=com_' . WDFHelper::get_com_name() . '&controller=products&task=displaycompareproducts&product_id=' . $product_row->id);
         // review urls
         $product_row->reviews_url = JRoute::_('index.php?option=com_' . WDFHelper::get_com_name() . '&controller=products&task=displayproductreviews&product_id=' . $product_row->id);
         $product_row->write_review_url = JRoute::_('index.php?option=com_' . WDFHelper::get_com_name() . '&controller=products&task=displayproductreviews&product_id=' . $product_row->id . '&write_review=1');
     }
     return $product_rows;
 }
Пример #2
0
";

    var wdShop_redirectToCart = <?php 
echo $options->checkout_redirect_to_cart_after_adding_an_item == 1 ? 'true' : 'false';
?>
;
	var wdShop_minicart = "<?php 
echo Juri::base() . 'index.php?option=com_' . WDFHelper::get_com_name() . '&controller=shoppingcart&task=displayminicart&tmpl=component';
?>
";
	var wdShop_minicart_js_path = "<?php 
echo WDFUrl::get_site_url() . 'modules/mod_ecommercewd_minicart/js/main.js';
?>
";
    var wdShop_urlAddToShoppingCart = "<?php 
echo WDFUrl::get_site_url() . 'index.php?option=com_' . WDFHelper::get_com_name() . '&controller=shoppingcart&task=add';
?>
";
    var wdShop_urlDisplayShoppingCart = "<?php 
echo JRoute::_('index.php?option=com_' . WDFHelper::get_com_name() . '&controller=shoppingcart&task=displayshoppingcart');
?>
";
	var wdShop_amount_in_stock = <?php 
echo $product_row->amount_in_stock;
?>
;
	var wdShop_product_unlimited = <?php 
echo $product_row->unlimited;
?>
;
	var wdShop_currency_code = "<?php