Results 1 to 5 of 5
  1. #1

    Default how to add the add-to-cart-button to the new products box on the home page?

    i have doneload a free zen-cart templates on templatemonster website, through this code i can easy show product descrption on home page,but i can't show the add-to-cart button on home page,

    the php code is:
    PHP Code:
    <?php
    /**
     * new_products.php module
     *
     * @package modules
     * @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
     * @version $Id: new_products.php 4629 2006-09-28 15:29:18Z ajeh $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }
    // display limits
    //$display_limit = zen_get_products_new_timelimit();
          
    $display_limit zen_get_new_date_range();

    if ( (!isset(
    $new_products_category_id)) || ($new_products_category_id == '0') ) {
      
    $new_products_query "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, p.products_date_added, pd.products_description
                               from " 
    TABLE_PRODUCTS " p 
                               left join " 
    TABLE_PRODUCTS_DESCRIPTION " pd on p.products_id = pd.products_id 
                               where p.products_status = 1 " 
    $display_limit;
    } else {
      
    $new_products_query "select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_date_added, pd.products_description,
                                               p.products_price
                               from " 
    TABLE_PRODUCTS " p 
                               left join " 
    TABLE_PRODUCTS_DESCRIPTION " pd on p.products_id = pd.products_id 
                               left join " 
    TABLE_SPECIALS " s
                               on p.products_id = s.products_id, " 
    TABLE_PRODUCTS_TO_CATEGORIES " p2c, " .
      
    TABLE_CATEGORIES " c
                               where p.products_id = p2c.products_id
                               and p2c.categories_id = c.categories_id
                               and c.parent_id = '" 
    . (int)$new_products_category_id "'
                               and p.products_status = 1 " 
    $display_limit;
    }
    $new_products $db->ExecuteRandomMulti($new_products_queryMAX_DISPLAY_NEW_PRODUCTS);

    $row 0;
    $col 0;
    $list_box_contents = array();
    $title '';

    $num_products_count $new_products->RecordCount();

    // show only when 1 or more
    if ($num_products_count 0) {
      if (
    $num_products_count SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == ) {
        
    $col_width floor(100/$num_products_count);
      } else {
        
    $col_width floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS);
      }

      while (!
    $new_products->EOF) {
      
        
    $products_img = (($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']), '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_WIDTHIMAGE_PRODUCT_NEW_HEIGHT) . '</a>');
        
        
    $products_name '<a class="name" href="' zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'products_id=' $new_products->fields['products_id']) . '">' zen_get_products_name($new_products->fields['products_id']) . '</a>';
        
        
    $products_desc substr(strip_tags($new_products->fields['products_description']), 025) . '...';
        
        
    $products_price '<strong>' zen_get_products_display_price($new_products->fields['products_id']) . '</strong>';
        
        
    $products_######## = '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'products_id=' . $new_products->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_GOTO_PROD_DETAILS, BUTTON_GOTO_PROD_DETAILS_ALT) . '</a>';
      
      
          
    $img_col_w IMAGE_PRODUCT_NEW_WIDTH 10;

      

        if (
    SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS && $num_products_count 1) {
        
            if (
    $col && $col SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS) {
                
    $tm_param 'style="margin-left:2px;"';
            } else {
                
    $tm_param '';
            }
        
        
    $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' ' ' 'style="width:' $col_width '%;"',
        
    'text' => 
        
                
    '<div class="product product_border" align="center" ' $tm_param '>
                    <div class="margin_col">
                        ' 
    $products_img '<br />
                        <br style="line-height:10px;" />
                        ' 
    $products_name '<br />
                        <div class="text">
                            ' 
    $products_desc '<br />
                        </div>
                        ' 
    $products_price '<br>
                        <br style="line-height:10px;" />
                        ' 
    $products_######## . '
                        
    <div class="spacer"><br class="clear" /></div>
                    </
    div>
                </
    div>'
                    
                    
                    );
                    
        } else {

        $list_box_contents[$row][$col] = array('
    params' =>'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
        '
    text' => 
        
                '
    <div class="product">
                    <
    div class="w_100">
                        <
    div class="right" style="margin-left:-' . $img_col_w . 'px;">
                            <
    div class="margin" style="margin-left:' . $img_col_w . 'px;">
                                
    ' . $products_name . '<br />
                                <
    div class="text">
                                    
    ' . $products_desc . '
                                
    </div>
                                <
    div class="price">
                                    
    ' . $products_price . '
                                
    </div>
                                <
    div class="button">' . $products_######## . '</div>
                                <
    div class="clear"></div>
                            </
    div>
                        </
    div>
                        <
    div class="left" style="width:' . $img_col_w . 'px;">
                            
    ' . $products_img . '
                        
    </div>
                        <
    div class="clear"></div>
                    </
    div>
                </
    div>'
                        
                );
        
        }
        
        

        $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;
      }
    }
    ?>

  2. #2

    Default Re: how to add the add-to-cart-button to the new products box on the home page

    Hi ebloger,

    First, templatemonster very often has wonky code. A lot of what they do involves hacking up the original code and makes getting help here on the forum difficult sometimes because there isn't always a way to overcome what has been done to the code.

    Second, you should only be editing code when it's the only way to make the changes you want. Many changes can be made through the admin panel. Always look for the easier way to accomplish something (i.e. via the admin panel) before going to change your code.

    You did not need to edit the code you posted in order to show your product descriptions on the main page. This could have been accomplished through your admin panel.

    Third, if you haven't yet learned about and implemented the override system, you should do that before you make another change to your ZC.

    Lastly, the buy now buttons can be set to display through the admin panel. Go to admin/configuration/all listings.

    Hope this helps.
    Go that extra mile, you never know what's at the end of the road

    Empowerment Sanctuary

  3. #3

    Default Re: how to add the add-to-cart-button to the new products box on the home page

    Correction:

    admin/configuration/product listing turns the buy now buttons on and off.

    admin/configuration/all listings determines the position of the buy now buttons on the page.
    Go that extra mile, you never know what's at the end of the road

    Empowerment Sanctuary

  4. #4
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: how to add the add-to-cart-button to the new products box on the home page

    @ScriptJunkie

    I agree that it's always best to look for changes that can be effected via the Admin though the changes that ebloger wants can't be done there and need code changes in the current version of Zen Cart.

    @ebloger
    I assume that you're after an effect similar to that demonstrated on www.monkeyshine.co.uk, which was achieved though changes similar to that which you've already done for the product description and adding the 'add to cart box' from around about line 88 to 114 of tpl_product_info_display.php into relevant template files.

    Afterthought - if you have attributes you will get a more info link rather than buy now button (or a choose options button on Monkeyshine)
    Last edited by kuroi; 10 Nov 2008 at 10:32 AM. Reason: afterthought
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  5. #5
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: how to add the add-to-cart-button to the new products box on the home page

    Quote Originally Posted by ScriptJunkie View Post
    Correction:

    admin/configuration/product listing turns the buy now buttons on and off.

    admin/configuration/all listings determines the position of the buy now buttons on the page.
    ... turns them on and off on the product listing page, not in the new products box on the home page which is what ebloger is actually working with.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

 

 

Similar Threads

  1. How do I move the Add To Cart Box down on the products page?
    By mleahy in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 29 Mar 2011, 11:40 PM
  2. How do I add rounded corners to the small "New Products" images on the home page?
    By cuiljoe in forum Templates, Stylesheets, Page Layout
    Replies: 16
    Last Post: 1 Apr 2010, 12:03 PM
  3. Replies: 3
    Last Post: 23 Sep 2008, 06:25 PM
  4. add to cart box on every item on my home page near the details button
    By crash_bandicoot in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 20 Feb 2008, 11:41 AM
  5. add to cart box on every item on my home page near the details button
    By crash_bandicoot in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 5 Feb 2008, 08:23 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR