Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Code to display Featured Category with Description, Manufacture URL, BuyNow button

Code to display Featured Category with Description, Manufacture URL, BuyNow button

Views: 11,348

Results 21 to 36 of 36
3 Aug 2009, 3:57 PM
#21
fattyfat avatar

fattyfat

New Zenner

Join Date:
Jul 2009
Posts:
28
Plugin Contributions:
0

Code to display Featured Category with Description, Manufacture URL, BuyNow button

This is a great feature, thanks dharam1987.

I implemented this for my client who wanted a buy now button directly on the home page. They were delighted they got what they wanted, except they asked if when they hit the buy button, it could go directly to the final checkout page (we are using the authorize.net SIM method) instead of through the cart process.

Is this possible?

11 Jan 2010, 7:30 PM
#22
gingertea avatar

gingertea

New Zenner

Join Date:
Jul 2007
Posts:
36
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

Thank dharam1987 for this great add.

I'm having an issue in regard to products with attributes. The BUY NOW button places any given product that does not have any attributes successfully in the cart. If there are any attributes associated with the given product, it redirects to the product listing.

Each of my products has only one attribute, which is enabled for the purposes of making it a downloadable product. Is there something I need to modify in order to force the BUY NOW button for each product with an attribute to resume normal activity in regard to placing it into the cart?

ANY help would be greatly appreciated.

2 Feb 2010, 12:48 AM
#23
divaboutiques avatar

divaboutiques

Zen Follower

Join Date:
Feb 2007
Location:
Worldwide Web
Posts:
191
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

I tried to add the buy now button on the main page for new products and I am getting this error:

Parse error: syntax error, unexpected T_IF in /home/divabou/public_html/store/includes/modules/new_products.php on line 1

Here is my code here:

<?php/** * new_products.php module * * @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: new_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 = '';$new_products_query = '';$display_limit = zen_get_new_date_range();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') ) { $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, p.products_date_added, p.products_price, p.products_type, p.master_categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.products_status = 1 " . $display_limit;} 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 $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, p.products_date_added, p.products_price, p.products_type, p.master_categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.products_id in (" . $list_of_products . ")"; }}if ($new_products_query != '') $new_products = $db->ExecuteRandomMulti($new_products_query, MAX_DISPLAY_NEW_PRODUCTS);$row = 0;$col = 0;$list_box_contents = array();$title = '';$num_products_count = ($new_products_query == '') ? 0 : $new_products->RecordCount();// show only when 1 or moreif ($num_products_count > 0) { if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == 0 ) { $col_width = floor(100/$num_products_count); } else { $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS); } while (!$new_products->EOF) { $products_price = zen_get_products_display_price($new_products->fields['products_id']); if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']); $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"', 'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br />' . $products_price); $col ++; if ($col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS - 1)) { $col = 0; $row ++; } $new_products->MoveNextRandom(); } if ($new_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">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '</h2>'; } else { $title = '<h2 class="centerBoxHeading">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . '</h2>'; } $zc_show_new_products = true; }}?>
8 Apr 2010, 9:20 PM
#24
rxalex avatar

rxalex

Totally Zenned

Join Date:
Feb 2006
Posts:
588
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

How do I integrate into this

<?php /** * Electronics Template designed by zen-cart-power.com * zen-cart-power.com - Zen Cart templates and modules * Power your Zen Cart! * * * @copyright Copyright 2008-2009 Zen-Cart-Power.com * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 */ if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } // initialize vars $categories_products_id_list = ''; $list_of_products = ''; $new_products_query = ''; $number_of_columns = 3; $display_limit = zen_get_new_date_range(); 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') ) { $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, p.products_date_added, p.products_price, p.products_type, p.master_categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.products_status = 1 " . $display_limit; } 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 $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, p.products_date_added, p.products_price, p.products_type, p.master_categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.products_id in (" . $list_of_products . ")"; } } if ($new_products_query != '') $new_products = $db->ExecuteRandomMulti($new_products_query, MAX_DISPLAY_NEW_PRODUCTS); $row = 0; $col = 0; $list_box_contents = array(); $title = ''; $num_products_count = ($new_products_query == '') ? 0 : $new_products->RecordCount(); // show only when 1 or more if ($num_products_count > 0) { if ($num_products_count < $number_of_columns || $number_of_columns == 0 ) { $col_width = floor(100/$num_products_count); } else { $col_width = floor(100/$number_of_columns); } while (!$new_products->EOF) { $products_price = zen_get_products_display_price_pure_blue($new_products->fields['products_id']); if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']); //##wel - additional class for last div in string if ($col == $number_of_columns - 1) { $additional_class = 'no-right-margin'; } else { $additional_class = ''; } //wel $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew float-left ' . $additional_class . '"', 'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : ' <div class="productbox-top-left"><div class="productbox-top-right"></div></div> <div class="productbox-bg-left"><div class="productbox-bg-right"> <div class="columnar-product-info"> <div class="columnar-product-img"><a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a></div>') . '<div class="product-box-name"><a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . substr($new_products->fields['products_name'], 0, 40) . (strlen($new_products->fields['products_name']) > 40 ? "..." : "") . '</a></div> ' . '<span class="central-boxes-price">' . COLUMNAR_PRICE . ' ' . '</span>' . $products_price . ' ' . ' <br /><div class="detail-button"><a class="detail-link" href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">'. DETAIL_LINK .'</a></div> <div class="clearBoth"></div> </div> </div></div> <div class="productbox-bottom-left"><div class="productbox-bottom-right"></div></div>'); $col ++; if ($col > ($number_of_columns - 1)) { $col = 0; $row ++; } $new_products->MoveNextRandom(); } if ($new_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"><span>' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '</span></h2>'; } else { $title = '<h2 class="centerBoxHeading"><span>' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . '</span></h2>'; } $zc_show_new_products = true; } } ?>
29 May 2010, 11:08 AM
#25
creation avatar

creation

New Zenner

Join Date:
May 2010
Location:
South Coast of NSW Australia
Posts:
57
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

I have read all this with interest but I have to admit my understanding still a bit low.

Admin I can work out .. the code, thats not too bad ... when i can find it!!

My problem seems simple ---

I want to open my main page wwith the Featured items in the centra box in two rows of three or more rows if there are more than six etc

Fine ... go Config> and set the 'open with' at 22/ set the number of cols at 3// terrific but nothing' nothing at all - happens.

page is https://www.creationsdelphine.com/catalogue/

Any help appreciated

29 May 2010, 4:35 PM
#26
rxalex avatar

rxalex

Totally Zenned

Join Date:
Feb 2006
Posts:
588
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

This code didnt work for me... cant integrate as above

31 May 2010, 3:31 PM
#27
wheat avatar

wheat

New Zenner

Join Date:
Oct 2006
Posts:
62
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

Just a very loud and heartfelt THANK YOU

Although I have a relatively okay working .com site, we decided to use our .biz to develop from the ground up - starting with the 1.3.9c (well we did start with 1.3.9, but .... )

Not only did it work "as expected" and does not seem to have "broken" anything else,

But I ALSO wanted this to work for "NEW PRODUCTS (month)

  • I found actually found you by reading the install for the other add on which is for New Products. It did not work and after several hours of fussing and fiddling, I decided to try something else.

used a global search and replace, "match case" to change:

featured to new

and

FEATURED to NEW

Sometimes it is just that simple <G> and former blondes now gray really need that occasional simplicity

Meanwhile, it is not clear to me where to put the d_image css, but since it all seems to be working, I think maybe I should stop <G> now

Thank you again -

Wheat

The dev site is:
http://www.ItsAllJustString.biz

16 Dec 2010, 10:54 AM
#28
zillionzillion avatar

zillionzillion

New Zenner

Join Date:
Dec 2010
Posts:
4
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

I am using 1.3.9h.

I am trying to add an add to cart box/button on every featured product on the main page.

I tried to add

$add_code .='. <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']) . '">' . '<img src="my image link" />' . '</a>';

It doesn't work.

How can I add an add to cart box/button on every featured product on the main page?

Please help.

27 May 2011, 6:21 PM
#29
elly avatar

elly

New Zenner

Join Date:
May 2011
Posts:
49
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

I love this mod :wub:

I put in the code on page one and it works - brilliantly.

One minor style niggle: I didn't like the way it shifted everything in the columns to the left. I preferred them centred. So I looked in the original code and figured out how to do this.

This file may have been modified when I added in the columns mod. However, I thought this may be used to others still learning (as I am)

Find this part of the code as posted at tht top of the thread:

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

Cut out the bit: 'class="back"'

Replace with: 'class="centerBoxContentsFeatured centeredContent back"'

et voila! It's centred again :smartalec:

16 Jan 2012, 4:00 PM
#30
windsurfer avatar

windsurfer

Zen Follower

Join Date:
Jun 2011
Posts:
185
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

Hi dharam1987
I tried to insert this code in the "includes\functions\extra_functions\index_listing.php" file for V1.5 but that doesn't work, is there a mod for this version that will do this ?
Thanks

26 Nov 2013, 4:52 AM
#31
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

Anyone get this mod to work on V 1.5.1?
If so would you share the code?
What I really need is just a "By Now/Add to Cart" button on the Main Page for the "New Products".

Thanks in Advance.

26 Nov 2013, 6:08 AM
#32
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

linuxguy2:

Anyone get this mod to work on V 1.5.1?
If so would you share the code?
What I really need is just a "By Now/Add to Cart" button on the Main Page for the "New Products".

Thanks in Advance.

Check the plugin section for Flexible NSF (New, Specials & Featured) Center-boxes

26 Nov 2013, 3:05 PM
#33
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

Thanks,
I'll take it for a spin & let you know how it works out.

26 Nov 2013, 5:39 PM
#34
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

Installed per instructions on my soon to be production test site and setting "More Info" to false did not get rid of the ....more info. I am NOT using any attributes.

Then I installed on a out of the box fresh zc install using the default "Classic" template with demo product and set ALL settings in the Mod to false but I still get the ... more info.
With everything turned on I get double ... more info on some items which is probably due the attributes being set fo those items.

The setting isn't taking so I will probably just comment out this code around line 103 but this should be fixed.
Am I missing something?

Line #103 : $more_info_link = '<div class="flexNCBinfo">' . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($new_products->fields['master_categories_id']) . '&products_id=' . $new_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>' . '</div>';

26 Nov 2013, 7:48 PM
#35
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

linuxguy2:

Installed per instructions on my soon to be production test site and setting "More Info" to false did not get rid of the ....more info. I am NOT using any attributes.

Then I installed on a out of the box fresh zc install using the default "Classic" template with demo product and set ALL settings in the Mod to false but I still get the ... more info.
With everything turned on I get double ... more info on some items which is probably due the attributes being set fo those items.

The setting isn't taking so I will probably just comment out this code around line 103 but this should be fixed.
Am I missing something?

Line #103 : $more_info_link = '<div class="flexNCBinfo">' . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($new_products->fields['master_categories_id']) . '&products_id=' . $new_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>' . '</div>';

I will double test and fix the bugs and re-upload. Thank you for pointing that out!

27 Nov 2013, 4:55 PM
#36
linuxguy2 avatar

linuxguy2

Zen Follower

Join Date:
Sep 2013
Location:
Texas
Posts:
315
Plugin Contributions:
0

Re: Code to display Featured Category with Description, Manufacture URL, BuyNow button

Thanks for checking.

I am only using the "new products" on the main page page so I commented out the code in your module.

// Remove ... more info link
// if (DISPLAY_FLEX_NEW_CENTERBOX_MORE_INFO == 'true' && zen_has_product_attributes($new_products->fields['products_id'])) {
// $more_info_link = '';
// } else {
// $more_info_link = '<div class="flexNCBinfo">' . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($new_products->fields['master_categories_id']) . '&products_id=' . $new_products->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>' . '</div>';
// }

I'm just doing a flat category/product entry. No attributes what so ever.