Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2007
    Posts
    38
    Plugin Contributions
    0

    Default Display quantity discounts on listing page

    Hi everyone,
    This question has been raised before on this forum, but I have been unable to find an answer.
    I am trying to add the quantity discount box from the product info page to the product listing page. I have tried every possible combination under the sun, and I feel that the closer I get, the further away I am.
    I am modifying 2 files: product_listing.php and tpl_modules_products_quantity_discounts.php. I am using the template override system.

    My idea is to alter the value of $lc_price to contain the HTML for the quantity discount box.

    Here are the files, so you can have a look:

    tpl_modules_products_quantity_discounts.php
    PHP Code:
    <?php
    /**
     * Module Template
     *
     * @package templateSystem
     * @copyright Copyright 2003-2005 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: tpl_modules_products_quantity_discounts.php 2008-02-04 PRedmond $
     * Based on: tpl_modules_products_quantity_discounts.php 3291 2006-03-28 04:03:38Z ajeh $
     */
     
      
    if ($zc_hidden_discounts_on) {
       
    $lc_price '<table border="1" cellspacing="2" cellpadding="2">';
       
    $lc_price .= '<tr>';
       
    $lc_price .= '<td colspan="1" align="center">';
       
    $lc_price .= TEXT_HEADER_DISCOUNTS_OFF;
       
    $lc_price .= '</td>';
       
    $lc_price .= '</tr>';
       
    $lc_price .= '<tr>';
       
    $lc_price .= '<td colspan="1" align="center">';
       
    $lc_price .= $zc_hidden_discounts_text;
       
    $lc_price .= '</td>';
       
    $lc_price .= '</tr>';
       
    $lc_price .= '</table>';
     } else {
    $lc_price .= '<table border="1" cellspacing="2" cellpadding="2">';
    $lc_price .= '<tr>';
    $lc_price .= '<td colspan="' . ($columnCount+1) . '" align="center">';
      switch (
    $products_discount_type) {
        case 
    '1':
         
    $lc_price .= TEXT_HEADER_DISCOUNT_PRICES_PERCENTAGE;
          break;
        case 
    '2':
          
    $lc_price .= TEXT_HEADER_DISCOUNT_PRICES_ACTUAL_PRICE;
          break;
        case 
    '3':
          
    $lc_price .= TEXT_HEADER_DISCOUNT_PRICES_AMOUNT_OFF;
          break;
      }
    $lc_price .= '</td>';
    $lc_price .= '</tr>';
    $lc_price .= '<tr>';
    $lc_price .= '<td align="center">' $show_qty '<br />' $currencies->display_price($show_pricezen_get_tax_rate($products_tax_class_id)) . '</td>';
     
      foreach(
    $quantityDiscounts as $key=>$quantityDiscount) {
    $lc_price .= '<td align="center">' $quantityDiscount['show_qty'] . '<br />' $currencies->display_price($quantityDiscount['discounted_price'], zen_get_tax_rate($products_tax_class_id)) . '</td>';
        
    $disc_cnt++;
        if (
    $discount_col_cnt == $disc_cnt && !($key == sizeof($quantityDiscount))) {
          
    $disc_cnt=0;
    $lc_price .= '</tr><tr>';
        }
      }
      if (
    $disc_cnt $columnCount) {
    $lc_price .= '<td align="center" colspan="' . ($columnCount+$disc_cnt)+'> &nbsp; </td>';
     } 
    $lc_price .= '</tr>';
      if (
    zen_has_product_attributes($products_id_current)) {
    $lc_price .= '<tr>';
    $lc_price .= '<td colspan="' $columnCount+'" align="center">';
    $lc_price .= TEXT_FOOTER_DISCOUNT_QUANTITIES
    $lc_price .= '</td>';
    $lc_price .= '</tr>';
     
      } 
    $lc_price .= '</table>';
     
      } 
    // hide discounts

    product_listing.php
    PHP Code:
    <?php
    /**
     * product_listing 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: product_listing.php 4655 2006-10-02 01:02:38Z ajeh $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }
    $show_submit zen_run_normal();
    $listing_split = new splitPageResults($listing_sqlMAX_DISPLAY_PRODUCTS_LISTING'p.products_id''page');
    $how_many 0;
    $list_box_contents[0] = array('params' => 'class="productListing-rowheading"');
    $zc_col_count_description 0;
    $lc_align '';
    for (
    $col=0$n=sizeof($column_list); $col<$n$col++) {
      switch (
    $column_list[$col]) {
        case 
    'PRODUCT_LIST_MODEL':
        
    $lc_text TABLE_HEADING_MODEL;
        
    $lc_align '';
        
    $zc_col_count_description++;
        break;
        case 
    'PRODUCT_LIST_NAME':
        
    $lc_text TABLE_HEADING_PRODUCTS;
        
    $lc_align '';
        
    $zc_col_count_description++;
        break;
        case 
    'PRODUCT_LIST_MANUFACTURER':
        
    $lc_text TABLE_HEADING_MANUFACTURER;
        
    $lc_align '';
        
    $zc_col_count_description++;
        break;
        case 
    'PRODUCT_LIST_PRICE':
        
    $lc_text TABLE_HEADING_PRICE;
        
    $lc_align 'right' . (PRODUCTS_LIST_PRICE_WIDTH '" width="' PRODUCTS_LIST_PRICE_WIDTH '');
        
    $zc_col_count_description++;
        break;
        case 
    'PRODUCT_LIST_QUANTITY':
        
    $lc_text TABLE_HEADING_QUANTITY;
        
    $lc_align 'right';
        
    $zc_col_count_description++;
        break;
        case 
    'PRODUCT_LIST_WEIGHT':
        
    $lc_text TABLE_HEADING_WEIGHT;
        
    $lc_align 'right';
        
    $zc_col_count_description++;
        break;
        case 
    'PRODUCT_LIST_IMAGE':
        
    $lc_text TABLE_HEADING_IMAGE;
        
    $lc_align 'center';
        
    $zc_col_count_description++;
        break;
      }
      if ( (
    $column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
        
    $lc_text zen_create_sort_heading($_GET['sort'], $col+1$lc_text);
      }
     
      
    $list_box_contents[0][$col] = array('align' => $lc_align,
                                          
    'params' => 'class="productListing-heading"',
                                          
    'text' => $lc_text );
    }
    if (
    $listing_split->number_of_rows 0) {
      
    $rows 0;
      
    $listing $db->Execute($listing_split->sql_query);
      
    $extra_row 0;
      while (!
    $listing->EOF) {
        
    $rows++;
        if (((
    $rows-$extra_row)/2) == floor(($rows-$extra_row)/2)) {
          
    $list_box_contents[$rows] = array('params' => 'class="productListing-even"');
        } else {
          
    $list_box_contents[$rows] = array('params' => 'class="productListing-odd"');
        }
        
    $cur_row sizeof($list_box_contents) - 1;
        for (
    $col=0$n=sizeof($column_list); $col<$n$col++) {
          
    $lc_align '';
          switch (
    $column_list[$col]) {
            case 
    'PRODUCT_LIST_MODEL':
            
    $lc_align '';
            
    $lc_text $listing->fields['products_model'];
            break;
            case 
    'PRODUCT_LIST_NAME':
            
    $lc_align '';
            if (isset(
    $_GET['manufacturers_id'])) {
              
    $lc_text '<h3 class="itemTitle"><a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' $listing->fields['products_id']) . '">' $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
            } else {
              
    $lc_text '<h3 class="itemTitle"><a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 'cPath=' $_GET['cPath'] . '&' '') . 'products_id=' $listing->fields['products_id']) . '">' $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
            }
            break;
            case 
    'PRODUCT_LIST_MANUFACTURER':
            
    $lc_align '';
            
    $lc_text '<a href="' zen_href_link(FILENAME_DEFAULT'manufacturers_id=' $listing->fields['manufacturers_id']) . '">' $listing->fields['manufacturers_name'] . '</a>';
            break;
            case 
    'PRODUCT_LIST_PRICE':
     
     
        
    $products_discount_type zen_products_lookup($listing->fields['products_id'], $what_field 'products_discount_type');
        if (
    $products_discount_type != 0) {
          
    $rows++;
          
    $products_id_current = (int)$listing->fields['products_id'];
          
    $quantityDiscounts = array();
          
    $products_discount_type_from zen_products_lookup($listing->fields['products_id'], $what_field 'products_discount_type_from');
          require(
    DIR_WS_MODULES zen_get_module_directory(FILENAME_PRODUCTS_QUANTITY_DISCOUNTS));
          require(
    $template->get_template_dir('/tpl_modules_products_quantity_discounts.php',DIR_WS_TEMPLATE$current_page_base,'templates'). '/tpl_modules_products_quantity_discounts.php');
      }
     
              echo 
    $lc_price;
            
    //$lc_price = zen_get_products_display_price($listing->fields['products_id'])  . " OK";
            
    $lc_align 'right';
            
    $lc_text =  $lc_price;
     
     
            
    // more info in place of buy now
            
    $lc_button '';
            if (
    zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
              
    $lc_button '<a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 'cPath=' $_GET['cPath'] . '&' '') . 'products_id=' $listing->fields['products_id']) . '">' MORE_INFO_TEXT '</a>';
            } else {
              if (
    PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
                if (
                    
    // not a hide qty box product
                    
    $listing->fields['products_qty_box_status'] != &&
                    
    // product type can be added to cart
                    
    zen_get_products_allow_add_to_cart($listing->fields['products_id']) != 'N'
                    
    &&
                    
    // product is not call for price
                    
    $listing->fields['product_is_call'] == 0
                    
    &&
                    
    // product is in stock or customers may add it to cart anyway
                    
    ($listing->fields['products_quantity'] > || SHOW_PRODUCTS_SOLD_OUT_IMAGE == 0) ) {
                  
    $how_many++;
                }
                
    // hide quantity box
                
    if ($listing->fields['products_qty_box_status'] == 0) {
                  
    $lc_button '<a href="' zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' $listing->fields['products_id']) . '">' zen_image_button(BUTTON_IMAGE_BUY_NOWBUTTON_BUY_NOW_ALT'class="listingBuyNowButton"') . '</a>';
                } else {
                  
    $lc_button TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART "<input type=\"text\" name=\"products_id[" $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
                }
              } else {
    // qty box with add to cart button
                
    if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
                  
    $lc_buttonzen_draw_form('cart_quantity'zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' $listing->fields['products_id']), 'post''enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' zen_draw_hidden_field('products_id'$listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CARTBUTTON_IN_CART_ALT) . '</form>';
                } else {
                  
    $lc_button '<a href="' zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' $listing->fields['products_id']) . '">' zen_image_button(BUTTON_IMAGE_BUY_NOWBUTTON_BUY_NOW_ALT'class="listingBuyNowButton"') . '</a>';
                }
              }
            }
            
    $the_button $lc_button;
            
    $products_link '<a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 'cPath=' $_GET['cPath'] . '&' '') . 'products_id=' $listing->fields['products_id']) . '">' MORE_INFO_TEXT '</a>';
            
    $lc_text .= '<br />' zen_get_buy_now_button($listing->fields['products_id'], $the_button$products_link) . '<br />' zen_get_products_quantity_min_units_display($listing->fields['products_id']);
            
    $lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON '<br />' '') : '');
     
     
            break;
            case 
    'PRODUCT_LIST_QUANTITY':
            
    $lc_align 'right';
            
    $lc_text $listing->fields['products_quantity'];
            break;
            case 
    'PRODUCT_LIST_WEIGHT':
            
    $lc_align 'right';
            
    $lc_text $listing->fields['products_weight'];
            break;
            case 
    'PRODUCT_LIST_IMAGE':
            
    $lc_align 'center';
            if (
    $listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
              
    $lc_text '';
            } else {
              if (isset(
    $_GET['manufacturers_id'])) {
                
    $lc_text '<a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' $listing->fields['products_id']) . '">' zen_image(DIR_WS_IMAGES $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTHIMAGE_PRODUCT_LISTING_HEIGHT'class="listingProductImage"') . '</a>';
              } else {
                
    $lc_text '<a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 'cPath=' $_GET['cPath'] . '&' '') . 'products_id=' $listing->fields['products_id']) . '">' zen_image(DIR_WS_IMAGES $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTHIMAGE_PRODUCT_LISTING_HEIGHT'class="listingProductImage"') . '</a>';
              }
            }
            break;
          }
          
    $list_box_contents[$rows][$col] = array('align' => $lc_align,
                                                  
    'params' => 'class="productListing-data"',
                                                  
    'text'  => $lc_text);
     
        }
        
    // add description and match alternating colors
        //if (PRODUCT_LIST_DESCRIPTION > 0) {
        //  $rows++;
        //  if ($extra_row == 1) {
        //    $list_box_description = "productListing-data-description-even";
        //    $extra_row=0;
        //  } else {
        //    $list_box_description = "productListing-data-description-odd";
        //    $extra_row=1;
        //  }
        //  $list_box_contents[$rows][] = array('params' => 'class="' . $list_box_description . '" colspan="' . $zc_col_count_description . '"',
        //  'text' => zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION));
        //}
     
     
        
    $listing->MoveNext();
      }
     
      
    $error_categories false;
    } else {
      
    $list_box_contents = array();
      
    $list_box_contents[0] = array('params' => 'class="productListing-odd"');
      
    $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                                  
    'text' => TEXT_NO_PRODUCTS);
      
    $error_categories true;
    }
    if ((
    $how_many and $show_submit == true and $listing_split->number_of_rows 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == or  PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 3) ) {
      
    $show_top_submit_button true;
    } else {
      
    $show_top_submit_button false;
    }
    if ((
    $how_many and $show_submit == true and $listing_split->number_of_rows 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART >= 2) ) {
      
    $show_bottom_submit_button true;
    } else {
      
    $show_bottom_submit_button false;
    }
     
      if (
    $how_many && PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != and $show_submit == true and $listing_split->number_of_rows 0) {
      
    // bof: multiple products
        
    echo zen_draw_form('multiple_products_cart_quantity'zen_href_link(FILENAME_DEFAULTzen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post''enctype="multipart/form-data"');
      }
     
    ?>
    As an aside, is there any documentation on the interaction of all the files?? I would be interested in helping work on this if there is not, as I think it would help a lot of users - me included!!

    Thanks for any advice any may have.

  2. #2
    Join Date
    Dec 2009
    Posts
    43
    Plugin Contributions
    0

    Default Re: Display quantity discounts on listing page

    Please help ! I have same issue. Please someone....
    anyone?
    Thanks,
    digulu

  3. #3
    Join Date
    Aug 2010
    Posts
    2
    Plugin Contributions
    0

    Default Re: Display quantity discounts on listing page

    +10,000.

  4. #4
    Join Date
    Dec 2010
    Posts
    60
    Plugin Contributions
    0

    Default Re: Display quantity discounts on listing page

    Hopefully in the next version. I need this too as if I add the cart button to the listing page no one gets to see the quantity discounts

    Fred McCaughey

  5. #5
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Display quantity discounts on listing page

    This does work, you can see it live here.

    I will put something together for download by weeks end if anybody is still in need of this.

  6. #6
    Join Date
    Jan 2012
    Posts
    16
    Plugin Contributions
    0

    Default Re: Display quantity discounts on listing page

    Thank You so much, this works great!!

 

 

Similar Threads

  1. Replies: 17
    Last Post: 19 Feb 2013, 12:45 PM
  2. Mod to display qty. discounts in category listing?
    By DCDC in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 25 May 2010, 06:53 PM
  3. Can I display Quantity Discounts in my Product Listing?
    By digulu in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 3 Jan 2010, 07:41 AM
  4. Problem with the way the quantity discounts display on the product page
    By Kegless.co.uk in forum Setting Up Specials and SaleMaker
    Replies: 1
    Last Post: 7 May 2009, 12:24 AM
  5. Replies: 3
    Last Post: 5 Jul 2007, 05:55 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