Page 1 of 2 12 LastLast
Results 1 to 10 of 22

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Posts
    50
    Plugin Contributions
    2

    Default Re: how to ?: make "buy it now" link in featured products on the front page

    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.
    Code:
    <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.

  2. #2
    Join Date
    Aug 2006
    Location
    Singapore
    Posts
    167
    Plugin Contributions
    1

    Default Re: how to ?: make "buy it now" link in featured products on the front page

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

    PHP 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']) . '">' zen_image_button(BUTTON_IMAGE_BUY_NOWBUTTON_BUY_NOW_ALT) . '</a>&nbsp;'
    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!

  3. #3
    Join Date
    Aug 2006
    Location
    Singapore
    Posts
    167
    Plugin Contributions
    1

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

    Any helps?

  4. #4
    Join Date
    Mar 2009
    Location
    India, Hyderabad
    Posts
    36
    Plugin Contributions
    1

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

    Quote Originally Posted by milkyway View Post
    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.

  5. #5
    Join Date
    Mar 2009
    Location
    India, Hyderabad
    Posts
    36
    Plugin Contributions
    1

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

    Quote Originally Posted by dharam1987 View Post
    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>&nbsp;');

    USE THE ABOVE CODE

  6. #6
    Join Date
    Mar 2009
    Location
    India, Hyderabad
    Posts
    36
    Plugin Contributions
    1

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

    Quote Originally Posted by dharam1987 View Post
    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>&nbsp;');

    USE THE ABOVE CODE
    http://www.zen-cart.com/forum/showth...607#post704607

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

  7. #7
    Join Date
    Aug 2006
    Location
    Singapore
    Posts
    167
    Plugin Contributions
    1

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

    Thank you very much!, thats solved the problem

  8. #8
    Join Date
    Mar 2009
    Location
    India, Hyderabad
    Posts
    36
    Plugin Contributions
    1

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

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

  9. #9
    Join Date
    Jun 2009
    Posts
    43
    Plugin Contributions
    0

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

    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.

    Code:
    <?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;
    
      }
    
    }
    
    ?>

  10. #10
    Join Date
    Sep 2005
    Location
    Ocala, FL
    Posts
    528
    Plugin Contributions
    0

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

    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:
    www.gelcandlecompany.com

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v150 How Do I Make The "Buy Now" Button Go Away For Just One Item?
    By Scully in forum General Questions
    Replies: 5
    Last Post: 12 Feb 2013, 10:33 PM
  2. How to make an old product turn up under "new products" on the front page?
    By Nina_Paris_France in forum Customization from the Admin
    Replies: 4
    Last Post: 13 Jun 2011, 06:37 PM
  3. How to: new/featured main page - "buy now/details" change to "design" with attributes
    By ladybugmom in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 18 Jan 2011, 11:23 AM
  4. Replies: 12
    Last Post: 17 Jul 2009, 01:26 AM
  5. Replies: 0
    Last Post: 9 Sep 2008, 03:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg