Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Customizing the Look of Your Shop / Templates, Stylesheets, Page Layout / how do I make "buy it now" link in featured products on the front page?

how do I make "buy it now" link in featured products on the front page?

Locked
This thread is locked. New replies are disabled.
14 Aug 2006, 4:56 PM
#1
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Post #1 by graper

This also applies to specials and new this month items.

How do I make a "buy it now" link for a product that is in a "featured item", "Specials", and "New This Month" center box that is found on the front page?

I can't seem to find it in the admin area. I'd be happy with an "Add to Cart" link if that's all that can be done.

Another link I need to know how to make is a more info button that links to the items itself.

Also does Zen cart have a function to display the first [x many] characters in a description field already built in or do I need to build my own. The last thing I want to have happen is a breaking of a table or a div that was put into the description and have it not be closed just because I did a substring.

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

15 Aug 2006, 1:13 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #2 by kobra

How do I make a "buy it now" link for a product that is in a "featured item", "Specials", and "New This Month" center box that is found on the front page?

These are in the admin but I can not attest to their function:

Admin > confuguration > Featured Listing > Display Product Buy Now Button
Same for other listings.

Another link I need to know how to make is a more info button that links to the items itself.
You should check the current function as even if there is not a more info, clicking the image and other areas of a listing takes you to the Product Info page.
Also does Zen cart have a function to display the first [x many] characters in a description field already built in or do I need to build my own.
This is also in the admin for several of the product screens like the product listing page:
Admin > configuration > product listing > Display Product Description

The last thing I want to have happen is a breaking of a table or a div that was put into the description and have it not be closed just because I did a substring.
Describe this in specific detail???

Zen-Venom Get Bitten

15 Aug 2006, 2:20 PM
#3
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Post #3 by graper

kobra:

These are in the admin but I can not attest to their function:

Admin > confuguration > Featured Listing > Display Product Buy Now Button
Same for other listings.

unfortunatly this refers to the listing when you get into Featured Items from the category list. I've had to customize the featured_products.php file to change how list looks. I've made a customized buy now button and more info button. Also the description was not being displayed and I had to add that too.

You should check the current function as even if there is not a more info, clicking the image and other areas of a listing takes you to the Product Info page.

I wanted to add a button regardless of the links that were already there. I got that done with some customization of the featured_products.php file.

This is also in the admin for several of the product screens like the product listing page:
Admin > configuration > product listing > Display Product Description

the problem is that in Admin > configuration > featured listing secion controls only the listing that looks like the product listing. The center boxe for featured products on the front page are not crontrolled through this UI and does not have a customization setup that I desire. No probelm, I'm a programmer I can go in and find out where it is and make my own customizations. If you look at the page http://markham.kirkhamsystems.dyndns.org you will see that I have a customized "featured products" center box. There is no way to display descriptions, add to cart buttons or more info buttons to the center box. the suggestion you give leads to the next quote.

Describe this in specific detail???

in Admin > configuration > product listing > Display Product Description one is able to control the amount of the description that is displayed on the listing. Since I want this on the front page, I would like to know what function(s) are used to do this as I beleive the system would take into account HTML code and properly strip and replace codes if necessary.

For example if there is 300 characters in a descriptions, and some of that is HTML like <table...><tr><td>some text</td></tr><tr><td> ... text at the end </td></tr></table> if I just go in and do a substring of the first 20 characters all I get is <table ...><tr><td>some text </tr>(end of substring) all of a sudden I got a broken table and that is what I want to avoid. I think I may have found the function(s) I want but it looks like it strips the html away and provides an unstructured string. it's
zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION)

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

15 Aug 2006, 7:46 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #4 by kobra

Granville,
Sorry for the simplistic response that I posted, had you stated that you were a programmer and customizing the displays, I either would not have posted or posted in a different manner.

A very nice implementation of ZenCart that you have assembled!! I believe that their is a showcase where your site can be displayed as one that uses ZenCart. There are very few restrictions for this and you might consider doing this. Many considering ZenCart need great examples to convince employers, clients or others that this cart is a good chioce.

Also, as the base cart script was opensourced for your use, you might consider assembling this as a contribution for others that might be wishing for something like this, and give back to the community if you so choose.

Great work!

Zen-Venom Get Bitten

17 Aug 2006, 8:08 PM
#5
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Post #5 by graper

kobra:

A very nice implementation of ZenCart that you have assembled!! I believe that their is a showcase where your site can be displayed as one that uses ZenCart. There are very few restrictions for this and you might consider doing this. Many considering ZenCart need great examples to convince employers, clients or others that this cart is a good chioce.

Also, as the base cart script was opensourced for your use, you might consider assembling this as a contribution for others that might be wishing for something like this, and give back to the community if you so choose.

Great work!

Sorry to take so long to respond back on this, been busy. Thanks for the compliment and I'll deffinatly look into the showcase, maybe it will drum up some business for my company.

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

28 Aug 2006, 8:34 PM
#6
cjmarley avatar

cjmarley

Zen Follower

Join Date:
May 2004
Posts:
96
Plugin Contributions:
2

Post #6 by cjmarley

Would you be willing to share how you did this with me? It would be so deeply appreciated!!!

CJ

18 Sep 2006, 9:29 PM
#7
reap avatar

reap

New Zenner

Join Date:
Sep 2006
Posts:
13
Plugin Contributions:
0

Post #7 by reap

I have also been killing myself trying to make the features list on the main center page show descriptions and buy now/info button.

graper I checked out your http://markham.kirkhamsystems.dyndns.org/

can you please share your featured_products.php or whatever you did to make it work.

Pretty please!! I am going insane.

Thanks!

21 Dec 2006, 9:00 PM
#8
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Post #8 by graper

I got another PM today about how to make a buy now link. here is the code to make a buy now/add to cart link.

<a href="' . zen_href_link( $_GET['main_page'], 'products_id=' . $product_id .'&action=buy_now') . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a>

if you're looking for a quick guide on how to change the layouts of the featured products, new products, or specials, then check out this page.

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

22 Mar 2009, 5:13 PM
#9
milkyway avatar

milkyway

Inactive

Join Date:
Aug 2006
Location:
Singapore
Posts:
167
Plugin Contributions:
1

Post #9 by milkyway

I also use the same code for one of my project,

'<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ';

However I found an issue, when the product is out of stock the 'Buy now' button still show up, of course because I don't put any IF statement for it.

Can somebody help me to share what the IF statement we shall put to check whether the stock is 'sold out' or not? So zencart can replace the Buy now button with Sold Out button if the item is out of stock.

I tried to figure out but couldn't find it... really appreciate all helps

Thanks!

Responsive ZenCart Templates that automatically adapt itself with iPad, iPhone, BlackBerry, Androids and any monitor screen size
Buy a coffee for Zen-Cart devs. http://www.zen-cart.com/donate

24 Mar 2009, 7:25 AM
#10
milkyway avatar

milkyway

Inactive

Join Date:
Aug 2006
Location:
Singapore
Posts:
167
Plugin Contributions:
1

Post #10 by milkyway

Any helps?

Responsive ZenCart Templates that automatically adapt itself with iPad, iPhone, BlackBerry, Androids and any monitor screen size
Buy a coffee for Zen-Cart devs. http://www.zen-cart.com/donate

24 Mar 2009, 12:54 PM
#11
dharam1987 avatar

dharam1987

New Zenner

Join Date:
Mar 2009
Location:
India, Hyderabad
Posts:
36
Plugin Contributions:
1

Post #11 by dharam1987

milkyway:

Any helps?
Though the above post is on Aug 2006. I would like to add the answer to it. So, that it will be helpful to anybody else coming to next after me.

You need to use the function zen_get_buy_now_button. This function is being used in tpl_modules_products_all_listing.php page (may be in some other pages also)

BTW, I wil be giving a link to download the total code which you can use with zencart3.8 which will display

vendor name
description
buynow button

for featured products in the main page.

Regards
Dharam

24 Mar 2009, 1:07 PM
#12
dharam1987 avatar

dharam1987

New Zenner

Join Date:
Mar 2009
Location:
India, Hyderabad
Posts:
36
Plugin Contributions:
1

Post #12 by dharam1987

dharam1987:

Though the above post is on Aug 2006. I would like to add the answer to it. So, that it will be helpful to anybody else coming to next after me.

You need to use the function zen_get_buy_now_button. This function is being used in tpl_modules_products_all_listing.php page (may be in some other pages also)

BTW, I wil be giving a link to download the total code which you can use with zencart3.8 which will display

vendor name
description
buynow button

for featured products in the main page.
zen_get_buy_now_button($featured_products->fields['products_id'],'<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ');

USE THE ABOVE CODE

Regards
Dharam

24 Mar 2009, 1:21 PM
#13
dharam1987 avatar

dharam1987

New Zenner

Join Date:
Mar 2009
Location:
India, Hyderabad
Posts:
36
Plugin Contributions:
1

Post #13 by dharam1987

dharam1987:

zen_get_buy_now_button($featured_products->fields['products_id'],'<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ');

USE THE ABOVE CODE
http://www.zen-cart.com/forum/showthread.php?p=704607#post704607

You can also visit the thread above and can find out much more information.

Regards
Dharam

24 Mar 2009, 1:23 PM
#14
milkyway avatar

milkyway

Inactive

Join Date:
Aug 2006
Location:
Singapore
Posts:
167
Plugin Contributions:
1

Post #14 by milkyway

Thank you very much!, thats solved the problem :D

Responsive ZenCart Templates that automatically adapt itself with iPad, iPhone, BlackBerry, Androids and any monitor screen size
Buy a coffee for Zen-Cart devs. http://www.zen-cart.com/donate

26 Mar 2009, 7:50 AM
#15
dharam1987 avatar

dharam1987

New Zenner

Join Date:
Mar 2009
Location:
India, Hyderabad
Posts:
36
Plugin Contributions:
1

Post #15 by dharam1987

You are most welcome. I am glad that I have helped you

Regards
Dharam

23 Jun 2009, 9:02 PM
#16
andrew55 avatar

andrew55

New Zenner

Join Date:
Jun 2009
Posts:
43
Plugin Contributions:
0

Post #16 by andrew55

Glad to find this. I think I understand the basics of what is instructed. I went to graper's site and found it helpful.

When I view my "Featured Product" section on home page, the buy now and more info buttons are showing.

Only problems are

  1. the 2 columns are gone (only a list now)

  2. when the buy now button is clicked, it redirects to the product page instead of just adding product to cart (even product with no attributes).

I'm not skilled at php, but here is the code I came up with if anyone is willing to take a look. Anyone have a working featured_products.php to post? Thanks for any suggestions.

<?php

/**

 * featured_products module - prepares content for display

 *

 * @package modules

 * @copyright Copyright 2003-2007 Zen Cart Development Team

 * @copyright Portions Copyright 2003 osCommerce

 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

 * @version $Id: featured_products.php 6424 2007-05-31 05:59:21Z ajeh $

 */

if (!defined('IS_ADMIN_FLAG')) {

  die('Illegal Access');

}



// initialize vars

$categories_products_id_list = '';

$list_of_products = '';

$featured_products_query = '';

$display_limit = '';



if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {

  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id, pd.products_description

                           from (" . TABLE_PRODUCTS . " p

                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id

                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )

                           where p.products_id = f.products_id

                           and p.products_id = pd.products_id

                           and p.products_status = 1 and f.status = 1

                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

} else {

  // get all products and cPaths in this subcat tree

  $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);



  if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {

    // build products-list string to insert into SQL query

    foreach($productsInCategory as $key => $value) {

      $list_of_products .= $key . ', ';

    }

    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma

    $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id, pd.products_description

                                from (" . TABLE_PRODUCTS . " p

                                left join " . TABLE_FEATURED . " f on p.products_id = f.products_id

                                left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id)

                                where p.products_id = f.products_id

                                and p.products_id = pd.products_id

                                and p.products_status = 1 and f.status = 1

                                and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'

                                and p.products_id in (" . $list_of_products . ")";

  }

}

if ($featured_products_query != '') $featured_products = $db->ExecuteRandomMulti($featured_products_query, MAX_DISPLAY_SEARCH_RESULTS_FEATURED);



$row = 0;

$col = 0;

$list_box_contents = array();

$title = '';



$num_products_count = ($featured_products_query == '') ? 0 : $featured_products->RecordCount();



// show only when 1 or more

if ($num_products_count > 0) {

  if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS == 0) {

    $col_width = floor(100/$num_products_count);

  } else {

    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS);

  }

  while (!$featured_products->EOF) {

    $products_price = zen_get_products_display_price($featured_products->fields['products_id']);

    if (!isset($productsInCategory[$featured_products->fields['products_id']])) $productsInCategory[$featured_products->fields['products_id']] = zen_get_generated_category_path_rev($featured_products->fields['master_categories_id']);


    $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',

    'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a><br />' . $products_price);

$product_link=zen_href_link( zen_get_info_page(  $featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']);
      $product_image=zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT);
      $product_name=$featured_products->fields['products_name'];
      $product_desc=zen_trunc_string( zen_clean_html( stripslashes( zen_get_products_description( $featured_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
      $product_id=$featured_products->fields['products_id'];
      $product_addtocart=zen_href_link( $_GET['main_page'], 'products_id=' . $product_id .'&action=buy_now');
	  
	  $list_box_contents[$row][$col] = array('params' =>'class="featured_prod back"'
		. '','text' => '<div class="featured_prod_name"><a href="' . $product_link . '">' . $product_name . '</a></div>'
		.' <div class="featured_prod_description"><a class="featured_prod_image" href="' . $product_link . '">' . $product_image. '</a>'
		. $product_desc . '</div><div class="clearBoth"></div>'
		. ' <div class="custom_prod_price">' . $product_price .'</div>'
		. ' <div class="custom_prod_links"><a href="' . $product_addtocart . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a>   <a href="' . $product_link . '"><img src="/biz/includes/templates/farm/buttons/english//button_more_reviews.gif" /></a></div>' );

    $col ++;

    if ($col > (SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS - 1)) {

      $col = 0;

      $row ++;

    }

    $featured_products->MoveNextRandom();

  }



  if ($featured_products->RecordCount() > 0) {

    if (isset($new_products_category_id) && $new_products_category_id !=0) {

      $category_title = zen_get_categories_name((int)$new_products_category_id);

      $title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . ($category_title != '' ? ' - ' . $category_title : '') . '</h2>';

    } else {

      $title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . '</h2>';

    }

    $zc_show_featured = true;

  }

}

?>
24 Jun 2009, 4:10 PM
#17
spawnie69 avatar

spawnie69

Totally Zenned

Join Date:
Sep 2005
Location:
Ocala, FL
Posts:
527
Plugin Contributions:
0

Post #17 by spawnie69

I my dilemma is similar.

I would like to display my featured products on the front page with some description with prices and buy now buttons (links to the product page).
I would like the featured products to be displayed in rotation in 2 columns on the front page.

I made my own version in html and placed in my admin main page.

I was wondering if zen cart already had a feature like this in the admin somewhere.
It would be nice to see the featured items in rotation at the front top.

advice is appreciated.
Here is the site:
https://www.gelcandlecompany.com

24 Jun 2009, 4:21 PM
#18
milkyway avatar

milkyway

Inactive

Join Date:
Aug 2006
Location:
Singapore
Posts:
167
Plugin Contributions:
1

Post #18 by milkyway

Of course you can,

If you follow the code above it will work.

I made similar way for many of my client's sites, here one of the example:
http://cvtreasures.com

Responsive ZenCart Templates that automatically adapt itself with iPad, iPhone, BlackBerry, Androids and any monitor screen size
Buy a coffee for Zen-Cart devs. http://www.zen-cart.com/donate

24 Jun 2009, 4:25 PM
#19
milkyway avatar

milkyway

Inactive

Join Date:
Aug 2006
Location:
Singapore
Posts:
167
Plugin Contributions:
1

Post #19 by milkyway

This is incorrect:

$product_addtocart=zen_href_link( $_GET['main_page'], 'products_id=' . $product_id .'&action=buy_now');

It should be:

$product_addtocart = zen_get_buy_now_button($featured_products->fields['products_id'],'<a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a> ');

Responsive ZenCart Templates that automatically adapt itself with iPad, iPhone, BlackBerry, Androids and any monitor screen size
Buy a coffee for Zen-Cart devs. http://www.zen-cart.com/donate

24 Jun 2009, 10:29 PM
#20
andrew55 avatar

andrew55

New Zenner

Join Date:
Jun 2009
Posts:
43
Plugin Contributions:
0

Post #20 by andrew55

milkyway - I played around with your code but I can't see how it fits yet. Anyway, this is the best I've come up with so far (without being a coder).

This featured products page has a "buy now" and "more info" button, it displays the short description (integrated with "Short Description" addin) right below the thumbnail and above the buttons.

I have it looking OK in 3 columns, which I couldn't figure out how to do with dharam1987's contribution. So what I have is a mix-match of different ideas from this community.

I think many people here could benefit from this, if the code is correct (if you are skilled in php and see any errors, please let me know).

If anyone knows how to change this code so it doesn't direct to category page when buy now button is clicked, please please let me know. I'd love for users to be able to add "non attributes" items to the cart without redirection.

Also, I am working to get a quantity field box next to the buttons for each product (customer enters in desired amount and it's submitted when buy now button is clicked). I've been looking at product_listing.php for the box field code, but my efforts have been disaserous so far. If anyone has insights into this, please share. Here is my code so far:

<?php

/**

 * featured_products module - prepares content for display

 *

 * @package modules

 * @copyright Copyright 2003-2007 Zen Cart Development Team

 * @copyright Portions Copyright 2003 osCommerce

 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

 * @version $Id: featured_products.php 6424 2007-05-31 05:59:21Z ajeh $

 */

if (!defined('IS_ADMIN_FLAG')) {

  die('Illegal Access');

}



// initialize vars

$categories_products_id_list = '';

$list_of_products = '';

$featured_products_query = '';

$display_limit = '';



if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {

  $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id, pd.products_short_desc

                           from (" . TABLE_PRODUCTS . " p

                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id

                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )

                           where p.products_id = f.products_id

                           and p.products_id = pd.products_id

                           and p.products_status = 1 and f.status = 1

                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";

} else {

  // get all products and cPaths in this subcat tree

  $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);



  if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {

    // build products-list string to insert into SQL query

    foreach($productsInCategory as $key => $value) {

      $list_of_products .= $key . ', ';

    }

    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma

    $featured_products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id, pd.products_short_desc

                                from (" . TABLE_PRODUCTS . " p

                                left join " . TABLE_FEATURED . " f on p.products_id = f.products_id

                                left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id)

                                where p.products_id = f.products_id

                                and p.products_id = pd.products_id

                                and p.products_status = 1 and f.status = 1

                                and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'

                                and p.products_id in (" . $list_of_products . ")";

  }

}

if ($featured_products_query != '') $featured_products = $db->ExecuteRandomMulti($featured_products_query, MAX_DISPLAY_SEARCH_RESULTS_FEATURED);



$row = 0;

$col = 0;

$list_box_contents = array();

$title = '';



$num_products_count = ($featured_products_query == '') ? 0 : $featured_products->RecordCount();



// show only when 1 or more

if ($num_products_count > 0) {

  if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS == 0) {

    $col_width = floor(100/$num_products_count);

  } else {

    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS);

  }

  while (!$featured_products->EOF) {

    $product_price = zen_get_products_display_price($featured_products->fields['products_id']);	
	  $product_link=zen_href_link( zen_get_info_page(  $featured_products->fields['products_id']), 'products_id=' . $featured_products->fields['products_id']);
      $product_id=$featured_products->fields['products_id'];
      $product_addtocart=zen_href_link( $_GET['main_page'], 'products_id=' . $product_id .'&action=buy_now');
	  $product_image=zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT);
      $product_name=$featured_products->fields['products_name'];
	  $featured_products->fields['products_short_desc'] = zen_get_products_short_desc($featured_products->fields['products_id']);

    if (!isset($productsInCategory[$featured_products->fields['products_id']])) $productsInCategory[$featured_products->fields['products_id']] = zen_get_generated_category_path_rev($featured_products->fields['master_categories_id']);
	

    $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',

    'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($featured_products->fields['products_id']), 'cPath=' . $productsInCategory[$featured_products->fields['products_id']] . '&products_id=' . $featured_products->fields['products_id']) . '">' . $featured_products->fields['products_name'] . '</a><div class="products_short_desc">' . $featured_products->fields['products_short_desc'] . '</div><div class="clearBoth"></div>'
		. ' <div class="featured_prod_price">' . $product_price .'</div>'
		. ' <div class="featured_prod_links"><a href="' . $product_addtocart . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a>   <a href="' . $product_link . '"><img src="/biz/includes/templates/mytemplate/buttons/english/mypic.gif" /></a></div>' );


    $col ++;

    if ($col > (SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS - 1)) {

      $col = 0;

      $row ++;

    }

    $featured_products->MoveNextRandom();

  }



  if ($featured_products->RecordCount() > 0) {

    if (isset($new_products_category_id) && $new_products_category_id !=0) {

      $category_title = zen_get_categories_name((int)$new_products_category_id);

      $title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . ($category_title != '' ? ' - ' . $category_title : '') . '</h2>';

    } else {

      $title = '<h2 class="centerBoxHeading">' . TABLE_HEADING_FEATURED_PRODUCTS . '</h2>';

    }

    $zc_show_featured = true;

  }

}

?>